Skip to main content
Vaults

Start MCP OAuth

Start an OAuth authorization flow and store the resulting MCP credential in a vault.

POST /api/v1/cloud/oauth/start Starts an OAuth authorization flow for an MCP server. CAS discovers the server's OAuth metadata, prepares PKCE, and returns the provider authorization URL. After the provider redirects to the CAS callback, CAS exchanges the authorization code and stores an mcp_oauth credential in the selected Vault.

Headers

HeaderRequiredDescription
AuthorizationYesBearer $QODER_ACCESS_TOKEN
Content-TypeYesapplication/json

Request body

FieldTypeRequiredDescription
vault_idstringYesActive Vault in which CAS will store the resulting credential
mcp_server_urlstringYesMCP server URL used for OAuth metadata discovery and later credential matching
client_idstringNoPre-registered OAuth client ID. If omitted, CAS uses dynamic client registration when the authorization server advertises it
client_secretstringNoSecret for the supplied client_id. Provide these two fields together for a confidential client
protocol, scope, and redirect_uri are not request fields. CAS discovers the OAuth endpoints and scopes from server metadata and always uses its configured callback URL.

Example request

curl -X POST https://api.qoder.com/api/v1/cloud/oauth/start \
  -H "Authorization: Bearer $QODER_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "vault_id": "vault_019e5cdb9c3f71c3b6505eba937a40b4",
    "mcp_server_url": "https://mcp.linear.app/mcp",
    "client_id": "",
    "client_secret": ""
  }'

Example response

HTTP 200 OK
{
  "authorization_url": "https://auth.example.com/authorize?client_id=cloud-agent&code_challenge=...&code_challenge_method=S256&redirect_uri=...&response_type=code&state=...",
  "state": "65eec7b8e79aa61c249d971678cf9201",
  "callback_origin": "https://api.qoder.com"
}
FieldTypeDescription
authorization_urlstringProvider URL to open in a browser
statestringOpaque, short-lived OAuth state. Use it only to correlate the popup callback
callback_originstringOrigin from which the browser callback message is expected

Complete the authorization

  1. Open authorization_url in a browser window.
  2. The user approves access at the OAuth provider.
  3. The provider redirects to the callback URL embedded by CAS. The callback URL is service-configured and cannot be overridden by this request.
  4. CAS validates and consumes the one-time state, exchanges the code for tokens, and creates an mcp_oauth credential in vault_id.
  5. The callback page sends an oauth_callback message to its opener. You can also list the Vault's credentials to retrieve the new credential ID; secret values are never returned.
The flow requires PKCE S256. When no client_id is supplied and the provider advertises a registration endpoint, CAS dynamically registers a public OAuth client.

Browser redirect shortcut

GET /api/v1/cloud/oauth/authorize accepts vault_id, mcp_server_url, and client_id as query parameters, starts the same flow, and responds with an HTTP redirect to the provider. Use POST /oauth/start when a client secret is required; do not place secrets in a URL.

Errors

HTTPTypeTrigger
400invalid_request_errorRequired field missing, Vault inactive, metadata discovery or dynamic registration failed, or the provider does not support required PKCE/token authentication behavior
401authentication_errorPAT or SAT missing, invalid, or expired
404not_found_errorVault does not exist or is not accessible
409conflict_errorVault is not active, or an active credential for the MCP URL already exists when the callback stores the credential