[BUG] MCPClient passes MCP tool names with "." to the model unchanged, so providers that only accept [a-zA-Z0-9_-] reject every request
Human Overview
MCP servers can have tools with a dot in the name. Amazon Bedrock and other providers block the request because of the dot, so every agent call fails. The fix swaps the dot for _ in the name the model sees; the MCP server still gets the original name.
Checks
- [x] I have updated to the lastest minor and patch version of Strands
- [x] I have checked the documentation and this is not expected behavior
- [x] I have searched ./issues and there are no duplicates of my issue
SDK Language
Python
Strands Version
main at c8e1351 (python/v1.65.0 is the latest release)
Language Runtime Version
Python 3.13.2, mcp 2.3.0
Operating System
macOS 27.0.1
Installation Method
git clone
Steps to Reproduce
The MCP spec allows . in tool names: SEP-986 lists the allowed characters as A-Z, a-z, 0-9, underscore (_), dash (-), and dot (.) (https://modelcontextprotocol.io/specification/2025-11-25/server/tools#tool-names). An MCP server with such a tool:
# server.py
from mcp.server.mcpserver import MCPServer # FastMCP on mcp 1.x
mcp = MCPServer("files")
@mcp.tool(name="files.read")
def files_read(path: str) -> str:
"""Read a file."""
return f"contents of {path}"
mcp.run()
import sys
from mcp import StdioServerParameters, stdio_client
from strands.models.bedrock import BedrockModel
from strands.tools.mcp import MCPClient
client = MCPClient(lambda: stdio_client(StdioServerParameters(command=sys.executable, args=["server.py"])))
with client:
tools = client.list_tools_sync()
print([tool.tool_name for tool in tools]) # ['files.read']
request = BedrockModel(model_id="anthropic.claude-test").format_request(
[{"role": "user", "content": [{"text": "hi"}]}], [tool.tool_spec for tool in tools]
)
print([tool["toolSpec"]["name"] for tool in request["toolConfig"]["tools"]]) # ['files.read']
Expected Behavior
The tool is exposed to the model under a name the provider accepts (for example files_read) and is still called on the server as files.read.
Actual Behavior
files.read is registered unchanged and sent as the tool name in every model request.
- Bedrock: botocore's service model for
bedrock-runtimedefinesToolSpecification.nameasToolNamewithpattern: [a-zA-Z0-9_-]+,min: 1,max: 64, sofiles.readdoes not match. I checked this against the service model; I did not send a live Bedrock request. - OpenAI documents the same
^[a-zA-Z0-9_-]{1,64}$pattern for function names.
Since the tool list goes with every request, one such tool makes every model call of the agent fail, not just calls to that tool. prefix= does not help: _sanitize_prefix cleans the prefix but not the tool name.
The TypeScript SDK's ToolRegistry rejects these names when the tool is registered ("Tool name must contain only alphanumeric characters, hyphens, and underscores"), so there the failure is at least immediate. The Python registry does not validate names, so it only fails at the model call.
Possible Solution
In MCPClient.list_tools_sync, replace characters outside [A-Za-z0-9_-] with _ in the agent-facing name, using the existing _sanitize_prefix regex and MCPAgentTool(name_override=...). MCPAgentTool already calls the server with mcp_tool.name, and string/regex tool_filters already match the server-side name, so neither changes. If two tools from one server map to the same name (files.read and files_read), raise a ValueError that names both. I have a PR ready.
Additional Context
Related but different: #4513 / #4569 (overlong prefixed names, TypeScript) and #2523 (invalid tool-use names returned by a model).
Disclosure: I used Claude Code to help investigate this and write the repro; I reviewed and ran it.