Files
tracy/extra/mcp/start_mcp.sh
Alan Tse e670bd18f7 feat(mcp): migrate to MCP Python SDK v2
`pip install mcp` now installs 2.x by default (v1 is
maintenance-only going forward), and nothing in this repo pinned a
version, so a fresh install already broke: v2 removed
mcp.server.fastmcp entirely, no compat shim.

- Import/class: mcp.server.fastmcp.FastMCP ->
  mcp.server.mcpserver.MCPServer.
- Transport options (host, port, sse_path, streamable_http_path)
  moved off the constructor and the settings object onto run();
  mutating mcp_server.settings.port now raises ValueError.
- _http_ping and the startup message read _SSE_PATH/
  _STREAMABLE_HTTP_PATH constants instead of settings.sse_path/
  settings.streamable_http_path -- v2 no longer exposes them to
  read back. Values match the SDK's own defaults in both versions
  ("/sse", "/mcp"), so served paths are unchanged.
- Adds extra/mcp/requirements.txt (mcp>=2.0.0,<3) -- there was no
  dependency manifest at all before this.

Decorator API is unchanged; every tool/resource here was already
async def, so the "sync handlers now run on worker threads" change
doesn't apply.

Verified in an isolated venv (mcp 2.0.0): module imports cleanly
with all 10 tools and 2 resources registered, the server starts
and serves streamable-http on the expected path, and _http_ping
correctly reports a running instance as alive.
2026-08-21 20:42:28 -07:00

20 lines
746 B
Bash

#!/bin/sh
# Start the Tracy MCP server.
#
# First run: pip install -r requirements.txt (next to this script).
#
# Set PYTHONPATH to the directory containing TracyServerBindings.so/.pyd.
# Adjust the Release/Debug suffix to match your CMake build configuration.
PYTHONPATH="${PYTHONPATH:+$PYTHONPATH:}$(dirname "$0")/../../build/python/Release"
export PYTHONPATH
# Machine-local overrides (not committed). Create start_mcp.local.sh next to
# this file to set TRACY_CAPTURES_DIR, TRACY_MCP_PORT, or any other env var:
# export TRACY_CAPTURES_DIR=/path/to/captures
# export TRACY_MCP_PORT=47380
if [ -f "$(dirname "$0")/start_mcp.local.sh" ]; then
. "$(dirname "$0")/start_mcp.local.sh"
fi
exec python3 "$(dirname "$0")/tracy_mcp.py" "$@"