Skip to content
Open
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
2 changes: 1 addition & 1 deletion src/mcp_agent/mcp/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""

# Constants
SEP = "-"
SEP = "__"


def create_namespaced_name(server_name: str, resource_name: str) -> str:
Expand Down
7 changes: 7 additions & 0 deletions tests/integration/api/mcp_tools_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 3 additions & 1 deletion tests/integration/api/test_describe_a2a.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import pytest

from mcp_agent.mcp.common import SEP

if TYPE_CHECKING:
from a2a_types.types import AgentCard, AgentSkill

Expand All @@ -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
Expand Down
11 changes: 10 additions & 1 deletion tests/integration/api/test_hyphens_in_name.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

import pytest

from mcp_agent.mcp.common import SEP


@pytest.mark.integration
@pytest.mark.asyncio
Expand All @@ -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

Expand Down
6 changes: 4 additions & 2 deletions tests/integration/api/test_tool_list_change.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

import pytest

from mcp_agent.mcp.common import SEP

if TYPE_CHECKING:
from mcp import ListToolsResult

Expand All @@ -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"}')
Expand All @@ -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

Expand Down
3 changes: 2 additions & 1 deletion tests/integration/roots/live.py
Original file line number Diff line number Diff line change
@@ -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")
Expand All @@ -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__":
Expand Down
4 changes: 3 additions & 1 deletion tests/integration/roots/test_roots.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import pytest

from mcp_agent.mcp.common import SEP


@pytest.mark.integration
@pytest.mark.asyncio
Expand All @@ -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.
Expand Down
5 changes: 3 additions & 2 deletions tests/integration/sampling/live.py
Original file line number Diff line number Diff line change
@@ -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")
Expand All @@ -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}")


Expand Down
Loading