---
title: "Initiate OAuth login for an MCP server"
method: POST
path: "/api/mcp/oauth/login"
tags: ["v2", "mcp", "mcp"]
---

# Initiate OAuth login for an MCP server

`POST /api/mcp/oauth/login`

Discover OAuth metadata from the MCP server and return a login URL.

1. Discovers the protected-resource metadata (RFC 9728)
2. Fetches the authorization server metadata (RFC 8414)
3. Performs Dynamic Client Registration (RFC 7591) if available
4. Returns the authorization URL for the frontend to open in a popup

## Request body

- MCPOAuthLoginRequest — Request to start an OAuth flow for an MCP server.
  - `server_url` string, required — URL of the MCP server that requires OAuth

## Response `200`

Successful Response

- MCPOAuthLoginResponse — Response with the OAuth login URL for the user to authenticate.
  - `login_url` string, required
  - `state_token` string, required

## Other responses

- `401` — Authentication required
- `422` — Validation Error

---

[API](https://skmtc.net/significant-gravitas/apis/autogpt-agent-server.md) · [All operations](https://skmtc.net/significant-gravitas/apis/autogpt-agent-server/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/significant-gravitas/autogpt-agent-server/versions/382041c7ecb2/schema)
