Skip to main content
Glama

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
NameRequiredDescriptionDefault
pathYesPath to open in VSCode

Implementation Reference

  • 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"], }, },
  • 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"); } }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/AbdurRaahimm/mcp-git-terminal-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server