-
Notifications
You must be signed in to change notification settings - Fork 22.1k
Description
🏷️ 问题类别
AI 分析相关(报错、内容异常、提示词失效等)
📝 描述发生了什么
您好,感谢开发这个实用的项目!
我在尝试使用 n8n 的 AI Agent 节点来调用 TrendRadar 的 MCP 服务。在使用 trigger_crawl 等工具时,出现了 Pydantic 校验错误,导致调用失败。
原因分析 n8n 的 AI Agent 框架在调用 MCP 工具时,会自动将当前的会话上下文(例如 sessionId, action, chatInput, toolCallId 等)强行注入到工具的参数列表中。
由于目前项目中的 FastMCP 工具定义(@mcp.tool 修饰的函数)比较严格,没有定义接收这些额外参数的字段,导致 Pydantic 抛出了 Unexpected keyword argument 异常。
项目能否在输入未知参数的时候,直接忽略这些参数,以提高兼容性。
谢谢。
📋 错误日志/配置(可选)
传入参数:
[
{
"sessionId":
"1bd19f08a0474d6aafc5df28e09b9c47",
"action":
"sendMessage",
"chatInput":
"触发一次抓取",
"platforms":
null,
"save_to_local":
false,
"include_url":
false,
"tool":
"trigger_crawl",
"toolCallId":
"call_00_FH363F1Zn57ATns8AMmhJ6bU"
}
]
输出log:
[
{
"response":
[
{
"type":
"text",
"text":
"Error calling tool 'trigger_crawl': 4 validation errors for call[trigger_crawl]\nsessionId\n Unexpected keyword argument [type=unexpected_keyword_argument, input_value='1bd19f08a0474d6aafc5df28e09b9c47', input_type=str]\n For further information visit https://errors.pydantic.dev/2.12/v/unexpected_keyword_argument\naction\n Unexpected keyword argument [type=unexpected_keyword_argument, input_value='sendMessage', input_type=str]\n For further information visit https://errors.pydantic.dev/2.12/v/unexpected_keyword_argument\nchatInput\n Unexpected keyword argument [type=unexpected_keyword_argument, input_value='触发一次抓取', input_type=str]\n For further information visit https://errors.pydantic.dev/2.12/v/unexpected_keyword_argument\ntoolCallId\n Unexpected keyword argument [type=unexpected_keyword_argument, input_value='call_00_FH363F1Zn57ATns8AMmhJ6bU', input_type=str]\n For further information visit https://errors.pydantic.dev/2.12/v/unexpected_keyword_argument"
}
]
}
]
🖥️ 使用环境
Docker (本地/NAS)