Skip to content

Visual Studio Code cannot authorize with FastMCP OAuth #1868

@automaton82

Description

@automaton82

Description

If you attempt to add a MCP server that supports OAuth to VSC in mcp.json with dynamic client registration, you will catch the following error inside register.py class RegistrationHandler method handle:

validation_error = 1 validation error for OAuthClientMetadata
                   grant_types.2
                     Input should be 'authorization_code' or 'refresh_token' [type=literal_error,
input_value='urn:ietf:params:oauth:grant-type:device_code',
input_type=str]
                For further information visit https://errors.pydantic.dev/2.11/v/literal_error

This was the body payload from VSC:

body = {'client_name': 'Visual Studio Code', 'client_uri': 'https://code.visualstudio.com', 'grant_types': ['authorization_code', 'refresh_token', 'urn:ietf:params:oauth:grant-type:device_code'], 'response_types': ['code'], 'redirect_uris': ['https://insiders.vscode.dev/redirect', 'https://vscode.dev/redirect', 'http://localhost/', 'http://127.0.0.1/', 'http://localhost:33418/', 'http://127.0.0.1:33418/'], 'scope': 'read:data', 'token_endpoint_auth_method': 'none', 'application_type': 'native'}

Example Code

Example `.vscode/mcp.json` file:


{
	"servers": {
		"my-mcp-server-7574582c": {
			"url": "http://localhost:5173/mcp",
			"type": "http"
		}
	},
	"inputs": []
}

Version Information

FastMCP version:                                                           2.12.2
MCP version:                                                               1.13.1
Python version:                                                           3.11.13
Platform:          Linux-5.15.167.4-microsoft-standard-WSL2-x86_64-with-glibc2.36
FastMCP root path:             /workspaces/app/.venv/lib/python3.11/site-packages

Metadata

Metadata

Assignees

No one assigned

    Labels

    authRelated to authentication (Bearer, JWT, OAuth, WorkOS) for client or server.bugSomething isn't working. Reports of errors, unexpected behavior, or broken functionality.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions