JL

jonrad/lsp-mcp

开发工具

本页由 AI 翻译,技术细节请以原文为准。 查看原文

192 stars 29 forks 质量 67 趋势 17MIT

jonrad/lsp-mcp 是从 https://github.com/jonrad/lsp-mcp. 导入的 MCP 服务器候选

概览

jonrad/lsp-mcp 是从 https://github.com/jonrad/lsp-mcp. 导入的 MCP 服务器候选

概述(AI 翻译)

一个模型上下文协议(MCP)服务器,为LLMs/AI代理提供语言服务器协议(LSP)服务器的能力。这使AI能够从代码库中获取语言感知上下文。

  • LSP MCP
  • 示例
  • 警告
  • 特色
  • 快速入门
  • Claude桌面
  • 使用 Docker (推荐)
  • 使用 npx
  • 光标
  • MCP CLI 客户端
  • ABC(导言)
  • 什么是MCP?
  • 什么是LSP?
  • 发展
  • 依赖关系
  • 判决
  • 路线图
  • 参考文献

示例

输入:

输出:

警告

这是在有色人种州。

特色

  • 同时支持多个LSP(多编程语言支持),详见示例配置
  • 从LSP JSON模式动态生成支持的LSP方法,详见json模式

快速启动

克劳德桌面

使用 Docker (推荐)

修改claude_desktop_config.json(如MCP文档所述),包含以下内容:

你可能需要通过通过传递 docker -v /local_dir:/remote_dir 来与容器共享一些文件。然后你可以向 Claude 询问 /remote_dir/ 里的文件。

使用 NPX

注意:Claude Desktop 似乎对 NPX 很挑剔。

本页由 AI 翻译,技术细节请以原文为准。

README

以下为原文 README 节选,完整内容请查看原文。

LSP MCP

An Model Context Protocol (MCP) server that provides LLMs/AI Agents with the capabilities of a language server protocol (LSP) server. This gives the AI the ability to get language aware context from the codebase.

Example

Input:

Use lsp to give me insights into the following typescript code:

let foo = "bar";
function x() {
  let foo = 123;
  console.log(foo);
}
x();
console.log(foo);

Output:

I'll use LSP (Language Server Protocol) to analyze your TypeScript code. Let me break down what's happening:
Here's what the code does and the insights from LSP analysis:

1. Variable Shadowing:

There are two variables named foo:

A global foo (string type) initialized with the value "bar"
A local foo (number type) inside the function x() initialized with the value 123

2. Execution Flow:

First, the global foo is declared and assigned the value "bar"
When function x() is called, the local foo variable is declared and assigned 123
The console.log(foo) inside the function outputs 123 (the local variable)
After the function finishes, console.log(foo) outputs "bar" (the global variable)

3. Scope Isolation:

The LSP confirms that TypeScript correctly identifies the different types:

The global foo is a string type
The local foo inside the function is a number type

Changes to the local foo don't affect the global foo

This is a classic example of variable shadowing in JavaScript/TypeScript, where a local variable with the same name as a global variable takes precedence within its scope.

Warning

This is in a POC state.

Features

  • Multiple LSPs (Multiple programming language support) at the same time, see sample config
  • Dynamically generates supported LSP method from LSP JSON Schema, see json schema

Quick Start

Claude Desktop

Modify claude_desktop_config.json (As described in the MCP Docs) with the following:

{
  "mcpServers": {
    "lsp": {
      "command": "docker",
      "args": ["run", "-i", "--rm", "docker.io/jonrad/lsp-mcp:0.3.1"]
    }
  }
}
在 GitHub 查看完整 README

安装

docker run -i --rm docker.io/jonrad/lsp-mcp:0.3.1
新手?先看 mcpskill.org 教程 →

配置

{ "mcpServers": { "lsp": { "command": "docker", "args": ["run", "-i", "--rm", "docker.io/jonrad/lsp-mcp:0.3.1"] } } }