MCP HubMCP Hub
jonrad

lsp-mcp

by: jonrad

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.

29created 23/02/2025
Visit
LLM
LSP

📌Overview

Purpose: The LSP MCP framework serves as a Model Context Protocol server that equips language models (LLMs) and AI agents with integrated capabilities from the Language Server Protocol (LSP), enabling access to language-aware context from codebases.

Overview: LSP MCP is designed to enhance AI interactions with code through the LSP, allowing for sophisticated understanding and analysis of various programming languages. It supports multiple LSP instances simultaneously, thus broadening the scope of AI capabilities in multi-language environments.

Key Features:

  • Multiple LSP Support: Enables simultaneous interaction with various programming languages, enhancing flexibility and usability for developers working in multi-language projects.

  • Dynamic LSP Method Generation: Automatically generates supported LSP methods using the LSP JSON Schema, streamlining the integration process and ensuring compatibility with various language servers.


LSP MCP

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

Table of Contents

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 to analyze your TypeScript code.

Key Insights:

  1. Variable Shadowing: There are two variables named foo (a global string and a local number).
  2. Execution Flow: The global foo outputs "bar", while the local foo outputs 123.
  3. Scope Isolation: Changes to local foo don't affect the global foo.

Warning

This is in a POC state.

Features

  • Multiple LSP support for different programming languages.
  • Dynamically generated supported LSP methods from LSP JSON Schema.

Quick Start

Claude Desktop

Using Docker (Recommended)

Modify claude_desktop_config.json as follows:

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

Using npx

Note: Claude Desktop may have issues with npx.

{
  "mcpServers": {
    "lsp": {
      "command": "npx",
      "args": ["-y", "--silent", "git+https://github.com/jonrad/lsp-mcp", "--lsp", "npx -y --silent -p 'typescript@5.7.3' -p 'typescript-language-server@4.3.3' typescript-language-server --stdio"]
    }
  }
}

Cursor

Follow the instructions provided by Cursor.

MCP CLI Client

Follow the instructions for Claude but use the config file located in ~/.llm/config.json.

The ABCs (Introduction)

What is an MCP?

What is an LSP?

Development

yarn
yarn mcp-cli # Interactive MCP tool to help with development
yarn dev --help # Get the CLI help

Dependencies

Decisions

  • Switching to Node for better LSP support and ease of use.
  • Using the low-level MCP SDK for more control.
  • Implementing config validation with Zod.

Roadmap

  • Sync capabilities between LSP client and server.
  • Auto-generate LSP JSON Schema.
  • Create a proper release process.

References