Extract Function
extractFunctionExtract a selected code range into a new function with automatic parameter and return type detection. Get rename locations for meaningful naming.
Instructions
Extract the selected code range into a new function. TypeScript auto-detects parameters and return type. The response includes renameFilename/renameLocation so you can follow up with rename_symbol to give the function a meaningful name.
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>",
"startLine": "<startLine>",
"startOffset": "<startOffset>",
"endLine": "<endLine>",
"endOffset": "<endOffset>",
"preview": "<preview>"
},
"name": "extractFunction"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| file | Yes | File path (absolute or relative to cwd) | |
| endLine | Yes | 1-based end line | |
| preview | Yes | If true, only preview changes | |
| endOffset | Yes | 1-based end character offset | |
| startLine | Yes | 1-based start line | |
| startOffset | Yes | 1-based start character offset |