diff --git a/fastmcp_slim/fastmcp/cli/apps_dev.py b/fastmcp_slim/fastmcp/cli/apps_dev.py index 2bfa5f1dc..49cbc771d 100644 --- a/fastmcp_slim/fastmcp/cli/apps_dev.py +++ b/fastmcp_slim/fastmcp/cli/apps_dev.py @@ -1221,7 +1221,7 @@ async def _list_tools(mcp_url: str) -> list[dict[str, Any]]: async with ClientSession(read, write) as session: await session.initialize() result = await session.list_tools() - return [t.model_dump() for t in result.tools] + return [t.model_dump(by_alias=True) for t in result.tools] except Exception as exc: logger.debug(f"Could not list tools from {mcp_url}: {exc}") return [] diff --git a/fastmcp_slim/fastmcp/server/event_store.py b/fastmcp_slim/fastmcp/server/event_store.py index fb3c526df..7b988d61b 100644 --- a/fastmcp_slim/fastmcp/server/event_store.py +++ b/fastmcp_slim/fastmcp/server/event_store.py @@ -161,7 +161,7 @@ class EventStore(SDKEventStore): entry = EventEntry( event_id=event_id, stream_id=stream_id, - message=message.model_dump(mode="json") if message else None, + message=message.model_dump(mode="json", by_alias=True) if message else None, ) await self._event_store.put(key=event_id, value=entry, ttl=self._ttl) diff --git a/fastmcp_slim/fastmcp/server/providers/proxy.py b/fastmcp_slim/fastmcp/server/providers/proxy.py index b757b6f2b..d4512f8ab 100644 --- a/fastmcp_slim/fastmcp/server/providers/proxy.py +++ b/fastmcp_slim/fastmcp/server/providers/proxy.py @@ -204,7 +204,9 @@ class ProxyTool(Tool): if task_metadata: meta = meta or {} meta["modelcontextprotocol.io/task"] = ( - task_metadata.model_dump(exclude_none=True) + task_metadata.model_dump( + by_alias=True, exclude_none=True + ) ) result = await client.call_tool_mcp( diff --git a/fastmcp_slim/fastmcp/server/transforms/prompts_as_tools.py b/fastmcp_slim/fastmcp/server/transforms/prompts_as_tools.py index 28efbc658..81c421bc3 100644 --- a/fastmcp_slim/fastmcp/server/transforms/prompts_as_tools.py +++ b/fastmcp_slim/fastmcp/server/transforms/prompts_as_tools.py @@ -157,7 +157,9 @@ def _format_prompt_result(result: Any) -> str: if isinstance(msg.content, TextContent): content = msg.content.text else: - content = msg.content.model_dump(mode="json", exclude_none=True) + content = msg.content.model_dump( + mode="json", by_alias=True, exclude_none=True + ) messages.append( { diff --git a/fastmcp_slim/fastmcp/server/transforms/search/base.py b/fastmcp_slim/fastmcp/server/transforms/search/base.py index 7368d62f5..cfeac6909 100644 --- a/fastmcp_slim/fastmcp/server/transforms/search/base.py +++ b/fastmcp_slim/fastmcp/server/transforms/search/base.py @@ -60,7 +60,8 @@ def _extract_searchable_text(tool: Tool) -> str: def serialize_tools_for_output_json(tools: Sequence[Tool]) -> list[dict[str, Any]]: """Serialize tools to the same dict format as ``list_tools`` output.""" return [ - tool.to_mcp_tool().model_dump(mode="json", exclude_none=True) for tool in tools + tool.to_mcp_tool().model_dump(mode="json", by_alias=True, exclude_none=True) + for tool in tools ]