A VS Code extension that creates an MCP (Model Context Protocol) server to expose VS Code Language Model tools over HTTP, enabling external applications to access and utilize VS Code's built-in LM tools.
This extension provides the following functionality:
- MCP Server: Creates a Model Context Protocol server that runs on
http://localhost:22333 - VS Code LM Tools Integration: Automatically discovers and exposes all registered VS Code Language Model tools
- HTTP API: Provides a REST-like interface for external applications to interact with VS Code LM tools
- Tool Discovery: Lists all available VS Code LM tools with their descriptions and input schemas
- Tool Invocation: Attempts to invoke VS Code LM tools (with limitations outside chat context)
- Install and activate the extension
- The MCP server will automatically start on port 22333 when the extension activates
- You'll see a notification: "MCP Server started on port 22333"
The server exposes the following MCP protocol endpoints:
- Initialize:
POST http://localhost:22333with{"method": "initialize", ...} - List Tools:
POST http://localhost:22333with{"method": "tools/list", ...} - Call Tool:
POST http://localhost:22333with{"method": "tools/call", ...} - Ping:
POST http://localhost:22333with{"method": "ping", ...}
- VS Code version 1.102.0 or higher
- Node.js and npm for development
- Network access to localhost port 22333
The extension implements a subset of the Model Context Protocol (MCP) v2024-11-05:
- Server Info:
vscode-lm-tools-mcp-serverv1.0.0 - Capabilities: Supports tools discovery and invocation
- Transport: HTTP with JSON-RPC 2.0 format
- CORS: Enabled for cross-origin requests
- Automatically discovers all registered
vscode.lm.tools - Normalizes tool input schemas to ensure MCP compatibility
- Handles tool invocation with proper error handling
- Provides detailed tool information when direct invocation fails
- Tool invocation requires a
toolInvocationTokenwhich is only available in chat contexts - Outside of chat contexts, the server returns tool metadata instead of execution results
- Some VS Code LM tools may not be accessible depending on the current workspace and context
This extension does not currently contribute any VS Code settings.
- Direct tool invocation may fail outside of VS Code chat contexts due to
toolInvocationTokenrequirements - Tool availability depends on other installed extensions and workspace configuration
- Server runs on a fixed port (22333) which may conflict with other applications
Initial release featuring:
- MCP server implementation with HTTP transport
- VS Code LM tools discovery and exposure
- Basic tool invocation with fallback to metadata
npm install
npm run compilenpm testnpm run packageTo connect to this MCP server from an MCP client, add the following configuration to your mcp.json file:
{
"servers": {
"vscode": {
"type": "streamable-http",
"url": "http://localhost:22333"
}
}
}{
"servers": {
"vscode": {
"type": "http",
"url": "http://localhost:22333"
}
}
}- Ensure this VS Code extension is installed and active
- The MCP server will automatically start on port 22333
- Your MCP client should be configured to connect to the above URL
Once connected, your MCP client will have access to:
- Tool Discovery: Automatically list all VS Code LM tools
- Tool Invocation: Execute VS Code LM tools (with context limitations)
- Schema Information: Access input schemas for each tool
@modelcontextprotocol/sdk: Core MCP SDK for server implementation- VS Code API: For accessing Language Model tools and extension functionality
This extension follows VS Code extension development best practices:
See the LICENSE file for details.