---
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
  - `scopes` string[], nullable — OAuth scopes to request. Omit or use null to use catalogue or discovered defaults; an empty list requests no scopes.

## 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

## Changes

- **2026-09-17** `5f27fa9d6c03` — 1 info
  - added the new optional request property `scopes`

[Change history](https://skmtc.dev/significant-gravitas/apis/autogpt-agent-server/changes/api/mcp/oauth/login/post.md)

---

[API](https://skmtc.dev/significant-gravitas/apis/autogpt-agent-server.md) · [All operations](https://skmtc.dev/significant-gravitas/apis/autogpt-agent-server/llms.txt) · [OpenAPI document](https://skmtc.dev/significant-gravitas/apis/autogpt-agent-server/revisions/5f27fa9d6c03?raw)
