pyspy-mcp
v0.2.1MCP 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.
| Parameter | Type | Description |
|---|---|---|
command | Command to run and sample, e.g. ["python", "script.py"]. Use this OR pid. | |
duration | integer | How many seconds to sample (default 5, recommended 5-60). |
gil | boolean | Only include traces holding the GIL. |
idle | boolean | Include idle threads. |
native | boolean | Include native/C extension frames if supported on this platform. |
output_format | string | One of "speedscope" (JSON), "flamegraph" (SVG), "raw" (text), "chrometrace". |
pid | Process ID to sample. Use this OR command, not both. | |
rate | integer | Samples per second (default 100). |
subprocesses | boolean | Include child Python processes. |
dump_stacks Dump Stacks
Dump the current Python call stacks of a process.
| Parameter | Type | Description |
|---|---|---|
pid * | integer | Process ID to inspect. |
json_output | boolean | Return structured JSON instead of human-readable text. |
locals_level | integer | Number of times to pass --locals (0-2). Each level shows more locals. |
native | boolean | Include native frames if supported. |
subprocesses | boolean | Include 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.
| Parameter | Type | Description |
|---|---|---|
profile_path * | string | Path to a speedscope JSON (.json) or raw (.txt) profile. |
top_n | integer | Number of top frames to return (default 10). |
compare_profiles Compare Profiles
Compare two speedscope profiles and show percentage changes.
| Parameter | Type | Description |
|---|---|---|
profile_a * | string | Path to the first profile. |
profile_b * | string | Path to the second profile. |
top_n | integer | Number 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.
| Parameter | Type | Description |
|---|---|---|
command | Command to run and monitor. Use this OR pid. | |
duration | integer | How many seconds to run top (default 5, recommended 5-60). |
gil | boolean | Only show traces holding the GIL. |
idle | boolean | Include idle threads. |
native | boolean | Include native frames if supported. |
pid | Process ID. Use this OR command. | |
rate | integer | Samples per second (default 100). |
subprocesses | boolean | Include child processes. |