mirror of
https://github.com/PrefectHQ/fastmcp.git
synced 2026-08-24 06:24:18 +02:00
Add by_alias to wire-crossing model_dump calls
This commit is contained in:
parent
2ea012ead4
commit
1f319df0c3
5 changed files with 10 additions and 5 deletions
|
|
@ -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 []
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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
|
||||
]
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue