fastmcp
fastmcp copied to clipboard
Lack of clarity in progress reporting in FastMCP Python Client
Description
Issue
The documentation around ctx.report_progress in FastMCP is unclear, for using it in FastMCP Python client.
- The docs show how to use ctx.report_progress on the server, but it’s not clear how a Python client is supposed to receive those updates.
- The standard Python client does not send a progressToken in tool/resource requests, so even if the server calls report_progress, the client never receives progress notifications.
- There is no documented or supported way to pass a progressToken or request metadata from the Python client, and attempts to use lower-level APIs (e.g., client.session.call_tool(..., _meta={...})) result in errors.
Expected Behaviour
- Clear guidance in the docs about when and how report_progress actually works (i.e., only if the client sends a progressToken)
- Some way for Python devs to opt in to progress reporting—maybe an optional argument
- And if this isn’t officially supported (yet?), it would help to explicitly say so and explain what the recommended pattern is.
To reproduce
* Build a server tool that calls ctx.report_progress.
* Trigger it from the Python client.
possible solutions
- exporse the progress_token argument in Client.call_tool
- Add a “progress_callback” argument to call_tool that handles updates, progress tokens to a user-defined function
Example Code
Version Information
fastmcp==2.2.6
mcp==1.6.0
python==3.12.8
Additional Context
No response
Hi @sandipan1 , Did you find a workaround for this issue?
I also tried using the low-level API as you mention
There is no documented or supported way to pass a progressToken or request metadata from the Python client, and attempts to use lower-level APIs (e.g., client.session.call_tool(..., _meta={...})) result in error
@jlowin Could you please take a look at this?
A workaround is use ctx.info to send your message and parse it using log_handler in client
How can we pass context logging back to the client? I’ve tried using both stdio and SSE, but the logs are not appearing in the client console.
For example, this tool includes context logging, but it's not visible on the client side.
# math_server.py
from fastmcp import FastMCP, Context
mcp = FastMCP("math", log_level="DEBUG")
@mcp.tool()
async def add(a: int, b: int, ctx: Context = None) -> int:
"""Add two numbers"""
if ctx:
await ctx.info(f"Adding {a} and {b}")
result = a + b
await ctx.info(f"Result: {result}")
return result
return a + b
@mcp.tool()
async def multiply(a: int, b: int, ctx: Context = None) -> int:
"""Multiply two numbers"""
if ctx:
await ctx.info(f"Multiplying {a} and {b}")
result = a * b
await ctx.info(f"Result: {result}")
return result
return a * b
if __name__ == "__main__":
# mcp.run(transport="stdio")
mcp.run(transport='sse', host="127.0.0.1", port=8004)
@kjoth have you provided a log handler as described here? https://gofastmcp.com/clients/client#logging
If something is broken please open a separate issue, this one is closed by #513
@kjoth have you provided a log handler as described here? https://gofastmcp.com/clients/client#logging
If something is broken please open a separate issue, this one is closed by #513
@jlowin I’m currently using LangChain’s MultiServerMCPClient (from langchain_mcp_adapters.client) to connect to multiple MCP servers. I haven’t tried the FastMCP client yet—does FastMCP allow connections to several MCP servers as well?
https://github.com/langchain-ai/langchain-mcp-adapters#client-1