Skip to content

Conversation

@aiorga-sherpas
Copy link
Contributor

@aiorga-sherpas aiorga-sherpas commented Oct 22, 2025

Description

Minor changes to add the meta argument to the call_tool method.
modelcontextprotocol/python-sdk#1231 has been merged and will be in the next mcp release. With that and this minor changes we fix #1315

Review Checklist

  • My Pull Request is ready for review

@marvin-context-protocol marvin-context-protocol bot added enhancement Improvement to existing functionality. For issues and smaller PR improvements. client Related to the FastMCP client SDK or client-side functionality. DON'T MERGE PR is not ready for merging. Used by authors to prevent premature merging. labels Oct 22, 2025
@aiorga-sherpas aiorga-sherpas marked this pull request as ready for review October 27, 2025 10:15
@jlowin
Copy link
Owner

jlowin commented Oct 27, 2025

Thanks @aiorga-sherpas -- can you confirm whether this requires mcp>=1.19?

On the one hand I believe that the SDK generally ignores extra inputs in which case this does not require raising the pin to 1.19. On the other hand, users who provide this on mcp<1.19 may be surprised when it doesn't work.

I am comfortable raising the minimum in pyproject.toml as generally we won't always be able to support older versions as we stay on the cutting edge of functionality, though for non-breaking changes like this it is an option to raise an error if users pass meta when calling a tool and their MCP version is < 1.19

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 28, 2025

Walkthrough

Adds an optional meta: dict[str, Any] | None parameter to call_tool_mcp() and call_tool(), forwards it through the tool-call path (from call_toolcall_tool_mcpsession.call_tool), and updates docstrings; existing error/content handling remains unchanged.

Changes

Cohort / File(s) Summary
Client core
src/fastmcp/client/client.py
Add `meta: dict[str, Any]

Poem

🐰 I slipped a tiny _meta in my paw,
Whispered it down the call, soft and small,
From call to session it hops along,
A secret tucked inside the code’s song,
Little rabbit trails where data fall.

Pre-merge checks and finishing touches

✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: adding a meta parameter to the call_tool method.
Description check ✅ Passed The description covers the main change, references the linked issue and upstream SDK PR, but lacks details on testing and some contributor checklist items are incomplete.
Linked Issues check ✅ Passed The PR implements the core requirement from issue #1315: exposing meta parameter on call_tool and call_tool_mcp methods to forward metadata to MCP servers.
Out of Scope Changes check ✅ Passed All changes are scoped to adding the meta parameter to call_tool and call_tool_mcp methods as required; no unrelated modifications detected.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between dcec290 and 356e1f8.

⛔ Files ignored due to path filters (1)
  • tests/client/test_client.py is excluded by none and included by none
📒 Files selected for processing (1)
  • src/fastmcp/client/client.py (6 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/fastmcp/client/client.py (1)
src/fastmcp/server/proxy.py (1)
  • call_tool (107-120)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Run tests: Python 3.10 on windows-latest
🔇 Additional comments (1)
src/fastmcp/client/client.py (1)

919-992: LGTM: Parameter forwarding is correct.

The meta parameter is properly forwarded from call_tool to call_tool_mcp on line 958, and the docstring has been updated accordingly. Once the version compatibility issue in call_tool_mcp is addressed, this method will work correctly.


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

@aiorga-sherpas
Copy link
Contributor Author

aiorga-sherpas commented Oct 28, 2025

If meta argument is used with mcp<1.19 the following warning is printed: Warning: Could not call tool sum: ClientSession.call_tool() got an unexpected keyword argument 'meta' and the tool execution is skipped.
I could add an additional warning about having to update mcp>=1.19 and try to execute it without sending the meta.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ceeb00a and abc0286.

📒 Files selected for processing (1)
  • src/fastmcp/client/client.py (7 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
src/**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

Use Python ≥ 3.10 and provide full type annotations for library code

Files:

  • src/fastmcp/client/client.py
**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

Never use bare except; always catch specific exception types

Files:

  • src/fastmcp/client/client.py
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Run tests: Python 3.10 on windows-latest
  • GitHub Check: Run tests with lowest-direct dependencies
🔇 Additional comments (3)
src/fastmcp/client/client.py (3)

6-6: LGTM!

The inspect import is necessary for the runtime feature detection implemented below and is correctly positioned.


895-928: LGTM!

The meta parameter is correctly added to call_tool, properly documented, and correctly forwarded to call_tool_mcp. The type annotations follow the coding guidelines for Python ≥ 3.10.


861-885: Signature inspection approach verified and working correctly.

The inspect.signature runtime detection successfully identifies whether meta is supported by the installed MCP version (tested with MCP 1.16.0, which lacks the parameter). The code correctly prevents TypeErrors by conditionally passing meta only when supported, and appropriately warns users when they attempt to use it with older MCP versions.

Optional refinements for consideration:

  1. Session lifecycle: If you add caching for the signature check (as suggested earlier), reset the cache when a new session is established—this ensures the check adapts if the session object changes.

  2. Documentation: Add a note to the method docstring indicating that the meta parameter requires MCP ≥ 1.19 and will be silently omitted on older versions.

Copy link
Owner

@jlowin jlowin left a comment

Choose a reason for hiding this comment

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

@aiorga-sherpas following #2283, MCP 1.19 is now the minimum version for FastMCP, so I think a lot of the version checking machinery can be removed. Do you mind simplifying the feature work here to strip it out, and adding a test to confirm the meta is received on the server?

@aiorga-sherpas aiorga-sherpas requested a review from jlowin November 4, 2025 12:01
Copy link
Owner

@jlowin jlowin left a comment

Choose a reason for hiding this comment

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

Thank you!

@jlowin jlowin merged commit 7e6610b into jlowin:main Nov 4, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

client Related to the FastMCP client SDK or client-side functionality. DON'T MERGE PR is not ready for merging. Used by authors to prevent premature merging. enhancement Improvement to existing functionality. For issues and smaller PR improvements.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow clients to send _meta to server

2 participants