Skip to content

Commit 916cdc9

Browse files
cliffhallclaude
andcommitted
feat(git): build the git server on MCPServer; unknown tool is -32602
The git server moves from the SDK's low-level Server, with its SDK v1 compatibility wrapper (hand-rolled jsonschema validation, every exception folded into an isError result), to the high-level MCPServer (modelcontextprotocol#5174). Each tool is a typed function registered with @server.tool; its name, description, arguments, defaults, descriptions and annotations are unchanged. Only each input schema's top-level title differs, now derived from the function name. - An unknown tool is a JSON-RPC -32602 protocol error in both eras, as the spec requires. MCPServer still answers one with isError (python-sdk#3659), so a middleware rejects it before the lookup, which also keeps modelcontextprotocol#4994's rule that the name is checked before repo_path. - Anticipated failures (the guards, GitError, gitdb's ODBError, and the builtins GitPython raises for failed lookups) are raised as ToolError, so the model still reads their message, now prefixed by MCPServer with "Error executing tool <name>: ". Anything else is a crash, reported generically. - subscriptions=False: the tool list never changes, so the 2026-07-28 capabilities advertise no listChanged. MCPServer always serves empty prompt and resource lists, so those capabilities now appear. - Argument validation errors are pydantic's, from MCPServer. - jsonschema is no longer a direct dependency. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Signed-off-by: cliffhall <[email protected]>
1 parent 50c6823 commit 916cdc9

10 files changed

Lines changed: 511 additions & 486 deletions

File tree

‎src/git/README.md‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ A Model Context Protocol server for Git repository interaction and automation. T
88

99
Source: https://github.com/modelcontextprotocol/servers/tree/main/src/git
1010

11-
Requires MCP Python SDK 2.x (`mcp>=2.2,<3`).
11+
Requires MCP Python SDK 2.x (`mcp>=2.2,<3`). The server is built on the SDK's high-level `MCPServer`: each tool is a typed Python function, and the SDK derives its input schema from the signature.
1212

1313
Please note that mcp-server-git is currently in early development. The functionality and available tools are subject to change and expansion as we continue to develop and improve the server.
1414

@@ -106,6 +106,11 @@ The server speaks both eras of the Model Context Protocol over stdio, with nothi
106106

107107
Roots is deprecated in 2026-07-28, and this server never asks a client for Roots in either era: repository access comes from `--repository` alone, or, with no `--repository`, from each tool call's `repo_path`. Methods the 2026-07-28 specification removes, such as `ping`, are answered only on a 2025-11-25 connection.
108108

109+
### Errors
110+
111+
- **A tool that fails** returns a result with `isError: true` whose text is `Error executing tool <name>: <message>`, so the model can read it and correct the call. This covers git errors (an unknown revision, a failed command), a `repo_path` that is not a repository or is outside `--repository`, the flag-injection guards, and arguments that do not match the tool's input schema.
112+
- **An unknown tool name** is a protocol error, JSON-RPC `-32602` (`Unknown tool: <name>`), as the specification requires in both eras. Before 2.0.0 it was an `isError` result.
113+
109114
## Installation
110115

111116
### Using uv (recommended)

‎src/git/pyproject.toml‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ classifiers = [
1818
dependencies = [
1919
"click>=8.1.7",
2020
"gitpython>=3.1.60",
21-
"jsonschema>=4.20.0",
2221
"mcp>=2.2,<3",
2322
"pydantic>=2.0.0",
2423
]

0 commit comments

Comments
 (0)