Skip to main content
Glama

language-server-mcp MCP 服务器

模型上下文协议 (MCP) 服务器为代码编辑提供语言支持。

这是一个基于 TypeScript 的 MCP 服务器,旨在通过提供悬停信息、代码补全和诊断等功能来增强代码编辑体验。它通过提供以下功能演示了核心 MCP 概念:

  • 用于代码分析和操作的特定语言工具

  • 与模型上下文协议集成,实现无缝通信

特征

语言支持

  • 提供代码中符号的悬停信息

  • 提供代码完成建议

  • 报告诊断信息(错误、警告)

  • 仅使用 TypeScript 测试,理论上应该支持 Python。如果可能的话,希望能添加其他语言服务器,或者提供更多语言无关性。

MCP 集成

  • 实现 MCP 协议与客户端通信

  • 将语言特性公开为 MCP 工具

工具

  • get_hover :获取文档中某个位置的悬停信息

    • 将 languageId、filePath、内容、行和字符作为必需参数

  • get_completions :获取文档中某个位置的完成建议

    • 将 languageId、filePath、content、line 和 character 作为必需参数

  • get_diagnostics :获取文档的诊断信息

    • 将 languageId、filePath 和 content 作为必需参数

Related MCP server: VSCode LSP MCP Server

发展

安装依赖项:

npm install

构建服务器:

npm run build

对于使用自动重建的开发:

npm run watch

安装

要与 Claude Desktop 一起使用,请添加服务器配置:

在 MacOS 上: ~/Library/Application Support/Claude/claude_desktop_config.json在 Windows 上: %APPDATA%/Claude/claude_desktop_config.json

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

调试

由于 MCP 服务器通过 stdio 进行通信,调试起来可能比较困难。我们推荐使用MCP Inspector ,它以包脚本的形式提供:

npm run inspector

检查器将提供一个 URL 来访问浏览器中的调试工具。

Available Tools

3 tools
get_completionsC

Get completion suggestions for a position in a document

Inputs: character (required), content (required), filePath (required), languageId (required), +2 more.

get_diagnosticsC

Get diagnostic information for a document

Inputs: content (required), filePath (required), languageId (required), projectRoot (required).

get_hoverC

Get hover information for a position in a document

Inputs: character (required), content (required), filePath (required), languageId (required), +2 more.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    B3.2/5.0

    Scored across 3 tools

    Disambiguation5/5

    Each tool has a clearly distinct purpose: get_completions provides suggestions, get_diagnostics provides error/warning information, and get_hover provides documentation. There is no overlap or ambiguity between these three core language server operations.

    Naming Consistency5/5

    All tools follow a consistent verb_noun pattern with 'get_' prefix and descriptive nouns (completions, diagnostics, hover). The naming is perfectly uniform and predictable throughout the set.

    Tool Count3/5

    With only 3 tools, the server feels somewhat thin for a language server domain. While these cover fundamental operations, typical language servers would include more capabilities like formatting, references, definitions, or rename operations. The count is borderline minimal.

    Completeness2/5

    The tool surface is significantly incomplete for a language server. Missing are essential operations like formatting, finding references, getting definitions, renaming symbols, and code actions. Agents will encounter dead ends when trying to perform common language server tasks beyond the three provided.

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      D
      maintenance
      A lightweight MCP server that provides 40 tools for TypeScript/JavaScript refactoring and code intelligence, directly mapping to TypeScript's tsserver protocol commands for accurate structural changes and workspace analysis.
      40
      29 npm
      3
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      A standalone MCP server that provides TypeScript type inference and hover information using tsgo, enabling AI agents to get type details, diagnostics, references, and more without needing an editor.
      1
      MIT