MCP HubMCP Hub
alexwohletz

language-server-mcp

by: alexwohletz

language server mcp

17created 17/12/2024
Visit
language

📌Overview

Purpose: This framework aims to enhance the code editing experience by providing comprehensive language support and functionality through a Model Context Protocol (MCP) server.

Overview: The language-server-mcp is a TypeScript-based server designed to leverage the Model Context Protocol, facilitating seamless tools for code analysis, completion, and diagnostics. It serves as a model of MCP concepts while targeting primarily TypeScript, with potential for expansion to other languages like Python.

Key Features:

  • Language Support: Offers hover information, code completion suggestions, and diagnostic reporting to improve the coding workflow.

  • MCP Integration: Implements the MCP protocol for effective communication with clients, exposing various language features as MCP tools.

  • Tools: Provides specific functions like get_hover, get_completions, and get_diagnostics that retrieve relevant information based on the language and document position.


language-server-mcp MCP Server

A Model Context Protocol (MCP) server providing language support for code editing.

This TypeScript-based MCP server enhances code editing by providing features such as hover information, code completion, and diagnostics. It demonstrates core MCP concepts by offering:

  • Language-specific tools for code analysis and manipulation
  • Integration with the Model Context Protocol for seamless communication

Features

Language Support

  • Provides hover information for symbols in code
  • Offers code completion suggestions
  • Reports diagnostic information (errors, warnings)
  • Currently tested with TypeScript; theoretically supports Python. Expansion to additional languages is desired.

MCP Integration

  • Implements the MCP protocol for communication with clients
  • Exposes language features as MCP tools

Tools

  • get_hover: Get hover information for a position in a document
    Parameters: languageId, filePath, content, line, character
  • get_completions: Get completion suggestions for a position in a document
    Parameters: languageId, filePath, content, line, character
  • get_diagnostics: Get diagnostic information for a document
    Parameters: languageId, filePath, content

Development

Install dependencies:

npm install

Build the server:

npm run build

For development with auto-rebuild:

npm run watch

Installation

To use with Claude Desktop, add the server config:

  • On MacOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • On Windows: %APPDATA%/Claude/claude_desktop_config.json

Example configuration:

{
  "mcpServers": {
    "language-server-mcp": {
      "command": "/path/to/language-server-mcp/build/index.js"
    }
  }
}

Debugging

Since MCP servers communicate over stdio, debugging can be challenging. It is recommended to use the MCP Inspector, available as a package script:

npm run inspector

The Inspector will provide a URL to access debugging tools in your browser.