Skip to content

Expose experimental_capabilities on FastMCP for cross-server interop conventions #4040

@ZLeventer

Description

@ZLeventer

Problem

FastMCP has no public API to set experimental server capabilities, even though the underlying LowLevelServer.create_initialization_options supports them. The transport layer (run_stdio_async, run_http_async) calls create_initialization_options() without passing experimental capabilities through, so there's no way for application code to advertise experimental capabilities during the initialize handshake.

Follows up on #4039 (condensed per contributing guidelines).

MRE

from fastmcp import FastMCP

mcp = FastMCP("my-server")

# No public API for this — only workaround is monkey-patching a private attribute:
_original = mcp._mcp_server.create_initialization_options

def _patched(notification_options=None, experimental_capabilities=None, **kwargs):
    merged = {"file_exchange": {"version": "0.3"}, **(experimental_capabilities or {})}
    return _original(
        notification_options=notification_options,
        experimental_capabilities=merged,
        **kwargs,
    )

mcp._mcp_server.create_initialization_options = _patched

Proposed fix

Add an experimental_capabilities kwarg to FastMCP.__init__ and forward it through create_initialization_options() in the transport layer. Happy to PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementImprovement to existing functionality. For issues and smaller PR improvements.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