top_profile
Run a live sampling profiler on a Python process for a few seconds and return a summary of the most time-consuming functions.
Instructions
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.
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "top_profile"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| gil | No | Only show traces holding the GIL. | |
| pid | No | Process ID. Use this OR command. | |
| idle | No | Include idle threads. | |
| rate | No | Samples per second (default 100). | |
| native | No | Include native frames if supported. | |
| command | No | Command to run and monitor. Use this OR pid. | |
| duration | No | How many seconds to run top (default 5, recommended 5-60). | |
| subprocesses | No | Include child processes. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |