Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions src/fast_agent/agents/mcp_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,12 @@
from fast_agent.core.exceptions import PromptExitError
from fast_agent.core.logging.logger import get_logger
from fast_agent.interfaces import FastAgentLLMProtocol
from fast_agent.mcp.common import get_resource_name, get_server_name, is_namespaced_name
from fast_agent.mcp.common import (
create_namespaced_name,
get_resource_name,
get_server_name,
is_namespaced_name,
)
from fast_agent.mcp.mcp_aggregator import MCPAggregator, NamespacedTool, ServerStatus
from fast_agent.skills.registry import format_skills_for_prompt
from fast_agent.tools.elicitation import (
Expand Down Expand Up @@ -322,8 +327,8 @@ def _format_server_instructions(
if instructions is None:
continue

# Format tool names with server prefix
prefixed_tools = [f"{server_name}-{tool}" for tool in tool_names]
# Format tool names with server prefix using the new namespacing convention
prefixed_tools = [create_namespaced_name(server_name, tool) for tool in tool_names]
tools_list = ", ".join(prefixed_tools) if prefixed_tools else "No tools available"

formatted_parts.append(
Expand Down
2 changes: 1 addition & 1 deletion src/fast_agent/mcp/mcp_aggregator.py
Original file line number Diff line number Diff line change
Expand Up @@ -1201,7 +1201,7 @@ async def _parse_resource_name(self, name: str, resource_type: str) -> tuple[str

async def call_tool(self, name: str, arguments: dict | None = None) -> CallToolResult:
"""
Call a namespaced tool, e.g., 'server_name-tool_name'.
Call a namespaced tool, e.g., 'server_name__tool_name'.
"""
if not self.initialized:
await self.load_servers()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ async def agent_with_template():
# Check that tools are listed
assert "<tools>" in agent.instruction, \
"Tools section not found in XML"
assert "instructions_enabled-calculate_sum" in agent.instruction, \
assert "instructions_enabled__calculate_sum" in agent.instruction, \
"Tool names not properly prefixed in instructions"


Expand Down Expand Up @@ -197,12 +197,12 @@ async def agent_tools_check():

# Check that all expected tools are listed
expected_tools = [
"instructions_enabled-calculate_sum",
"instructions_enabled-calculate_product",
"instructions_enabled-calculate_divide",
"instructions_enabled-text_reverse",
"instructions_enabled-text_uppercase",
"instructions_enabled-text_count"
"instructions_enabled__calculate_sum",
"instructions_enabled__calculate_product",
"instructions_enabled__calculate_divide",
"instructions_enabled__text_reverse",
"instructions_enabled__text_uppercase",
"instructions_enabled__text_count"
]

for tool in expected_tools:
Expand Down
Loading