-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Input should be a valid string [type=string_type, input_value=123, input_type=int] #316
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Can you please format your code, and try to translate to English? 🙏 |
|
This is the same as this issue from the original FastMCP repo: It was fixed in FastMCP Dec 5th 2024: But it looks like in merging FastMCP into the official Python SDK this fix was lost. |
@w0807c This issue is not fixed in this repository. I recommend reopening the issue, if possible. |
@Kludex are you able to reopen this? ive been able to replicate this bug as well with 1.5.0 the offending line is here:
@daviddoran-stripe correctly pointed out the fix was not migrated to the mcp sdk. |
Same issue here~ |
+1 |
I opened a PR
I opened a PR with the fix you pointed out. Hopefully it will be merged soon. Sonnet 3.7 is clever enough to escape the strings, but other models fail miserably with this bug. |
fixed |
MCP Server tools code:
`@mcp.tool(description="查询物流信息")
async def query_logistics(order_id: str) -> str:
"""查询物流信息。当用户需要根据订单号查询物流信息时,调用此工具
Args:
order_id: 订单号
Returns:
物流信息的字符串描述
"""
统一的物流信息数据
tracking_info = [
{"time": "2024-01-20 10:00:00", "status": "包裹已揽收",
"location": "深圳转运中心"},
{"time": "2024-01-20 15:30:00", "status": "运输中", "location": "深圳市"},
{"time": "2024-01-21 09:00:00", "status": "到达目的地",
"location": "北京市"},
{"time": "2024-01-21 14:00:00", "status": "派送中",
"location": "北京市朝阳区"},
{"time": "2024-01-21 16:30:00", "status": "已签收",
"location": "北京市朝阳区三里屯"}
]
格式化物流信息
result = f"物流单号:{order_id}\n\n物流轨迹:\n"
for item in tracking_info:
result += f"[{item['time']}] {item['status']} - {item['location']}\n"
return result
MCP client execute code:
self._streams_context = sse_client(url=server_url)streams = await self._streams_context.aenter()
error info:
Connected to server with tools: ['query_logistics']
Result of add tool: meta=None content=[TextContent(type='text', text='Error executing tool query_logistics: 1 validation error for query_logisticsArguments\norder_id\n Input should be a valid string [type=string_type, input_value=123, input_type=int]\n For further information visit https://errors.pydantic.dev/2.10/v/string_type', annotations=None)] isError=True
The text was updated successfully, but these errors were encountered: