Skip to content

[Bug]mcp工具的 name 包含了"."导致报错 #9533

Description

@fuchaohan

What happened / 发生了什么

mcp添加工具的的 name 包含了"."导致报错

Reproduce / 如何复现?

添加并使用腾讯文档mcp,然后聊天就会出现

Image

AstrBot version, deployment method (e.g., Windows Docker Desktop deployment), provider used, and messaging platform used. / AstrBot 版本、部署方式(如 Windows Docker Desktop 部署)、使用的提供商、使用的消息平台适配器

4.27.1 docker deepseek

OS

Linux

Logs / 报错日志

[2026-08-04 00:43:43.769] [Core] [WARN] [v4.27.1] [runners.tool_loop_agent_runner:561]: Chat Model deepseek-responses/deepseek-v4-flash request error: Error code: 400 - {'error': {'message': "Invalid 'tools[428].name': string does not match pattern. Expected a string that matches the pattern '^[a-zA-Z0-9_-]+$'.", 'type': 'invalid_request_error', 'param': None, 'code': 'invalid_request_error'}} Traceback (most recent call last): File "/AstrBot/astrbot/core/agent/runners/tool_loop_agent_runner.py", line 515, in _iter_llm_responses_with_fallback async for attempt in retrying: File "/usr/local/lib/python3.12/site-packages/tenacity/asyncio/init.py", line 170, in anext do = await self.iter(retry_state=self._retry_state) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/tenacity/asyncio/init.py", line 157, in iter result = await action(retry_state) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/tenacity/_utils.py", line 111, in inner return call(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/tenacity/init.py", line 393, in self._add_action_func(lambda rs: rs.outcome.result()) ^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/concurrent/futures/_base.py", line 449, in result return self.__get_result() ^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/concurrent/futures/_base.py", line 401, in __get_result raise self._exception File "/AstrBot/astrbot/core/agent/runners/tool_loop_agent_runner.py", line 519, in _iter_llm_responses_with_fallback async for resp in self._iter_llm_responses( File "/AstrBot/astrbot/core/agent/runners/tool_loop_agent_runner.py", line 479, in _iter_llm_responses async for resp in stream: # type: ignore File "/AstrBot/astrbot/core/provider/sources/openai_source.py", line 1319, in text_chat_stream ) = await self._handle_api_error( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/AstrBot/astrbot/core/provider/sources/openai_responses_source.py", line 649, in _handle_api_error result = await super()._handle_api_error( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/AstrBot/astrbot/core/provider/sources/openai_source.py", line 1183, in _handle_api_error raise e File "/AstrBot/astrbot/core/provider/sources/openai_source.py", line 1302, in text_chat_stream async for response in self._query_stream( File "/AstrBot/astrbot/core/provider/sources/openai_responses_source.py", line 417, in _query_stream stream = await retry_provider_request( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/AstrBot/astrbot/core/provider/sources/request_retry.py", line 124, in retry_provider_request async for attempt in retrying: File "/usr/local/lib/python3.12/site-packages/tenacity/asyncio/init.py", line 170, in anext do = await self.iter(retry_state=self._retry_state) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/tenacity/asyncio/init.py", line 157, in iter result = await action(retry_state) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/tenacity/_utils.py", line 111, in inner return call(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/tenacity/init.py", line 393, in self._add_action_func(lambda rs: rs.outcome.result()) ^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/concurrent/futures/_base.py", line 449, in result return self.__get_result() ^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/concurrent/futures/_base.py", line 401, in __get_result raise self._exception File "/AstrBot/astrbot/core/provider/sources/request_retry.py", line 126, in retry_provider_request return await request_factory() ^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/openai/resources/responses/responses.py", line 2865, in create return await self._post( ^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/openai/_base_client.py", line 1992, in post return await self.request(cast_to, opts, stream=stream, stream_cls=stream_cls) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/openai/_base_client.py", line 1777, in request raise self.make_status_error_from_response(err.response) from None openai.BadRequestError: Error code: 400 - {'error': {'message': "Invalid 'tools[428].name': string does not match pattern. Expected a string that matches the pattern '^[a-zA-Z0-9-]+$'.", 'type': 'invalid_request_error', 'param': None, 'code': 'invalid_request_error'}}

Are you willing to submit a PR? / 你愿意提交 PR 吗?

  • Yes!

Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions