modelcontextprotocol/servers · error · ValueError

Unknown tool: {name}

Error message

Unknown tool: {name}

What it means

The git server's call_tool dispatch (server.py:487-598) matches on the tool name; the case _ at line 597-598 raises ValueError('Unknown tool: {name}') for anything not in the GitTools enum. The server runs with raise_exceptions=True (line 602), so this propagates to the MCP client.

Source

Thrown at src/git/src/mcp_server_git/server.py:598

                return [TextContent(
                    type="text",
                    text=result
                )]

            case GitTools.BRANCH:
                result = git_branch(
                    repo,
                    arguments.get("branch_type", 'local'),
                    arguments.get("contains", None),
                    arguments.get("not_contains", None),
                )
                return [TextContent(
                    type="text",
                    text=result
                )]

            case _:
                raise ValueError(f"Unknown tool: {name}")

    options = server.create_initialization_options()
    async with stdio_server() as (read_stream, write_stream):
        await server.run(read_stream, write_stream, options, raise_exceptions=True)

View on GitHub (pinned to 76d64c822f)

Solutions

  1. Call list_tools at runtime and use only names it actually advertises.
  2. Upgrade or downgrade client and server to matching versions.
  3. Fix the typo in the tool name against the advertised list.
  4. Confirm the request is routed to the git server, not a different MCP server.

Example fix

// before
//   session.call_tool("git_log", ...)   -> Unknown tool
// after
//   name in {t.name for t in (await session.list_tools()).tools}  # use a real one
Defensive patterns

Strategy: validation

Validate before calling

known = {t.name for t in (await session.list_tools()).tools}
if name not in known:
    raise ValueError(f"{name!r} not offered by git server; choose from {sorted(known)}")
await session.call_tool(name, arguments)

Type guard

async def is_known_tool(session, name: str) -> bool:
    return name in {t.name for t in (await session.list_tools()).tools}

Try / catch

try:
    await session.call_tool(name, arguments)
except Exception as e:
    if "Unknown tool" in str(e):
        # refresh advertised tools and retry with a corrected name
        ...
    raise

Prevention

When it happens

Trigger: Client invokes a tool name the running server version does not register: a typo, a name from a newer/older release, or a tool that belongs to a different server. For example calling 'git_log' or 'log' when the server advertises neither.

Common situations: Version skew between a hardcoded client config and the installed mcp-server-git. Client copied a tool name from outdated docs. Duplicate/misrouted dispatch across multiple MCP servers.

Related errors


AI-assisted analysis of modelcontextprotocol/servers@76d64c822f (2026-08-12). Data as JSON: /api/errors/d41e85b30c028563. Report an issue: GitHub.