Skip to content

fix(git): handle input without crashing - #4214

Closed
KonecSvetta wants to merge 1 commit into
modelcontextprotocol:mainfrom
KonecSvetta:fix/git-raise-exceptions
Closed

KonecSvetta wants to merge 1 commit into
modelcontextprotocol:mainfrom
KonecSvetta:fix/git-raise-exceptions

Conversation

@KonecSvetta

Copy link
Copy Markdown

Description

This PR changes mcp-server-git to run the stdio server with raise_exceptions=False instead of raise_exceptions=True.

With raise_exceptions=True, JSON-RPC input can cause exceptions from stdin parsing to propagate into the server task group and terminate the process. With the default behavior, the server reports the error back to the client as a JSON-RPC error and keeps running.

Fixes #4213.

Publishing Your Server

N/A — this PR modifies an existing reference server and does not add a new server.

Server Details

  • Server: git
  • Changes to: stdio error handling

Motivation and Context

mcp-server-git currently differs from reference servers such as mcp-server-time and mcp-server-sqlite, which use the default raise_exceptions=False behavior.

A similar issue was previously fixed for mcp-server-fetch in PR #3515. This PR applies the same kind of follow-up cleanup to mcp-server-git.

The change prevents malformed or unparseable JSON-RPC input from terminating the server process.

How Has This Been Tested?

Tested with the reproducer from #4213:

  • before the change, a deeply nested JSON-RPC request caused mcp-server-git to exit with code 1 and print a ValidationError: recursion limit exceeded;
  • after the change, the server no longer terminates on that input and reports the malformed input as a JSON-RPC error.

Also verified that normal initialization and tool calls still work.

Breaking Changes

None. This is a non-breaking robustness fix.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Protocol Documentation
  • My changes follows MCP security best practices
  • I have updated the server's README accordingly
  • I have tested this with an LLM client
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have documented all environment variables and configuration options

Additional context

This is a one-line change:

-        await server.run(read_stream, write_stream, options, raise_exceptions=True)
+        await server.run(read_stream, write_stream, options, raise_exceptions=False)

@LuuOW LuuOW left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technical audit: Verified MCP server implementation for consistency with current SDK patterns.

@cliffhall cliffhall added the closed-superseded-v2 Closed: fixed or made obsolete by the v2 / 2026-07-28 refactor (#4875) label Oct 20, 2026
@cliffhall

Copy link
Copy Markdown
Member

Thank you for this pull request, and apologies for the long wait for a response.

Since it was opened, the reference servers have been rebuilt for the 2026-07-28 MCP specification (#4857) and released as v2 (2.0.0 on npm for the TypeScript servers, 2026.10.19 on PyPI for the Python servers). The code this PR changes has been replaced, and the behavior it addresses has either been fixed in v2 or no longer exists in the same form.

This is not a judgment on the change or on you; it's a consequence of the code it targets having been replaced. If the problem still happens on v2, please open a fresh issue with the version you're running and steps to reproduce. Note that this repository now accepts contributions as issues rather than pull requests from anyone but its maintainers; see CONTRIBUTING.md.

This is part of the backlog triage in #4875.

@cliffhall cliffhall closed this Oct 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

closed-superseded-v2 Closed: fixed or made obsolete by the v2 / 2026-07-28 refactor (#4875)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[git] raise_exceptions=True

3 participants