You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Two defects in that flow make it fail for some servers.
1. Fallback metadata has no registration endpoint
What happens
When the server does not publish /.well-known/oauth-authorization-server, get_oauth_server_metadata builds default metadata as described by the MCP spec. The registration URL is passed as register_endpoint, but authlib's AuthorizationServerMetadata (RFC 8414) names it registration_endpoint. metadata.registration_endpoint is therefore None, and build_oauth_params without a client_id/client_secret calls async_client.post(None, ...):
TypeError: Invalid type for url. Expected str or httpx2.URL, got <class 'NoneType'>: None
What should happen
Dynamic client registration should be attempted at {server_url}/register, as the MCP 2025-03-26 fallback rules say.
Confirmed both defects on current main (d3da3bd). PR creation on this repo is limited to collaborators, so the fix is on a fork branch you can pull or cherry-pick:
rstrip("/") keeps the old behaviour of dropping a trailing slash, so {base_url}/register and {base_url}/.well-known/... never get a double slash, and .../sse/ still maps to the server root.
Tests, in a new src/mistralai/extra/tests/test_mcp_oauth_discovery.py:
build_oauth_params without client_id/client_secret POSTs the registration to https://mcp.example/register (httpx MockTransport) and returns the registered credentials
base_url for /sse, /sse/, .services/sse, /messages/sse, /mcp/events, /mcp/
Results:
New tests on unpatched main: 3 tests, 6 failures + 1 error (TypeError: Invalid type for url ... got <class 'NoneType'>). With the fix: all pass.
python -m unittest discover -s src/mistralai/extra/tests -t src: 187 tests OK (184 on main, plus the 3 new ones).
pytest tests/: 358 passed, 46 skipped.
ruff check, mypy and pyright on src/mistralai/extra/: clean.
This was investigated and written with an AI coding agent (Claude) working on my behalf.
Activity
devteamaegis commentedon Nov 10, 2026
Confirmed both defects on current
main(d3da3bd). PR creation on this repo is limited to collaborators, so the fix is on a fork branch you can pull or cherry-pick:main: main...devteamaegis:client-python:fix/mcp-oauth-fallback-discoveryIt touches only hand-maintained files under
src/mistralai/extra/(listed in.genignore):rstrip("/")keeps the old behaviour of dropping a trailing slash, so{base_url}/registerand{base_url}/.well-known/...never get a double slash, and.../sse/still maps to the server root.Tests, in a new
src/mistralai/extra/tests/test_mcp_oauth_discovery.py:registration_endpoint == "https://mcp.example/register"build_oauth_paramswithoutclient_id/client_secretPOSTs the registration tohttps://mcp.example/register(httpxMockTransport) and returns the registered credentialsbase_urlfor/sse,/sse/,.services/sse,/messages/sse,/mcp/events,/mcp/Results:
main: 3 tests, 6 failures + 1 error (TypeError: Invalid type for url ... got <class 'NoneType'>). With the fix: all pass.python -m unittest discover -s src/mistralai/extra/tests -t src: 187 tests OK (184 onmain, plus the 3 new ones).pytest tests/: 358 passed, 46 skipped.ruff check,mypyandpyrightonsrc/mistralai/extra/: clean.This was investigated and written with an AI coding agent (Claude) working on my behalf.