Skip to content

Conversation

@CNSeniorious000
Copy link

@CNSeniorious000 CNSeniorious000 commented Nov 28, 2025

Description

Code:

from anyio import run

from fastmcp import FastMCP

mcp = FastMCP()

print("\033c", end="", flush=True)  # Clear console


@mcp.tool(name="name", title="title")
def _(): ...


@mcp.resource(uri="foo://bar", title="baz")
def _(): ...


@mcp.prompt(name="prompt_name", title="prompt_title")
def _(): ...


@run
async def _():
    proxy = FastMCP.as_proxy(mcp)

    print(await mcp.get_tools())
    print(await proxy.get_tools())

    print(await mcp.get_prompts())
    print(await proxy.get_prompts())

    print(await mcp.get_resource("foo://bar"))
    print(await proxy.get_resource("foo://bar"))

Before this PR:

{'name': FunctionTool(name='name', title='title', description=None, tags=set(), enabled=True)}
{'name': ProxyTool(name='name', title=None, description=None, tags=set(), enabled=True)}
{'prompt_name': FunctionPrompt(name='prompt_name', title='prompt_title', description=None, tags=set(), enabled=True)}
{'prompt_name': ProxyPrompt(name='prompt_name', title=None, description=None, tags=set(), enabled=True)}
name='_' title='baz' description=None icons=None tags=set() meta=None enabled=True uri=AnyUrl('foo://bar') mime_type='text/plain' annotations=None fn=<function _ at 0x0000016AF4E24D60>
name='_' title=None description=None icons=None tags=set() meta={'_fastmcp': {'tags': []}} enabled=True uri=AnyUrl('foo://bar') mime_type='text/plain' annotations=None

After this PR:

{'name': FunctionTool(name='name', title='title', description=None, tags=set(), enabled=True)}
{'name': ProxyTool(name='name', title='title', description=None, tags=set(), enabled=True)}
{'prompt_name': FunctionPrompt(name='prompt_name', title='prompt_title', description=None, tags=set(), enabled=True)}
{'prompt_name': ProxyPrompt(name='prompt_name', title='prompt_title', description=None, tags=set(), enabled=True)}
name='_' title='baz' description=None icons=None tags=set() meta=None enabled=True uri=AnyUrl('foo://bar') mime_type='text/plain' annotations=None fn=<function _ at 0x000002D67210BE20>
name='_' title='baz' description=None icons=None tags=set() meta={'_fastmcp': {'tags': []}} enabled=True uri=AnyUrl('foo://bar') mime_type='text/plain' annotations=None

Contributors Checklist

  • My change closes FastMCP.as_proxy loses tool title #2496
  • I have followed the repository's development workflow
  • I have tested my changes manually and by adding relevant tests
  • I have performed all required documentation updates

Review Checklist

  • I have self-reviewed my changes
  • My Pull Request is ready for review

@marvin-context-protocol marvin-context-protocol bot added bug Something isn't working. Reports of errors, unexpected behavior, or broken functionality. server Related to FastMCP server implementation or server-side functionality. labels Nov 28, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 28, 2025

Walkthrough

The changes update the proxy module to propagate the title field from source MCP objects to their corresponding proxy instances. Factory methods for creating proxy tools, resources, resource templates, and prompts now initialize the title field by extracting it from the originating MCP-derived entities. This ensures title metadata is preserved through the proxy creation process.

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The PR title clearly and specifically describes the main change: adding a title attribute to proxy classes (ProxyTool, ProxyResource, etc.).
Linked Issues check ✅ Passed The PR changes propagate the title field across proxy constructors (from_mcp_tool, from_mcp_resource, from_mcp_template, from_mcp_prompt), directly addressing issue #2496's requirement to preserve tool titles in as_proxy().
Out of Scope Changes check ✅ Passed All changes are focused on title field propagation in proxy constructors within src/fastmcp/server/proxy.py, remaining within the scope of issue #2496.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description check ✅ Passed The pull request includes a clear description with issue reference, code examples demonstrating the problem and solution, and all required checklist items are addressed.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FastMCP.as_proxy loses tool title

1 participant