open_in_vscode
Open directories or files directly in VSCode from the MCP Terminal & Git Server to streamline development workflows.
Instructions
Open a directory or file in VSCode
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | Path to open in VSCode |
Implementation Reference
- src/index.ts:435-449 (handler)The handler for the 'open_in_vscode' tool within the CallToolRequestSchema switch statement. It resolves the provided path and calls the openInVSCode helper function to open it in VSCode.case "open_in_vscode": { const { path: targetPath } = args as { path: string }; const resolvedPath = resolvePath(targetPath); await openInVSCode(resolvedPath); return { content: [ { type: "text", text: `Opened ${resolvedPath} in VSCode`, }, ], }; }
- src/index.ts:197-210 (registration)Registration of the 'open_in_vscode' tool in the ListToolsRequestSchema response, including name, description, and input schema.{ name: "open_in_vscode", description: "Open a directory or file in VSCode", inputSchema: { type: "object", properties: { path: { type: "string", description: "Path to open in VSCode", }, }, required: ["path"], }, },
- src/index.ts:33-58 (helper)Shared helper function that implements the core logic to open a project path in VSCode, trying 'code' command first then fallback executable paths.// Helper function to open project in VSCode async function openInVSCode(projectPath: string): Promise<void> { try { await execa("code", [projectPath]); } catch (error) { // If 'code' command fails, try common VSCode executable paths const vscodePaths = [ "code", "/usr/local/bin/code", "/usr/bin/code", "C:\\Program Files\\Microsoft VS Code\\Code.exe", "C:\\Program Files (x86)\\Microsoft VS Code\\Code.exe", ]; for (const codePath of vscodePaths) { try { await execa(codePath, [projectPath]); return; } catch { // Continue to next path } } throw new Error("VSCode not found. Please ensure VSCode is installed and 'code' command is available in PATH"); } }