### Claude Prompt for VS Code Workspace Interaction Source: https://github.com/juehang/vscode-mcp-server/blob/master/README.md This prompt guides Claude on interacting with a VS Code workspace using MCP tools. It emphasizes exploration, diagnostics, and specific editing strategies for small and large changes, along with a required planning and approval process. ```plaintext You are working on an existing codebase, which you can access using your tools. These code tools interact with a VS Code workspace. WORKFLOW ESSENTIALS: 1. Always start exploration with list_files_code on root directory (.) first 2. CRITICAL: Run get_diagnostics_code after EVERY set of code changes before completing tasks 3. For small edits (≤10 lines): use replace_lines_code with exact original content 4. For large changes, new files, or uncertain content: use create_file_code with overwrite=true EXPLORATION STRATEGY: - Start: list_files_code with path='.' (never recursive on root) - Understand structure: read key files like package.json, README, main entry points - Find symbols: use search_symbols_code for functions/classes, get_document_symbols_code for file overviews - Before editing: read_file_code the target file to understand current content EDITING BEST PRACTICES: - Small modifications: replace_lines_code (requires exact original content match) - If replace_lines_code fails: read_file_code the target lines, then retry with correct content - Large changes: create_file_code with overwrite=true is more reliable - After any changes: get_diagnostics_code to check for errors PLANNING REQUIREMENTS: Before making code modifications, present a comprehensive plan including: - Confidence level (1-10) and reasoning - Specific tools you'll use and why - Files you'll modify and approach (small edits vs complete rewrites) - How you'll verify the changes work (diagnostics, testing, etc.) ERROR HANDLING: - Let errors happen naturally - don't add unnecessary try/catch blocks - For tool failures: follow the specific recovery guidance in each tool's description - If uncertain about file content: use read_file_code to verify before making changes APPROVAL PROCESS: IMPORTANT: Only run code modification tools after presenting a plan and receiving explicit approval. Each change requires separate approval. Do not add tests unless specifically requested. If you believe testing is important, explain why and let the user decide. ``` -------------------------------- ### Get Symbol Definition Source: https://github.com/juehang/vscode-mcp-server/blob/master/README.md Retrieves definition information for a specific symbol within a file. Provides type, documentation, and source details. ```typescript get_symbol_definition_code(path: string, line: number, symbol: string): Promise ``` -------------------------------- ### Get Symbol Definition Source: https://context7.com/juehang/vscode-mcp-server/llms.txt Retrieves definition information for a symbol at a specific location using hover data. Returns type information, documentation, and source details for the symbol. Requires file path, line number, and the symbol name. ```bash curl -X POST http://localhost:3000/mcp \ -H "Content-Type: application/json" \ -d '{ "jsonrpc": "2.0", "id": 1, "method": "tools/call", "params": { "name": "get_symbol_definition_code", "arguments": { "path": "src/server.ts", "line": 22, "symbol": "MCPServer" } } }' ``` ```json { "content": [ { "type": "text", "text": "Definition information for symbol \"MCPServer\" at src/server.ts:22:13:\n\nCode context: `export class MCPServer {`\n\n```typescript\nclass MCPServer\n```\n\nSymbol range: [22:13] to [22:22]\n" } ] } ``` -------------------------------- ### Get Document Symbols Source: https://github.com/juehang/vscode-mcp-server/blob/master/README.md Generates a hierarchical outline of all symbols within a specified file. Useful for understanding file structure and organization. ```typescript get_document_symbols_code(path: string, maxDepth?: number): Promise ``` -------------------------------- ### Get Diagnostics Code Source: https://context7.com/juehang/vscode-mcp-server/llms.txt Analyzes code for warnings and errors using VS Code's integrated linters and language services. Run this after every set of code changes to verify there are no issues before completing tasks. -------------------------------- ### Get Document Symbols Source: https://context7.com/juehang/vscode-mcp-server/llms.txt Retrieves a complete symbol outline for a file, showing the hierarchical structure of classes, functions, methods, and variables. This is preferred over reading the entire file when only an overview is needed. Supports limiting the depth of the hierarchy. ```bash curl -X POST http://localhost:3000/mcp \ -H "Content-Type: application/json" \ -d '{ "jsonrpc": "2.0", "id": 1, "method": "tools/call", "params": { "name": "get_document_symbols_code", "arguments": { "path": "src/server.ts", "maxDepth": 2 } } }' ``` ```json { "content": [ { "type": "text", "text": "Document symbols for src/server.ts (25 total symbols):\n\nSummary: 1 Class, 8 Methods, 5 Properties, 11 Variables\n\nToolConfiguration (Interface)\n Range: 14:0-20:1 | Children: 5\n\n file (Property)\n Range: 15:4-15:17\n\n edit (Property)\n Range: 16:4-16:17\n\nMCPServer (Class)\n Range: 22:0-305:1 | Children: 12\n\n server (Property)\n Range: 23:4-23:26\n\n setupTools (Method)\n Range: 74:4-121:5\n\n start (Method)\n Range: 215:4-248:5\n" } ] } ``` -------------------------------- ### Execute Shell Command Code Source: https://context7.com/juehang/vscode-mcp-server/llms.txt Executes shell commands in VS Code's integrated terminal with shell integration. Commands must complete within the timeout period (default 10 seconds) or will return a timeout error. Useful for running CLI commands, builds, git operations, and package installations. ```bash # Run npm install curl -X POST http://localhost:3000/mcp \ -H "Content-Type: application/json" \ -d '{ "jsonrpc": "2.0", "id": 1, "method": "tools/call", "params": { "name": "execute_shell_command_code", "arguments": { "command": "npm install", "cwd": ".", "timeout": 30000 } } }' ``` ```bash # Run git status curl -X POST http://localhost:3000/mcp \ -H "Content-Type: application/json" \ -d '{ "jsonrpc": "2.0", "id": 1, "method": "tools/call", "params": { "name": "execute_shell_command_code", "arguments": { "command": "git status", "cwd": "." } } }' ``` ```bash # Run TypeScript compiler curl -X POST http://localhost:3000/mcp \ -H "Content-Type: application/json" \ -d '{ "jsonrpc": "2.0", "id": 1, "method": "tools/call", "params": { "name": "execute_shell_command_code", "arguments": { "command": "npm run compile", "timeout": 60000 } } }' ``` -------------------------------- ### List Files in Workspace using MCP Source: https://context7.com/juehang/vscode-mcp-server/llms.txt Use the `list_files_code` tool to explore the project structure. Avoid using `recursive=true` on the root directory to prevent excessive output. ```bash # MCP Request to list files in root directory curl -X POST http://localhost:3000/mcp \ -H "Content-Type: application/json" \ -d '{ "jsonrpc": "2.0", "id": 1, "method": "tools/call", "params": { "name": "list_files_code", "arguments": { "path": ".", "recursive": false } } }' # Response { "content": [ { "type": "text", "text": "[{\"path\": \"src\", \"type\": \"directory\"}, {\"path\": \"package.json\", \"type\": \"file\"}, {\"path\": \"README.md\", \"type\": \"file\"}]" } ] } ``` -------------------------------- ### Check Workspace Diagnostics Source: https://context7.com/juehang/vscode-mcp-server/llms.txt Use this to retrieve code diagnostics for the entire workspace. Specify severities and whether to include source code. The response format can be text or JSON. ```bash curl -X POST http://localhost:3000/mcp \ -H "Content-Type: application/json" \ -d '{ "jsonrpc": "2.0", "id": 1, "method": "tools/call", "params": { "name": "get_diagnostics_code", "arguments": { "severities": [0, 1], "format": "text", "includeSource": true } } }' ``` ```json { "content": [ { "type": "text", "text": "Found 2 issue(s):\n\nError: src/tools/file-tools.ts:45:10\n Property 'foo' does not exist on type 'FileResult'\n Source: ts\n\nWarning: src/server.ts:120:5\n 'result' is declared but never used\n Source: ts\n" } ] } ``` -------------------------------- ### Connect MCP Client Source: https://github.com/juehang/vscode-mcp-server/blob/master/README.md Configuration for connecting MCP clients to the VS Code MCP Server. Ensure the server is enabled via the status bar item. ```http http://localhost:3000/mcp ``` ```http http://[your-host]:3000/mcp ``` -------------------------------- ### Configure Claude Desktop for VS Code MCP Server Source: https://context7.com/juehang/vscode-mcp-server/llms.txt Configure Claude Desktop to connect to the VS Code MCP Server by specifying the command and arguments to launch the MCP remote client. ```json { "mcpServers": { "vscode-mcp-server": { "command": "npx", "args": ["mcp-remote@next", "http://localhost:3000/mcp"] } } } ``` -------------------------------- ### Configure VS Code MCP Server Settings Source: https://context7.com/juehang/vscode-mcp-server/llms.txt Configure the MCP server's port, host, default enablement, and specific tool enablement through VS Code settings. ```json { "vscode-mcp-server.port": 3000, "vscode-mcp-server.host": "127.0.0.1", "vscode-mcp-server.defaultEnabled": false, "vscode-mcp-server.enabledTools": { "file": true, "edit": true, "shell": true, "diagnostics": true, "symbol": true } } ``` -------------------------------- ### Claude Desktop Configuration for VS Code MCP Server Source: https://github.com/juehang/vscode-mcp-server/blob/master/README.md Configure Claude Desktop to use the VS Code MCP Server extension by specifying the command and arguments in your `claude_desktop_config.json` file. Ensure the port is not exposed externally due to potential security risks. ```json { "mcpServers": { "vscode-mcp-server": { "command": "npx", "args": ["mcp-remote@next", "http://localhost:3000/mcp"] } } } ``` -------------------------------- ### File Tools API Source: https://github.com/juehang/vscode-mcp-server/blob/master/README.md APIs for listing, reading, moving, renaming, and copying files and directories within the VS Code workspace. ```APIDOC ## list_files_code ### Description Lists files and directories in your workspace. ### Method POST ### Endpoint /juehang/vscode-mcp-server/list_files_code ### Parameters #### Query Parameters - **path** (string) - Required - The path to list files from - **recursive** (boolean) - Optional - Whether to list files recursively ### Request Example { "path": "/src", "recursive": true } ## read_file_code ### Description Reads file contents with encoding support and size limits. ### Method POST ### Endpoint /juehang/vscode-mcp-server/read_file_code ### Parameters #### Query Parameters - **path** (string) - Required - The path to the file to read - **encoding** (string) - Optional - File encoding (default: utf-8) - **maxCharacters** (integer) - Optional - Maximum character count (default: 100,000) ### Request Example { "path": "/src/index.js", "encoding": "utf-8", "maxCharacters": 5000 } ## move_file_code ### Description Moves a file or directory to a new location using VS Code's WorkspaceEdit API. ### Method POST ### Endpoint /juehang/vscode-mcp-server/move_file_code ### Parameters #### Query Parameters - **sourcePath** (string) - Required - The current path of the file or directory to move - **targetPath** (string) - Required - The new path where the file or directory should be moved to - **overwrite** (boolean) - Optional - Whether to overwrite if target already exists (default: false) ### Request Example { "sourcePath": "/src/old_file.js", "targetPath": "/dist/new_file.js", "overwrite": true } ## rename_file_code ### Description Renames a file or directory using VS Code's WorkspaceEdit API. ### Method POST ### Endpoint /juehang/vscode-mcp-server/rename_file_code ### Parameters #### Query Parameters - **filePath** (string) - Required - The current path of the file or directory to rename - **newName** (string) - Required - The new name for the file or directory - **overwrite** (boolean) - Optional - Whether to overwrite if a file with the new name already exists (default: false) ### Request Example { "filePath": "/src/old_name.js", "newName": "new_name.js", "overwrite": false } ## copy_file_code ### Description Copies a file to a new location using VS Code's file system API. ### Method POST ### Endpoint /juehang/vscode-mcp-server/copy_file_code ### Parameters #### Query Parameters - **sourcePath** (string) - Required - The path of the file to copy - **targetPath** (string) - Required - The path where the copy should be created - **overwrite** (boolean) - Optional - Whether to overwrite if target already exists (default: false) ### Request Example { "sourcePath": "/src/file_to_copy.js", "targetPath": "/dist/copied_file.js", "overwrite": false } ``` -------------------------------- ### Read File Contents using MCP Source: https://context7.com/juehang/vscode-mcp-server/llms.txt Use the `read_file_code` tool to read file contents. Supports encoding, character limits, and partial reading via line numbers. Files over 100,000 characters require line ranges. ```bash # Read entire file curl -X POST http://localhost:3000/mcp \ -H "Content-Type: application/json" \ -d '{ "jsonrpc": "2.0", "id": 1, "method": "tools/call", "params": { "name": "read_file_code", "arguments": { "path": "src/server.ts", "encoding": "utf-8", "maxCharacters": 100000 } } }' # Read specific lines (1-based, inclusive) curl -X POST http://localhost:3000/mcp \ -H "Content-Type: application/json" \ -d '{ "jsonrpc": "2.0", "id": 1, "method": "tools/call", "params": { "name": "read_file_code", "arguments": { "path": "src/server.ts", "startLine": 1, "endLine": 50 } } }' # Read file as base64 (for binary files) curl -X POST http://localhost:3000/mcp \ -H "Content-Type: application/json" \ -d '{ "jsonrpc": "2.0", "id": 1, "method": "tools/call", "params": { "name": "read_file_code", "arguments": { "path": "media/logo.png", "encoding": "base64" } } }' ``` -------------------------------- ### File Tools Source: https://context7.com/juehang/vscode-mcp-server/llms.txt This section details the file manipulation tools available through the MCP Server API. ```APIDOC ## POST /mcp (tools/call - list_files_code) ### Description Lists files and directories in the VS Code workspace. Use this tool to explore project structure and understand the codebase layout before performing read or modify operations. Never set `recursive=true` on the root directory as output will be too large. ### Method POST ### Endpoint `/mcp` ### Parameters #### Request Body - **jsonrpc** (string) - Required - "2.0" - **id** (integer) - Required - Request ID. - **method** (string) - Required - "tools/call" - **params** (object) - Required - **name** (string) - Required - "list_files_code" - **arguments** (object) - Required - **path** (string) - Required - The directory path to list files from. Use "." for the root. - **recursive** (boolean) - Optional - Whether to list files recursively. Defaults to false. ### Request Example ```json { "jsonrpc": "2.0", "id": 1, "method": "tools/call", "params": { "name": "list_files_code", "arguments": { "path": ".", "recursive": false } } } ``` ### Response #### Success Response (200) - **content** (array) - An array of objects representing files and directories. - **type** (string) - "directory" or "file". - **path** (string) - The path of the file or directory. #### Response Example ```json { "jsonrpc": "2.0", "id": 1, "result": { "content": [ { "type": "text", "text": "[{"path": "src", "type": "directory"}, {"path": "package.json", "type": "file"}, {"path": "README.md", "type": "file"}]" } ] } } ``` ``` ```APIDOC ## POST /mcp (tools/call - read_file_code) ### Description Reads file contents with encoding support and character limits. Supports partial file reading via line numbers for large files. Files exceeding 100,000 characters will fail unless you specify line ranges. ### Method POST ### Endpoint `/mcp` ### Parameters #### Request Body - **jsonrpc** (string) - Required - "2.0" - **id** (integer) - Required - Request ID. - **method** (string) - Required - "tools/call" - **params** (object) - Required - **name** (string) - Required - "read_file_code" - **arguments** (object) - Required - **path** (string) - Required - The path to the file to read. - **encoding** (string) - Optional - The file encoding (e.g., "utf-8", "base64"). Defaults to "utf-8". - **maxCharacters** (integer) - Optional - The maximum number of characters to read. Defaults to 100000. - **startLine** (integer) - Optional - The starting line number (1-based, inclusive) for partial reading. - **endLine** (integer) - Optional - The ending line number (1-based, inclusive) for partial reading. ### Request Example ```json # Read entire file { "jsonrpc": "2.0", "id": 1, "method": "tools/call", "params": { "name": "read_file_code", "arguments": { "path": "src/server.ts", "encoding": "utf-8", "maxCharacters": 100000 } } } # Read specific lines (1-based, inclusive) { "jsonrpc": "2.0", "id": 1, "method": "tools/call", "params": { "name": "read_file_code", "arguments": { "path": "src/server.ts", "startLine": 1, "endLine": 50 } } } # Read file as base64 (for binary files) { "jsonrpc": "2.0", "id": 1, "method": "tools/call", "params": { "name": "read_file_code", "arguments": { "path": "media/logo.png", "encoding": "base64" } } } ``` ### Response #### Success Response (200) - **content** (array) - An array containing the file content. - **type** (string) - "text". - **text** (string) - The content of the file. #### Response Example ```json { "jsonrpc": "2.0", "id": 1, "result": { "content": [ { "type": "text", "text": "// Content of the file..." } ] } } ``` ``` ```APIDOC ## POST /mcp (tools/call - move_file_code) ### Description Moves a file or directory to a new location using VS Code's WorkspaceEdit API. This operation updates all imports and references to the moved file throughout the workspace. ### Method POST ### Endpoint `/mcp` ### Parameters #### Request Body - **jsonrpc** (string) - Required - "2.0" - **id** (integer) - Required - Request ID. - **method** (string) - Required - "tools/call" - **params** (object) - Required - **name** (string) - Required - "move_file_code" - **arguments** (object) - Required - **sourcePath** (string) - Required - The current path of the file or directory. - **targetPath** (string) - Required - The new path for the file or directory. - **overwrite** (boolean) - Optional - Whether to overwrite the target if it already exists. Defaults to false. ### Request Example ```json { "jsonrpc": "2.0", "id": 1, "method": "tools/call", "params": { "name": "move_file_code", "arguments": { "sourcePath": "src/utils/helper.ts", "targetPath": "src/lib/helper.ts", "overwrite": false } } } ``` ### Response #### Success Response (200) - **content** (array) - An array containing a text message indicating success. - **type** (string) - "text". - **text** (string) - A confirmation message. #### Response Example ```json { "jsonrpc": "2.0", "id": 1, "result": { "content": [ { "type": "text", "text": "Successfully moved src/utils/helper.ts to src/lib/helper.ts" } ] } } ``` ``` ```APIDOC ## POST /mcp (tools/call - rename_file_code) ### Description Renames a file or directory using VS Code's WorkspaceEdit API with automatic reference updates across the workspace. ### Method POST ### Endpoint `/mcp` ### Parameters #### Request Body - **jsonrpc** (string) - Required - "2.0" - **id** (integer) - Required - Request ID. - **method** (string) - Required - "tools/call" - **params** (object) - Required - **name** (string) - Required - "rename_file_code" - **arguments** (object) - Required - **filePath** (string) - Required - The path to the file or directory to rename. - **newName** (string) - Required - The new name for the file or directory. - **overwrite** (boolean) - Optional - Whether to overwrite the target if it already exists. Defaults to false. ### Request Example ```json { "jsonrpc": "2.0", "id": 1, "method": "tools/call", "params": { "name": "rename_file_code", "arguments": { "filePath": "src/utils/logger.ts", "newName": "logging.ts", "overwrite": false } } } ``` ### Response #### Success Response (200) - **content** (array) - An array containing a text message indicating success. - **type** (string) - "text". - **text** (string) - A confirmation message. #### Response Example ```json { "jsonrpc": "2.0", "id": 1, "result": { "content": [ { "type": "text", "text": "Successfully renamed src/utils/logger.ts to logging.ts" } ] } } ``` ``` -------------------------------- ### Check Specific File Diagnostics Source: https://context7.com/juehang/vscode-mcp-server/llms.txt Use this to retrieve code diagnostics for a specific file. You can filter by severities and choose the output format. The response format can be text or JSON. ```bash curl -X POST http://localhost:3000/mcp \ -H "Content-Type: application/json" \ -d '{ "jsonrpc": "2.0", "id": 1, "method": "tools/call", "params": { "name": "get_diagnostics_code", "arguments": { "path": "src/server.ts", "severities": [0, 1, 2], "format": "json" } } }' ``` ```json { "content": [ { "type": "text", "text": "[\"{\"file\": \"src/server.ts\", \"line\": 120, \"column\": 5, \"severity\": \"Warning\", \"message\": \"'result' is declared but never used\", \"source\": \"ts\"}]" } ] } ``` -------------------------------- ### Create File Code Source: https://context7.com/juehang/vscode-mcp-server/llms.txt Creates new files or completely rewrites existing files using VS Code's WorkspaceEdit API. Use this for new files, large modifications (>10 lines), or complete file rewrites. ```bash # Create a new file curl -X POST http://localhost:3000/mcp \ -H "Content-Type: application/json" \ -d '{ "jsonrpc": "2.0", "id": 1, "method": "tools/call", "params": { "name": "create_file_code", "arguments": { "path": "src/utils/constants.ts", "content": "export const API_VERSION = \"1.0.0\";\nexport const DEFAULT_PORT = 3000;\nexport const MAX_RETRIES = 3;", "overwrite": false, "ignoreIfExists": false } } }' ``` ```bash # Overwrite existing file curl -X POST http://localhost:3000/mcp \ -H "Content-Type: application/json" \ -d '{ "jsonrpc": "2.0", "id": 1, "method": "tools/call", "params": { "name": "create_file_code", "arguments": { "path": "src/config.ts", "content": "export default {\n port: 3000,\n host: \"127.0.0.1\"\n};", "overwrite": true } } }' ``` -------------------------------- ### Search Workspace Symbols Source: https://context7.com/juehang/vscode-mcp-server/llms.txt Searches for symbols (functions, classes, variables, interfaces) across the entire workspace using fuzzy matching. Supports partial search terms and returns location and container information. Specify the maximum number of results. ```bash curl -X POST http://localhost:3000/mcp \ -H "Content-Type: application/json" \ -d '{ "jsonrpc": "2.0", "id": 1, "method": "tools/call", "params": { "name": "search_symbols_code", "arguments": { "query": "create", "maxResults": 10 } } }' ``` ```json { "content": [ { "type": "text", "text": "Found 15 symbols matching query \"create\" (showing first 10):\n\ncreateWorkspaceFile (Function)\nLocation: src/tools/edit-tools.ts:14:0\n\ncreatFile (Function) in registerEditTools\nLocation: src/tools/edit-tools.ts:156:4\n\ncreateTerminal (Method) in vscode.window\nLocation: src/extension.ts:51:4\n" } ] } ``` -------------------------------- ### Move File or Directory using MCP Source: https://context7.com/juehang/vscode-mcp-server/llms.txt Use the `move_file_code` tool to relocate files or directories within the workspace. This operation automatically updates all references across the project. ```bash curl -X POST http://localhost:3000/mcp \ -H "Content-Type: application/json" \ -d '{ "jsonrpc": "2.0", "id": 1, "method": "tools/call", "params": { "name": "move_file_code", "arguments": { "sourcePath": "src/utils/helper.ts", "targetPath": "src/lib/helper.ts", "overwrite": false } } }' # Response { "content": [ { "type": "text", "text": "Successfully moved src/utils/helper.ts to src/lib/helper.ts" } ] } ``` -------------------------------- ### VS Code Symbol Tools for Context Efficiency in Claude Source: https://github.com/juehang/vscode-mcp-server/blob/master/README.md Enhance context efficiency in Claude by utilizing VS Code symbol tools for exploring codebases. This approach reduces context consumption by focusing on file structure, symbol searching, and definitions. ```plaintext ## VS Code Symbol Tools for Context Efficiency Use VS Code symbol tools to reduce context consumption: - `get_document_symbols_code` for file structure overview instead of reading entire files - `search_symbols_code` to find symbols by name across the project - `get_symbol_definition_code` for type info and docs without full file context - Workflow: get outline → search symbols → get definitions → read implementation only when needed ``` -------------------------------- ### Edit Tools API Source: https://github.com/juehang/vscode-mcp-server/blob/master/README.md APIs for creating new files, replacing lines in existing files, and performing other editing operations. ```APIDOC ## create_file_code ### Description Creates a new file using VS Code's WorkspaceEdit API. ### Method POST ### Endpoint /juehang/vscode-mcp-server/create_file_code ### Parameters #### Query Parameters - **path** (string) - Required - The path to the file to create - **content** (string) - Required - The content to write to the file - **overwrite** (boolean) - Optional - Whether to overwrite if the file exists (default: false) - **ignoreIfExists** (boolean) - Optional - Whether to ignore if the file exists (default: false) ### Request Example { "path": "/src/new_file.js", "content": "console.log(\"Hello, MCP!\");", "overwrite": false, "ignoreIfExists": false } ## replace_lines_code ### Description Replaces specific lines in a file. ### Method POST ### Endpoint /juehang/vscode-mcp-server/replace_lines_code ### Parameters #### Query Parameters - **path** (string) - Required - The path to the file to modify - **startLine** (integer) - Required - The start line number (1-based, inclusive) - **endLine** (integer) - Required - The end line number (1-based, inclusive) - **content** (string) - Required - The new content to replace the lines with - **originalCode** (string) - Required - The original code for validation ### Request Example { "path": "/src/file.js", "startLine": 5, "endLine": 10, "content": "// New content for lines 5-10", "originalCode": "// Original content..." } ``` -------------------------------- ### Symbol Tools API Source: https://github.com/juehang/vscode-mcp-server/blob/master/README.md API endpoints for interacting with symbols within the VS Code workspace. ```APIDOC ## POST /search_symbols_code ### Description Searches for symbols across the workspace based on a query. ### Method POST ### Endpoint /search_symbols_code ### Parameters #### Request Body - **query** (string) - Required - The search query for symbol names - **maxResults** (integer) - Optional - Maximum number of results to return (default: 10) ### Request Example ```json { "query": "MyClass", "maxResults": 20 } ``` ### Response #### Success Response (200) - **symbols** (array) - A list of found symbols, each with properties like name, kind, location, etc. #### Response Example ```json { "symbols": [ { "name": "MyClass", "kind": "Class", "location": { "uri": "file:///path/to/file.js", "range": { "start": {"line": 10, "character": 0}, "end": {"line": 20, "character": 1} } } } ] } ``` ``` ```APIDOC ## POST /get_symbol_definition_code ### Description Gets definition information for a specific symbol in a given file. ### Method POST ### Endpoint /get_symbol_definition_code ### Parameters #### Request Body - **path** (string) - Required - The path to the file containing the symbol - **line** (integer) - Required - The line number of the symbol - **symbol** (string) - Required - The symbol name to look for on the specified line ### Request Example ```json { "path": "src/utils.js", "line": 15, "symbol": "helperFunction" } ``` ### Response #### Success Response (200) - **definition** (object) - Contains details about the symbol's definition, including type, documentation, and source location. #### Response Example ```json { "definition": { "type": "Function", "documentation": "A helper function to perform calculations.", "range": { "start": {"line": 12, "character": 0}, "end": {"line": 18, "character": 1} }, "source": "function helperFunction(a, b) { return a + b; }" } } ``` ``` ```APIDOC ## POST /get_document_symbols_code ### Description Retrieves an outline of all symbols within a specified file, showing their hierarchical structure. ### Method POST ### Endpoint /get_document_symbols_code ### Parameters #### Request Body - **path** (string) - Required - The path to the file to analyze (relative to workspace) - **maxDepth** (integer) - Optional - Maximum nesting depth to display for symbols (default: unlimited) ### Request Example ```json { "path": "src/main.js", "maxDepth": 3 } ``` ### Response #### Success Response (200) - **symbols** (array) - A hierarchical list of symbols found in the document, including their kind, range, and children. #### Response Example ```json { "symbols": [ { "name": "MyClass", "kind": "Class", "range": {"start": {"line": 5, "character": 0}, "end": {"line": 50, "character": 1}}, "children": [ { "name": "constructor", "kind": "Method", "range": {"start": {"line": 6, "character": 2}, "end": {"line": 10, "character": 3}} } ] } ] } ``` ``` -------------------------------- ### MCP Server API Endpoints Source: https://context7.com/juehang/vscode-mcp-server/llms.txt The VS Code MCP Server extension exposes a local HTTP server that handles MCP protocol requests. All requests are made to the `/mcp` endpoint using the POST method with a JSON-RPC 2.0 payload. ```APIDOC ## POST /mcp ### Description This is the main endpoint for interacting with the VS Code MCP Server. All MCP protocol requests are sent to this endpoint. ### Method POST ### Endpoint `/mcp` ### Request Body - **jsonrpc** (string) - Required - The JSON-RPC version, must be "2.0". - **id** (integer) - Required - The request ID. - **method** (string) - Required - The MCP method to call (e.g., "tools/call"). - **params** (object) - Required - The parameters for the method call. - **name** (string) - Required - The name of the tool or method to execute. - **arguments** (object) - Optional - The arguments for the specified method. ### Request Example ```json { "jsonrpc": "2.0", "id": 1, "method": "tools/call", "params": { "name": "list_files_code", "arguments": { "path": ".", "recursive": false } } } ``` ### Response #### Success Response (200) - **jsonrpc** (string) - The JSON-RPC version, will be "2.0". - **id** (integer) - The request ID. - **result** (object) - The result of the method call. - **content** (array) - The content of the result, typically an array of objects. - **type** (string) - The type of content (e.g., "text"). - **text** (string) - The actual content. #### Response Example ```json { "jsonrpc": "2.0", "id": 1, "result": { "content": [ { "type": "text", "text": "[{"path": "src", "type": "directory"}, {"path": "package.json", "type": "file"}, {"path": "README.md", "type": "file"}]" } ] } } ``` ``` -------------------------------- ### Replace Lines Code Source: https://context7.com/juehang/vscode-mcp-server/llms.txt Replaces specific lines in existing files with exact content validation. Use this for small modifications (≤10 lines) where you have the exact original text. The `originalCode` parameter must match the current file content exactly or the operation fails. ```bash curl -X POST http://localhost:3000/mcp \ -H "Content-Type: application/json" \ -d '{ "jsonrpc": "2.0", "id": 1, "method": "tools/call", "params": { "name": "replace_lines_code", "arguments": { "path": "src/server.ts", "startLine": 37, "endLine": 38, "content": " constructor(port: number = 4000, host: string = \"0.0.0.0\", terminal?: vscode.Terminal, toolConfig?: ToolConfiguration) {\n this.port = port;", "originalCode": " constructor(port: number = 3000, host: string = '127.0.0.1', terminal?: vscode.Terminal, toolConfig?: ToolConfiguration) {\n this.port = port;" } } }' ``` -------------------------------- ### Copy File Code Source: https://context7.com/juehang/vscode-mcp-server/llms.txt Copies a file to a new location. This operation only works for files, not directories. It is useful for creating backups or template files. ```bash curl -X POST http://localhost:3000/mcp \ -H "Content-Type: application/json" \ -d '{ "jsonrpc": "2.0", "id": 1, "method": "tools/call", "params": { "name": "copy_file_code", "arguments": { "sourcePath": "src/server.ts", "targetPath": "src/server.backup.ts", "overwrite": false } } }' ``` -------------------------------- ### Search Symbols in Workspace Source: https://github.com/juehang/vscode-mcp-server/blob/master/README.md Searches for symbols across the entire workspace. Useful for finding definitions of functions, classes, and variables. ```typescript search_symbols_code(query: string, maxResults?: number): Promise ``` -------------------------------- ### Shell Tools API Source: https://github.com/juehang/vscode-mcp-server/blob/master/README.md API endpoint for executing shell commands within the VS Code integrated terminal. ```APIDOC ## POST /execute_shell_command_code ### Description Executes a shell command in the VS Code integrated terminal with shell integration enabled. ### Method POST ### Endpoint /execute_shell_command_code ### Parameters #### Request Body - **command** (string) - Required - The shell command to execute - **cwd** (string) - Optional - The working directory for the command (default: '.') ### Request Example ```json { "command": "npm install", "cwd": "/app/project" } ``` ### Response #### Success Response (200) - **output** (string) - The standard output from the executed command. - **error** (string) - Any error output from the executed command. - **exitCode** (integer) - The exit code of the command. #### Response Example ```json { "output": "Package installed successfully.", "error": null, "exitCode": 0 } ``` ``` -------------------------------- ### Execute Shell Command Source: https://github.com/juehang/vscode-mcp-server/blob/master/README.md Executes a shell command in the VS Code integrated terminal. Supports specifying a working directory. ```typescript execute_shell_command_code(command: string, cwd?: string): Promise ```