MCP error: FileNotFoundError: [WinError 2] 系统找不到指定的文件。

when I run the example in cookbook, error occurs:

client code:

import asyncio
import os

from agno.agent import Agent
from agno.models.deepseek import DeepSeek
from agno.tools.mcp import MCPTools
from dotenv import load_dotenv

load_dotenv()


async def run_agent(message: str) -> None:
    # Initialize the MCP server
    async with (
        MCPTools(
            f"fastmcp run server.py",
        ) as mcp_tools,
    ):
        agent = Agent(
            model=DeepSeek(
                id=os.getenv('DEEPSEEK_CHAT_MODEL'),
                base_url=os.getenv('DEEPSEEK_API_BASE'),
                api_key=os.getenv('DEEPSEEK_API_KEY'),
            ),
            tools=[mcp_tools],
            show_tool_calls=True,
            markdown=True,
        )
        await agent.aprint_response(message, stream=True)

if __name__ == "__main__":
    asyncio.run(run_agent("What is the weather in San Francisco?"))

server code:

from fastmcp import FastMCP

mcp = FastMCP("weather_tools")


@mcp.tool()
def get_weather(city: str) -> str:
    return f"The weather in {city} is sunny"


@mcp.tool()
def get_temperature(city: str) -> str:
    return f"The temperature in {city} is 70 degrees"


if __name__ == "__main__":
    mcp.run(transport="stdio")

error:

File “C:\Users\name.conda\envs\agno\Lib\subprocess.py”, line 1548, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^
# no special security
^^^^^^^^^^^^^^^^^^^^^
…<4 lines>…
cwd,
^^^^
startupinfo)
^^^^^^^^^^^^
FileNotFoundError: [WinError 2] 系统找不到指定的文件。

The server.py and client.py are in the same dir, and file structure is:

project root

  • server.py
  • client.py

I have tried to use the absolutely path

 f"fastmcp run D/mcp_demo/server.py"

but it still doesn’t work and show the same error.

Hey @lijavac
thanks for reaching out and supporting Agno. I’ve shared this with the team, we’re working through all requests one by one and will get back to you soon.
If it’s urgent, please let us know. We appreciate your patience!

Hey @lijavac, your code works fine, it looks like only the file path is wrong.

I would recommend working with absolute paths, as you were trying! You probably only need a small adjustment there. This example works for me using the following string, maybe this helps?:

f"fastmcp run /Users/manu/agno-tech/agno/cookbook/tools/mcp/local_server/server.py"