Skip to content

Server accepts self-mount without error #3920

@strawgate

Description

@strawgate

`mcp.mount(mcp)` is accepted silently, causing infinite recursion when listing tools.

from fastmcp import FastMCP

mcp = FastMCP("test")
mcp.mount(mcp)  # no error

tools = await mcp.list_tools()  # infinite recursion

The `mount()` method has no guard against mounting a server onto itself. A simple identity check would catch this at mount time instead of producing confusing errors later.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working. Reports of errors, unexpected behavior, or broken functionality.serverRelated to FastMCP server implementation or server-side functionality.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions