The flow (first use)
Client requests a tool
Your AI client (Claude Code, Cursor, etc.) calls an MCP tool — say,
generate.Server returns 401
Without a valid Bearer token, the server returns
401 Unauthorized with a WWW-Authenticate header pointing to the OAuth metadata.Client opens browser
The client starts an OAuth flow: opens
https://app.artificialstudio.ai/connect in your default browser with a PKCE challenge.You sign in and approve
You sign in to Artificial Studio (if not already) and click Authorize. The browser redirects back to your AI client’s localhost callback with an auth code.
OAuth endpoints
The server exposes standard OAuth discovery metadata:| Endpoint | Purpose |
|---|---|
/.well-known/oauth-protected-resource | Resource metadata referenced from 401 responses |
/.well-known/oauth-authorization-server | Authorization server metadata (endpoints, supported grants) |
/oauth/authorize | Authorization endpoint (browser) |
/oauth/token | Token endpoint (exchange code, refresh) |
/oauth/register | Dynamic client registration (DCR) |
authorization_code(with PKCE — required)refresh_token
Scopes
Current scopes granted:- Read your account (credits, plan, profile)
- Read your generations
- Run generations (charges your credits like the dashboard)
Token storage
Tokens are stored by the client, not by Artificial Studio:- Claude Code: OS keychain /
~/.claude - Cursor: OS keychain
- Claude Desktop (via
mcp-remote):~/.mcp-auth/directory
Redirect URIs
For native clients, the server’s redirect URI whitelist accepts:http://localhost:<port>/*http://127.0.0.1:<port>/*
Troubleshooting
Browser doesn't open on first use
Browser doesn't open on first use
Some clients (especially in SSH / headless sessions) can’t launch a browser. Copy the authorize URL from the client logs and open it manually on a machine where you’re logged in — then paste the callback URL back into the client when prompted.
'invalid_token' after working for a while
'invalid_token' after working for a while
Your access token expired and the refresh failed. Remove the stored token and re-authenticate:
- Claude Code:
claude mcp remove artificial-studio && claude mcp add --transport http artificial-studio https://api.artificialstudio.ai/mcp - Cursor: remove the entry from
mcp.json, restart, re-add. - Claude Desktop (mcp-remote):
rm -rf ~/.mcp-auth/and restart.
'redirect_uri mismatch'
'redirect_uri mismatch'
The port your client chose for the OAuth callback isn’t accepted. Make sure you’re on the latest version of your MCP client — old versions sometimes pick non-localhost URIs. If it persists, open a support ticket with the exact redirect_uri from the error.
Multiple accounts
Multiple accounts
Each machine / profile stores one token. To switch accounts, remove the stored token (see above) and re-authenticate with the other account.
Next steps
Tool reference
All 6 tools, their args, and responses.
Async & polling
How to handle long-running generations.