diff --git a/src/mcp_agent/mcp/common.py b/src/mcp_agent/mcp/common.py index 5935dc46..a62e298f 100644 --- a/src/mcp_agent/mcp/common.py +++ b/src/mcp_agent/mcp/common.py @@ -3,7 +3,7 @@ """ # Constants -SEP = "-" +SEP = "__" def create_namespaced_name(server_name: str, resource_name: str) -> str: diff --git a/tests/integration/api/mcp_tools_server.py b/tests/integration/api/mcp_tools_server.py index 9c56db84..03df6362 100644 --- a/tests/integration/api/mcp_tools_server.py +++ b/tests/integration/api/mcp_tools_server.py @@ -13,6 +13,13 @@ # Create the FastMCP server app = FastMCP(name="An MCP Server", instructions="Here is how to use this server") +@app.prompt( + name="check_weather_prompt", + description="Asks for the weather in a specified location.", +) +def check_weather_prompt(location: str) -> str: + """The location to check""" + return f"Check the weather in {location}" @app.tool( name="check_weather", diff --git a/tests/integration/api/test_describe_a2a.py b/tests/integration/api/test_describe_a2a.py index d2d21266..3b707d0e 100644 --- a/tests/integration/api/test_describe_a2a.py +++ b/tests/integration/api/test_describe_a2a.py @@ -2,6 +2,8 @@ import pytest +from mcp_agent.mcp.common import SEP + if TYPE_CHECKING: from a2a_types.types import AgentCard, AgentSkill @@ -26,7 +28,7 @@ async def agent_function(): assert 2 == len(card.skills) skill: AgentSkill = card.skills[0] - assert "card_test-check_weather" == skill.id + assert f"card_test{SEP}check_weather" == skill.id assert "check_weather" == skill.name assert "Returns the weather for a specified location." assert skill.tags diff --git a/tests/integration/api/test_hyphens_in_name.py b/tests/integration/api/test_hyphens_in_name.py index e002197e..59dce7eb 100644 --- a/tests/integration/api/test_hyphens_in_name.py +++ b/tests/integration/api/test_hyphens_in_name.py @@ -1,6 +1,7 @@ - import pytest +from mcp_agent.mcp.common import SEP + @pytest.mark.integration @pytest.mark.asyncio @@ -10,6 +11,14 @@ async def test_hyphenated_server_name(fast_agent): @fast.agent(name="test", instruction="here are you instructions", servers=["hyphen-test"]) async def agent_function(): async with fast.run() as app: + # test prompt/get request + get_prompt_result = await app.test.get_prompt( + prompt_name=f"hyphen-test{SEP}check_weather_prompt", + arguments={"location": "New York"}, + ) + assert get_prompt_result.description is None + + # test tool calling result = await app.test.send('***CALL_TOOL check_weather {"location": "New York"}') assert "sunny" in result diff --git a/tests/integration/api/test_tool_list_change.py b/tests/integration/api/test_tool_list_change.py index 108e59ba..8267e50b 100644 --- a/tests/integration/api/test_tool_list_change.py +++ b/tests/integration/api/test_tool_list_change.py @@ -4,6 +4,8 @@ import pytest +from mcp_agent.mcp.common import SEP + if TYPE_CHECKING: from mcp import ListToolsResult @@ -24,7 +26,7 @@ async def agent_function(): # Initially there should be one tool (check_weather) tools: ListToolsResult = await app.test.list_tools() assert 1 == len(tools.tools) - assert "dynamic_tool-check_weather" == tools.tools[0].name + assert f"dynamic_tool{SEP}check_weather" == tools.tools[0].name # Calling check_weather will toggle the dynamic_tool and send a notification result = await app.test.send('***CALL_TOOL check_weather {"location": "New York"}') @@ -37,7 +39,7 @@ async def agent_function(): dynamic_tool_found = False # Check if dynamic_tool is in the list for tool in tools.tools: - if tool.name == "dynamic_tool-dynamic_tool": + if tool.name == f"dynamic_tool{SEP}dynamic_tool": dynamic_tool_found = True break diff --git a/tests/integration/roots/live.py b/tests/integration/roots/live.py index 89b88fd9..1ca90bc3 100644 --- a/tests/integration/roots/live.py +++ b/tests/integration/roots/live.py @@ -1,6 +1,7 @@ import asyncio from mcp_agent.core.fastagent import FastAgent +from mcp_agent.mcp.common import SEP # Create the application fast = FastAgent("FastAgent Example") @@ -11,7 +12,7 @@ async def main(): # use the --model command line switch or agent arguments to change model async with fast.run() as agent: - await agent.send("***CALL_TOOL roots_test-show_roots {}") + await agent.send(f"***CALL_TOOL roots_test{SEP}show_roots {{}}") if __name__ == "__main__": diff --git a/tests/integration/roots/test_roots.py b/tests/integration/roots/test_roots.py index 2dddb918..6760b391 100644 --- a/tests/integration/roots/test_roots.py +++ b/tests/integration/roots/test_roots.py @@ -1,5 +1,7 @@ import pytest +from mcp_agent.mcp.common import SEP + @pytest.mark.integration @pytest.mark.asyncio @@ -12,7 +14,7 @@ async def test_roots_returned(fast_agent): @fast.agent(name="foo", instruction="bar", servers=["roots_test"]) async def agent_function(): async with fast.run() as agent: - result = await agent.foo.send("***CALL_TOOL roots_test-show_roots {}") + result = await agent.foo.send(f"***CALL_TOOL roots_test{SEP}show_roots {{}}") assert "file:///mnt/data/" in result # alias assert "test_data" in result assert "file://no/alias" in result # no alias. diff --git a/tests/integration/sampling/live.py b/tests/integration/sampling/live.py index 93bc577a..534c19a3 100644 --- a/tests/integration/sampling/live.py +++ b/tests/integration/sampling/live.py @@ -1,6 +1,7 @@ import asyncio from mcp_agent.core.fastagent import FastAgent +from mcp_agent.mcp.common import SEP # Create the application with specified model fast = FastAgent("FastAgent Example") @@ -11,10 +12,10 @@ async def main(): # use the --model command line switch or agent arguments to change model async with fast.run() as agent: - result = await agent.send('***CALL_TOOL sampling_test-sample {"to_sample": "123foo"}') + result = await agent.send(f'***CALL_TOOL sampling_test{SEP}sample {"to_sample": "123foo"}') print(f"RESULT: {result}") - result = await agent.send('***CALL_TOOL slow_sampling-sample_parallel') + result = await agent.send(f'***CALL_TOOL slow_sampling{SEP}sample_parallel') print(f"RESULT: {result}")