You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
from mcp.server.fastmcp import FastMCP, Context
mcp = FastMCP("My App")
@mcp.tool()
async def long_task(files: list[str], ctx: Context) -> str:
"""Process multiple files with progress tracking"""
for i, file in enumerate(files):
ctx.info(f"Processing {file}")
await ctx.report_progress(i, len(files))
data, mime_type = await ctx.read_resource(f"file://{file}")
return "Processing complete"
The above piece of server implementation use Context to write logs and report progress, but how the client get the contxet? and how the context help improve performance or user experience?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Pre-submission Checklist
Question Category
Your Question
I'm building a mcp desktop client. it confuses me that how MCP's concept
Context
help building the AI system.I saw an example in python-sdk repository https://github.com/modelcontextprotocol/python-sdk?tab=readme-ov-file#context that
The above piece of server implementation use Context to write logs and report progress, but how the client get the contxet? and how the context help improve performance or user experience?
Beta Was this translation helpful? Give feedback.
All reactions