VSCode MCP Python Server
A production-ready MCP server that enables Claude to interact with local codebases through file operations, code analysis, and VSCode integration tools. It optimizes performance using LRU caching and asynchronous execution while maintaining local data privacy.
README
MCP Server - Model Context Protocol Server
A production-ready MCP (Model Context Protocol) server for VSCode and Claude integration with comprehensive tool support, performance monitoring, and diagnostics.
Version
Current Version: 1.0.0
Release Date: January 13, 2026
Status: Development
Features
⚡ Technical Optimizations
- Reduced Token Overhead: Instead of pasting large datasets into the chat, the MCP server allows Claude to query only the specific data it needs. This results in faster responses and lower cost/token usage.
- Asynchronous Execution: By leveraging Python’s asynchronous capabilities, the server can handle multiple data requests simultaneously without freezing the interaction.
- Custom Tool Mapping: You can wrap complex Python libraries (like
pandas,beautifulsoup, oros) into simple tools that Claude can call instantly.
🌟 Value Added to Projects
- Bridging the Gap: It turns Claude from a "chatbot" into a "developer agent" that can actually see and modify your local code or databases.
- Workflow Automation: You can automate repetitive tasks like log analysis, local file reorganization, or database querying simply by talking to Claude.
- Private Data Context: Since the server runs locally, you can provide Claude with context from private documents or internal company data without ever uploading those files to the cloud.
Core Capabilities
- 10 Professional Process - Complete file operations, code analysis, and VSCode integration
- LRU Caching - Intelligent request caching for 2-3x performance improvement
- Type Safety - 100% type hints (PEP 484 compliant)
- Enterprise Architecture - SOLID principles, design patterns, professional structure
- Comprehensive Logging - Structured logging to stderr for debugging
- Error Handling - Production-grade error handling with specific exceptions
Installation
Prerequisites
- Python 3.8 or higher
- VSCode (optional, for VSCode integration features)
- Windows, Linux, or macOS
Setup
-
Clone or download this repository
-
Ensure all files are in the same directory:
mcp_server.py- Main servertools.py- Tool implementationsvscode_detector.py- VSCode integrationdiagnostics.py- Health checksperformance_monitor.py- Performance trackinglanguages.json- Language configuration
-
Configure your Artifical intelligence Desktop(for claude) to use this server (see Configuration section)
Quick Start
# Test server compilation
python -m py_compile mcp_server.py
# Run diagnostics
python diagnostics.py
# Start server (usually called by Claude)
python mcp_server.py
Configuration
Add to your Claude Desktop config file:
Windows
%APPDATA%\Claude\claude_desktop_config.json
macOS
~/Library/Application Support/Claude/claude_desktop_config.json
Configuration Example
{
"mcpServers": {
"vscode-mcp": {
"command": "python",
"args": ["C:\\path\\to\\mcp_server.py"]
}
}
}
Usage Examples
Reading Files
User: "Read the contents of mcp_server.py"
Claude: Uses read_file tool
Result: File contents displayed
Code Analysis
User: "Analyze the code in tools.py"
Claude: Uses analyze_code tool
Result: Functions, classes, and imports listed with line numbers
Writing Code
User: "Write a Python calculator"
Claude: Uses write_code_to_project tool
System: Permission prompt appears
User: Approves
Result: calculator.py created with detailed feedback
Modifying Code
User: "In calculator.py, add error handling to the divide function"
Claude: Uses change_code tool
System: Permission prompt appears
User: Approves
Result: Function updated with before/after preview
Project Overview
User: "Show me the project structure"
Claude: Uses get_project_structure tool
Result: Files organized by programming language
Architecture
Main Components
MCPServer Class
- Protocol handler implementing MCP 2024-11-05
- JSON-RPC 2.0 communication
- Async/await patterns
- Request/response management
ToolRegistry Class
- Tool registration and management
- Input schema validation
- Tool invocation
RequestCache Class
- LRU caching mechanism
- Configurable cache size
- Automatic eviction
LanguageConfig Class
- Language configuration management
- Pattern matching for code analysis
- File extension handling
Design Patterns
- Registry Pattern - Tool management
- Cache Pattern - Request caching
- Dataclass Pattern - Type-safe metadata
- Dependency Injection - Configuration management
- Strategy Pattern - Tool execution
Performance
Optimization Features
- LRU cache for safe tool requests
- Async/await for non-blocking operations
- Efficient file system scanning
- Smart VSCode process detection
- Minimal memory footprint
Performance Metrics
| Metric | Value |
|---|---|
| Startup Time | < 1 second |
| Tool Execution | 10-100ms (cached: <1ms) |
| Memory Usage | ~50MB |
| Cache Hit Rate | 70-90% |
Diagnostics
Health Checks
Run comprehensive diagnostics:
# Full diagnostic suite
python diagnostics.py
# Quick check
python diagnostics.py --mode quick
# Health status (JSON)
python diagnostics.py --mode health
Diagnostic Tests
- Python version compatibility
- Required files existence
- File permissions
- Configuration validity
- Module imports
- Syntax checking
- Disk space
- Memory usage
- VSCode status
- Network connectivity
Development
Code Quality Standards
- PEP 8 - Style guide compliance
- PEP 257 - Docstring conventions
- PEP 484 - Type annotations
- Google Style - Docstring format
Testing
# Syntax check all files
python -m py_compile *.py
# Run diagnostics
python diagnostics.py
# Test tool imports
python -c "import tools; import mcp_server"
Troubleshooting
Common Issues
Server Won't Start
- Check Python version:
python --version(must be 3.8+) - Run diagnostics:
python diagnostics.py - Check syntax:
python -m py_compile mcp_server.py
Tools Not Working
- Verify file permissions
- Check languages.json is valid JSON
- Run import test:
python -c "import tools"
VSCode Detection Fails
- Ensure VSCode is running
- Check process permissions (Windows)
- Verify workspace directory is accessible
Permission Errors
- Run as administrator (if needed)
- Check file/directory permissions
- Verify paths in configuration
Code Contribution Guidelines
- Follow PEP 8 style guide
- Add type hints to all functions
- Write comprehensive docstrings
- Include error handling
- Add tests for new features
- Update README for new tools
Adding New Tools
- Implement tool function in
tools.py - Add tool definition in
mcp_server.pyTOOL_DEFINITIONS - Register tool in
main()function - Update README documentation
- Add diagnostic checks if needed
License
MIT License - See LICENSE file for details
Support
Documentation
- Full API reference in code docstrings
- Usage examples in this README
- Diagnostic tools for troubleshooting
Getting Help
- Run diagnostics:
python diagnostics.py - Check logs in stderr output
- Review error messages carefully
- Verify configuration files
Credits
Author: Kommandant
Version: 1.0.0
License: MIT
Status: Development
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。