pyspy-mcp

v0.2.1
pyspy-mcp Checked 3 days ago Published 4 months ago

MCP server for Python performance testing with py-spy

These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.

record_profile Record Profile

Record a sampling profile of a Python process or command.

ParameterTypeDescription
commandCommand to run and sample, e.g. ["python", "script.py"]. Use this OR pid.
durationintegerHow many seconds to sample (default 5, recommended 5-60).
gilbooleanOnly include traces holding the GIL.
idlebooleanInclude idle threads.
nativebooleanInclude native/C extension frames if supported on this platform.
output_formatstringOne of "speedscope" (JSON), "flamegraph" (SVG), "raw" (text), "chrometrace".
pidProcess ID to sample. Use this OR command, not both.
rateintegerSamples per second (default 100).
subprocessesbooleanInclude child Python processes.

dump_stacks Dump Stacks

Dump the current Python call stacks of a process.

ParameterTypeDescription
pid *integerProcess ID to inspect.
json_outputbooleanReturn structured JSON instead of human-readable text.
locals_levelintegerNumber of times to pass --locals (0-2). Each level shows more locals.
nativebooleanInclude native frames if supported.
subprocessesbooleanInclude child Python processes.

list_python_processes List Python Processes

List running Python processes on this machine.

analyze_profile Analyze Profile

Analyze an existing py-spy profile and return the hottest frames.

ParameterTypeDescription
profile_path *stringPath to a speedscope JSON (.json) or raw (.txt) profile.
top_nintegerNumber of top frames to return (default 10).

compare_profiles Compare Profiles

Compare two speedscope profiles and show percentage changes.

ParameterTypeDescription
profile_a *stringPath to the first profile.
profile_b *stringPath to the second profile.
top_nintegerNumber of frames to show (default 10).

top_profile Top Profile

Run a live ``py-spy top`` view for a few seconds and return the summary. On Windows, ``py-spy top`` cannot be captured through a pipe, so this tool falls back to a short ``record --format raw`` sample and returns the hottest frames instead of raw top output.

ParameterTypeDescription
commandCommand to run and monitor. Use this OR pid.
durationintegerHow many seconds to run top (default 5, recommended 5-60).
gilbooleanOnly show traces holding the GIL.
idlebooleanInclude idle threads.
nativebooleanInclude native frames if supported.
pidProcess ID. Use this OR command.
rateintegerSamples per second (default 100).
subprocessesbooleanInclude child processes.