FastMCP install & test with MCP Inspector on MacBook Pro

支 持 本 站: 捐赠服务器等运维费用,需要您的支持!

install uv
1. curl -LsSf https://astral.sh/uv/install.sh |sh
2. export PATH=$PATH:$HOME/.local/bin
3. confirm
% uv -V
uv 0.8.14 (af856fb88 2025-08-28)
% uvx -V
uvx 0.8.14 (af856fb88 2025-08-28)
4. update node
% node -v
v14.21.3
% brew upgrade node
% node -v
v24.7.0



支 持 本 站: 捐赠服务器等运维费用,需要您的支持!

create project

1. uv init mcp-demo
Initialized project `mcp-demo` at `/Users/yinlei/source/mcp-demo`
2. cd mcp-demo
3. uv add "mcp[cli]"

Using CPython 3.12.2 interpreter at: /usr/local/opt/[email protected]/bin/python3.12
Creating virtual environment at: .venv
Resolved 35 packages in 285ms
Prepared 32 packages in 181ms
Installed 32 packages in 19ms
+ annotated-types==0.7.0
+ anyio==4.10.0
+ attrs==25.3.0
+ certifi==2025.8.3
+ click==8.2.1
+ h11==0.16.0
+ httpcore==1.0.9
+ httpx==0.28.1
+ httpx-sse==0.4.1
+ idna==3.10
+ jsonschema==4.25.1
+ jsonschema-specifications==2025.4.1
+ markdown-it-py==4.0.0
+ mcp==1.13.1
+ mdurl==0.1.2
+ pydantic==2.11.7
+ pydantic-core==2.33.2
+ pydantic-settings==2.10.1
+ pygments==2.19.2
+ python-dotenv==1.1.1
+ python-multipart==0.0.20
+ referencing==0.36.2
+ rich==14.1.0
+ rpds-py==0.27.1
+ shellingham==1.5.4
+ sniffio==1.3.1
+ sse-starlette==3.0.2
+ starlette==0.47.3
+ typer==0.17.3
+ typing-extensions==4.15.0
+ typing-inspection==0.4.1
+ uvicorn==0.35.0

% vi server.py

from mcp.server.fastmcp import FastMCP

mcp = FastMCP("my_test")

@mcp.tool()
def add(a: int, b: int) -> int:
"Add two numbers"
return a + b

@mcp.resource("greeting://{name}")
def greeting(name: str) -> str:
"Get a personalized greeting"
return f"Hello, {name}!"

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

run mcp server with MCP Inspector
% npx @modelcontextprotocol/inspector uv run server.py

Starting MCP inspector...
⚙️ Proxy server listening on localhost:6277
🔑 Session token: b6c60f392eac32ffa9dc78c563c901e85ce644aef84a8338f6b16b4b65590320
Use this token to authenticate requests or set DANGEROUSLY_OMIT_AUTH=true to disable auth

🚀 MCP Inspector is up and running at:
http://localhost:6274/?MCP_PROXY_AUTH_TOKEN=b6c60f392eac32ffa9dc78c563c901e85ce644aef84a8338f6b16b4b65590320

🌐 Opening browser...

click "Connect" , "Tools", "Add", "Run Tool"

支 持 本 站: 捐赠服务器等运维费用,需要您的支持!

发布时间: