LSP-MCP
lsp-mcp
最完整的语言智能 MCP 服务器。包含 22 个工具,涵盖导航、诊断、重构和格式化。在 7 种语言中通过了 CI 验证。直接基于 LSP 3.17 规范构建。
与典型的 MCP-LSP 桥接器不同,lsp-mcp 维护一个持久的语言服务器会话——代理在完全索引的工作区上运行,具有实时诊断和跨文件感知能力,而不是在调用之间丢失上下文的冷启动存根。
为什么选择 lsp-mcp
lsp-mcp | 典型替代方案 | |
语言 (CI 验证) | 7 | 1–2 |
工具 | 22 | 3–5 |
LSP 规范合规性 | 3.17,按规范构建 | 特设 |
连接模型 | 持久 | 按请求 |
跨文件引用 | ✓ | 很少 |
实时诊断订阅 | ✓ | ✗ |
测试覆盖率 | 76% 语句, 86% 函数 | 很少测试 |
Related MCP server: LSP MCP
快速入门
{
"mcpServers": {
"lsp": {
"type": "stdio",
"command": "npx",
"args": ["blackwell-systems/LSP-MCP", "<language-id>", "<path-to-lsp-binary>", "<lsp-args>"]
}
}
}TypeScript:
{ "args": ["blackwell-systems/LSP-MCP", "typescript", "typescript-language-server", "--stdio"] }Go:
{ "args": ["blackwell-systems/LSP-MCP", "go", "gopls"] }Rust:
{ "args": ["blackwell-systems/LSP-MCP", "rust", "rust-analyzer"] }多语言支持
以下每种语言都在每次 CI 运行中进行集成测试——start_lsp、open_document、get_diagnostics 和 get_info_on_location 均已针对真实的语言服务器二进制文件进行了验证:
语言 | 服务器 | 安装 |
TypeScript / JavaScript |
|
|
Python |
|
|
Go |
|
|
Rust |
|
|
Java |
| |
C / C++ |
|
|
PHP |
|
|
工具
所有工具都需要先调用 start_lsp。
会话
工具 | 描述 |
| 使用项目根目录启动语言服务器 |
| 重启而不重启 MCP 服务器 |
| 打开文件进行跟踪(位置查询前必需) |
| 停止跟踪文件 |
分析
工具 | 描述 |
| 错误和警告——省略 |
| 位置悬停信息(类型签名、文档) |
| 位置补全建议 |
| 调用处的函数签名和活动参数 |
| 范围内的快速修复和重构 |
| 文件中的所有符号(函数、类、变量) |
| 在工作区中按名称搜索符号 |
导航
工具 | 描述 |
| 工作区中符号的所有引用 |
| 跳转到符号定义处 |
| 跳转到符号的类型定义处 |
| 跳转到接口或抽象方法的所有实现 |
| 跳转到符号的声明处(与定义不同——例如 C/C++ 头文件) |
重构
工具 | 描述 |
| 获取用于在工作区重命名符号的 |
| 在提交前验证重命名是否可行 |
| 获取文件的 |
| 将 |
| 执行服务器端命令(例如来自代码操作) |
实用工具
工具 | 描述 |
| 在运行时更改日志详细程度 |
推荐的代理工作流:
start_lsp(root_dir="/your/project")
open_document(file_path=..., language_id=...)
get_diagnostics() # whole project, no file_path
get_info_on_location(...) / get_references(...)
close_document(...)语言 ID: typescript, typescriptreact, javascript, javascriptreact, python, go, rust, java, c, cpp, php
资源
诊断资源支持实时订阅——当诊断发生变化时,服务器会发送 notifications/resources/updated。
方案 | 描述 |
| 所有打开的文件 |
| 特定文件(可订阅) |
| 位置悬停 |
| 位置补全 |
LSP 3.17 合规性
lsp-mcp 直接针对 LSP 3.17 规范实现,并通过针对真实语言服务器的集成测试进行验证。覆盖范围包括:
完整的生命周期(
initialize→initialized→shutdown),具有优雅的 SIGINT/SIGTERM 处理进度协议——工作区就绪检测在发送引用前会等待所有
$/progress令牌完成服务器发起的请求(
workspace/configuration,window/workDoneProgress/create, 动态注册)——全部正确响应,解除对这些响应有依赖的服务器加载阻塞正确的 JSON-RPC 帧、错误代码处理以及跨悬停、补全、代码操作和诊断的响应形状标准化
请参阅 docs/lsp-conformance.md 获取完整的方法覆盖矩阵和规范章节参考。
扩展
特定语言的扩展添加了工具、提示词和资源处理程序,在启动时按语言 ID 自动加载。
要添加扩展,请创建 src/extensions/<language-id>.ts 并实现 getToolHandlers、getToolDefinitions、getResourceHandlers、getSubscriptionHandlers、getPromptDefinitions 和 getPromptHandlers 的任意子集。所有功能均按语言 ID 命名空间划分。
开发
git clone https://github.com/blackwell-systems/LSP-MCP.git
cd LSP-MCP && npm install && npm run build
npm test # all unit test suites
npm run test:multi-lang # 7-language integration test (requires language servers)覆盖率:约 76% 语句,约 86% 函数。要检查 MCP 流量:claude --mcp-debug。
许可证
MIT
This server cannot be deployed
Maintenance
Related MCP Connectors
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
A Model Context Protocol server for Wix AI tools
Enable secure connectivity between Sentry issues and debugging data, and LLM clients, using a Model Context Protocol (MCP) server.
Codebase graphs, caller impact analysis, and recorded project context for AI coding agents.
Related MCP Servers
- AlicenseNot gradedqualityAmaintenanceProvides LLMs with code intelligence tools like relationship explanation, PR impact analysis, and health reports via the Model Context Protocol.3MIT
- AlicenseNot gradedqualityDmaintenanceProvides AI agents with language-aware code analysis through the Language Server Protocol, enabling tasks like getting code insights and diagnostics.6 npm191MIT
- AlicenseNot gradedqualityDmaintenanceExposes Language Server Protocol (LSP) functionality as Model Context Protocol (MCP) tools, enabling AI clients to programmatically analyze and edit code in any language supported by VS Code.5 npm33MIT
- AlicenseAqualityFmaintenanceProvides C++ code intelligence tools for AI agents via the Model Context Protocol, enabling symbol navigation, type information, and diagnostics.948Mozilla Public 2.0