Skip to content

Visual Studio Code cannot authorize with FastMCP OAuth #1379

@automaton82

Description

@automaton82

Initial Checks

Description

I reported this against FastMCP but the bug is actually in this lib, see PrefectHQ/fastmcp#1868

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": []
}

Python & MCP Python SDK

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

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions