fix(mcp): exclude null fields from Dynamic Client Registration payload

`OAuthClientMetadata.model_dump()` serializes optional `None` fields
(e.g. `scope`, `client_uri`) as JSON `null`. Some MCP servers that
perform strict validation on the registration payload (e.g. GitLab MCP)
reject the request with 400 Bad Request:

  {"error":"invalid_client_metadata","error_description":"expected string, received null"}

Using `model_dump(exclude_none=True)` omits unset optional fields from
the JSON body, which conforms to RFC 7591 (OAuth 2.0 Dynamic Client
Registration) where absent fields should use server defaults.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Aymeric GEFFROY 2026-04-09 16:20:31 +02:00
parent 41eeb1f2e7
commit 2114894118

View File

@ -527,7 +527,7 @@ def register_client(
response = ssrf_proxy.post(
registration_url,
json=client_metadata.model_dump(),
json=client_metadata.model_dump(exclude_none=True),
headers={"Content-Type": "application/json"},
)
if not response.is_success: