Skip to content

Conversation

@Kludex
Copy link
Member

@Kludex Kludex commented Jan 21, 2026

No description provided.

@Kludex Kludex changed the title Add meta to Client methods Add meta to Client methods Jan 21, 2026
from mcp.server.fastmcp import FastMCP
from mcp.shared.session import ProgressFnT

logger = logging.getLogger(__name__)
Copy link
Member Author

Choose a reason for hiding this comment

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

Unnecessary logger.

Copy link
Member Author

Choose a reason for hiding this comment

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

Changes here are not breaking change.

Copy link
Member Author

Choose a reason for hiding this comment

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

Adding the meta parameter in the methods here is also not a breaking change, because they have a default value. Which means is just a feature.

"TaskExecutionMode",
"TaskStatus",
# Base classes
"MCPModel",
Copy link
Member Author

Choose a reason for hiding this comment

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

MCPModel should be internal. It's not supposed to be exposed.

A lot of types here aren't supposed to be exposed.

model_config = ConfigDict(extra="allow", alias_generator=to_camel, populate_by_name=True)


Meta: TypeAlias = dict[str, Any]
Copy link
Member Author

Choose a reason for hiding this comment

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

The Meta type was being used as dict[str, Any] or as class Meta(BaseModel) depending on the class, which doesn't make sense. I've set dict[str, Any] for all of them, which matches the spec and most of the types here.

@Kludex Kludex requested a review from maxisbey January 21, 2026 21:25
return await self.session.list_prompts(params=types.PaginatedRequestParams(cursor=cursor))
return await self.session.list_prompts(params=types.PaginatedRequestParams(cursor=cursor, _meta=meta))

async def get_prompt(self, name: str, arguments: dict[str, str] | None = None) -> types.GetPromptResult:
Copy link
Contributor

Choose a reason for hiding this comment

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

meta here?

if ctx.meta is not None and ctx.meta.model_extra: # pragma: no branch
received_meta[0] = ctx.meta.model_extra.get("custom_field")
if ctx.meta is not None: # pragma: no branch
received_meta[0] = ctx.meta.get("custom_field")
Copy link
Contributor

Choose a reason for hiding this comment

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

should we call out this change in the migration docs? If people are putting extra things in their meta tags I assume they'd need to do this now?

@Kludex Kludex requested a review from maxisbey January 22, 2026 12:06
async def handle_tool(name: str, arguments: dict) -> list[TextContent]:
ctx = server.request_context
if ctx.meta and "progress_token" in ctx.meta:
await ctx.session.send_progress_notification(ctx.meta["progress_token"], 0.5, 100)
Copy link
Contributor

Choose a reason for hiding this comment

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

feels weird that it's key access but makes sense given you can add anything to meta. just weird vibes.

@Kludex Kludex merged commit f0ab53e into main Jan 22, 2026
28 checks passed
@Kludex Kludex deleted the add-meta-to-client-methods branch January 22, 2026 13:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants