extract_code_block
Extract a function, struct, class, or method from source code and return its exact line range and content, including annotations and doc comments while ignoring braces in strings or comments.
Instructions
Read the full text of a function, struct, class, or method from a file. Returns precise line range + content. Includes leading annotations (#[derive], @decorator, /// doc comments). String/comment-aware bracket matching prevents false depth counts from braces inside strings or comments.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"file": "<file>",
"symbol": "<symbol>"
},
"name": "extract_code_block"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| cwd | No | Working directory for resolving relative file paths (default: primary project root) | |
| file | Yes | Source file path (absolute or relative to cwd) | |
| symbol | Yes | Symbol name to extract | |
| contextLines | No | Extra lines before/after the block (default: 0) |