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
{{ message }}
Repository navigation
git: the string "null" for base_branch, contains or not_contains arrives as None (python-sdk#3055) #5176
blockedCannot proceed until something outside this issue changesbugSomething isn't workingserver-gitReference implementation for the Git MCP server - src/gitv2waiting-on-sdk
Since #5174 (#5175), the git server is built on MCPServer. Before validating arguments, the SDK's FuncMetadata.pre_parse_json JSON-decodes every string argument whose annotation is not exactly str. For the git server's three str | None parameters, that turns the literal string "null" into None:
Tool
Parameter
Effect of "null"
git_create_branch
base_branch
Branches from the current branch, not from a branch named null
git_branch
contains
The filter is silently dropped
git_branch
not_contains
The filter is silently dropped
All three advertise anyOf: [string, null], so "null" is a valid string value. Before #5175, the server received it unchanged.
Upstream: modelcontextprotocol/python-sdk#3055 (open), with the fix in python-sdk#3056. A comment there already reproduces this "null" → None case.
Done when
The SDK release that fixes python-sdk#3055 is locked in src/git, with a protocol test for each parameter showing that "null" reaches the tool as the string "null". Before then, a workaround in the server (declaring the parameters as str with a custom validator and a hand-written schema) is not wanted: these servers are meant to show the plain high-level API. Found in the Copilot review of #5175.
Unchanged: the plan in the issue body. Once an SDK release with the fix ships, lock it in src/git/uv.lock and add one protocol test per parameter (base_branch, contains, not_contains) showing that "null" reaches the tool as a string. No server-side workaround.
Taken off the v2.3.0 tracker: this was removed from Tracker: Git v2.3.0 #5270's sub-issues, since everything else in that tracker shipped in v2.3.0.
Protocol & Gateway Analysis: Union-Aware String Preservation for Nullable Schemas
We encountered and analyzed this exact literal "null" → None / null coercion behavior across multi-tier MCP architectures (gateways, TypeScript bridges, and tool proxies interfacing with src/git and database MCP servers).
Root Cause & Schema Combinator Mechanics
When an MCP tool declares an optional/nullable string:
When an intermediate proxy, transport normalizer, or pre-parser inspects parameter annotations, naive checks like field.annotation is not str (Python) or schema.type !== 'string' (TypeScript) evaluate to true because schema.type is either an array or undefined under anyOf.
Running JSON.parse(val) on the string "null" evaluates to primitive null / None, which silently drops the parameter:
git_create_branch: base_branch: "null" branches from current HEAD instead of creating from branch "null".
git_branch: contains: "null" silently drops the filter.
JSON-in-string payloads: templates like '{"blocks": [...]}' get deserialized into objects, subsequently failing downstream string validator constraints.
Normalization Logic
For any proxy, bridge, or server handling tool arguments, argument pre-parsing should adhere to union-aware schema traversal:
schemaAcceptsString(schema): Recursively walk anyOf, oneOf, allOf, and type arrays. If string is a permitted variant, never pre-parse incoming string values:
Strict Collection Check (schemaRequiresCollection): Only attempt JSON deserialization when the schema exclusively expects structured containers (array or object) with no string variant.
Disclosure: I maintain MCP Production Kit, an open-source hardening suite for MCP servers. We implemented and verified this union-aware argument normalization pattern in our test suite (Module 27) covering nullable string preservation, JSON-in-string preservation, and subprocess diagnostics.
blockedCannot proceed until something outside this issue changesbugSomething isn't workingserver-gitReference implementation for the Git MCP server - src/gitv2waiting-on-sdk
Activity
cliffhall commentedon Oct 29, 2026
Moved from v2.3.0 to v2.4.0. This is still blocked on the SDK, and stays labeled
waiting-on-sdk.mcpv2.3.0, which is the versionsrc/gitlocks.src/git/uv.lockand add one protocol test per parameter (base_branch,contains,not_contains) showing that"null"reaches the tool as a string. No server-side workaround.4 remaining items
A7mdMe commentedon Nov 20, 2026
Protocol & Gateway Analysis: Union-Aware String Preservation for Nullable Schemas
We encountered and analyzed this exact
literal "null"→None/nullcoercion behavior across multi-tier MCP architectures (gateways, TypeScript bridges, and tool proxies interfacing withsrc/gitand database MCP servers).Root Cause & Schema Combinator Mechanics
When an MCP tool declares an optional/nullable string:
anyOf: [{ type: "string" }, { type: "null" }](ortype: ["string", "null"]).field.annotation is not str(Python) orschema.type !== 'string'(TypeScript) evaluate totruebecauseschema.typeis either an array or undefined underanyOf.JSON.parse(val)on the string"null"evaluates to primitivenull/None, which silently drops the parameter:git_create_branch:base_branch: "null"branches from currentHEADinstead of creating from branch"null".git_branch:contains: "null"silently drops the filter.'{"blocks": [...]}'get deserialized into objects, subsequently failing downstream string validator constraints.Normalization Logic
For any proxy, bridge, or server handling tool arguments, argument pre-parsing should adhere to union-aware schema traversal:
schemaAcceptsString(schema): Recursively walkanyOf,oneOf,allOf, andtypearrays. Ifstringis a permitted variant, never pre-parse incoming string values:schemaRequiresCollection): Only attempt JSON deserialization when the schema exclusively expects structured containers (arrayorobject) with no string variant.interface-diffdiscards the git error when resolving its default base and reports the wrong cause #5636): Ensure that when git subprocesses fail downstream (e.g.Needed a single revision), errors retain the original cause (err.cause), exit code, and stderr tail rather than masking the root failure.Disclosure: I maintain MCP Production Kit, an open-source hardening suite for MCP servers. We implemented and verified this union-aware argument normalization pattern in our test suite (Module 27) covering nullable string preservation, JSON-in-string preservation, and subprocess diagnostics.