diff --git a/pyproject.toml b/pyproject.toml index f351c65c..ce4b79c3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -71,6 +71,8 @@ tools = [ "selenium", "html2text", "fastmcp>=2.2.0,<3.0", + # FastMCP 2 uses MCP SDK 1.x APIs (including McpError). + "mcp<2", "cryptography<49", "PyPDF2", "Pillow", @@ -134,6 +136,7 @@ all = [ "selenium", "html2text", "fastmcp>=2.2.0,<3.0", + "mcp<2", "cryptography<49", "PyPDF2", "Pillow", diff --git a/requirements.txt b/requirements.txt index 3fa2f55c..012314a6 100644 --- a/requirements.txt +++ b/requirements.txt @@ -49,6 +49,7 @@ beautifulsoup4 selenium>=4.0.0 html2text>=2020.1.16 fastmcp>=2.2.0,<3.0 +mcp<2 PyPDF2>=3.0.0 Pillow exa-py>=2.0.0 diff --git a/tests/src/tools/test_mcp_stdio.py b/tests/src/tools/test_mcp_stdio.py new file mode 100644 index 00000000..77241d22 --- /dev/null +++ b/tests/src/tools/test_mcp_stdio.py @@ -0,0 +1,31 @@ +"""Exercise the installed FastMCP/SDK pair through EvoAgentX's public wrapper.""" + +import sys +from importlib import import_module + + +def test_mcp_client_discovers_and_calls_local_stdio_tool(tmp_path): + # A compatible install must also expose the public workflow entry point. + import_module("evoagentx.workflow") + from evoagentx.tools.mcp import MCPClient + + server = tmp_path / "mcp_server.py" + server.write_text( + "from fastmcp import FastMCP\n" + "server = FastMCP('offline-arithmetic')\n" + "@server.tool\n" + "def add(a: int, b: int) -> int:\n" + " return a + b\n" + "if __name__ == '__main__':\n" + " server.run()\n", + encoding="utf-8", + ) + config = { + "mcpServers": {"arithmetic": {"command": sys.executable, "args": [str(server)]}} + } + + with MCPClient(config, connect_timeout=10) as toolkits: + assert len(toolkits) == 1 + toolkit = toolkits[0] + assert toolkit.get_tool_names() == ["add"] + assert toolkit.get_tool("add")(a=2, b=3) == ["5"]