Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
NotificationsYou must be signed in to change notification settings

mizchi/lsmcp

Repository files navigation

LSP for headless AI Agents

CI - Unit TestsCI - Integration TestsCI - Language Adapters

⚠️This project is under active development. APIs and features may change without notice.

A unified MCP (Model Context Protocol) server that provides advanced code manipulation and analysis capabilities for multiple programming languages through Language Server Protocol integration.

Features

  • 🌍Multi-Language Support - Built-in TypeScript/JavaScript, extensible to any language via LSP
  • 🔍Semantic Code Analysis - Go to definition, find references, type information
  • 🤖AI-Optimized - Designed for LLMs with line and symbol-based interfaces

LSP Tools (Language Server Protocol)

These tools work with any language that has an LSP server:

  • get_hover - Get hover information (type signature, documentation) using LSP
  • find_references - Find all references to symbol across the codebase using LSP
  • get_definitions - Get the definition(s) of a symbol using LSP
  • get_diagnostics - Get diagnostics (errors, warnings) for a file using LSP
  • get_all_diagnostics - Get diagnostics (errors, warnings) for all files in the project
  • rename_symbol - Rename a symbol across the codebase using Language Server Protocol
  • delete_symbol - Delete a symbol and optionally all its references using LSP
  • get_document_symbols - Get all symbols (functions, classes, variables, etc.) in a document using LSP
  • get_workspace_symbols - Search for symbols across the entire workspace using LSP
  • get_completion - Get code completion suggestions at a specific position using LSP
  • get_signature_help - Get signature help (parameter hints) for function calls using LSP
  • get_code_actions - Get available code actions (quick fixes, refactorings, etc.) using LSP
  • format_document - Format an entire document using the language server's formatting provider

Seeexamples/ for working examples of each supported language configuration.

Quick Start

lsmcp provides multi-language support through Language Server Protocol (LSP) integration. The basic workflow is:

  1. Install Language Server - Install the LSP server for your target language
  2. Add MCP Server - Configure usingclaude mcp add command or.mcp.json

Basic Usage

# Using presets for common languagesclaude mcp add typescript npx -- -y @mizchi/lsmcp -p typescript# Custom LSP server with --binclaude mcp add<server-name> npx -- -y @mizchi/lsmcp --bin="<lsp-command>"

Available Presets

lsmcp includes built-in presets for popular language servers:

  • typescript - TypeScript/JavaScript (typescript-language-server)
  • tsgo - TypeScript/JavaScript (tsgo - faster alternative)
  • deno - Deno TypeScript/JavaScript
  • pyright - Python (Microsoft Pyright)
  • ruff - Python (Ruff linter as LSP)
  • rust-analyzer - Rust
  • fsharp - F# (fsautocomplete)
  • moonbit - MoonBit
  • gopls - Go (Official Go language server)

For languages not in this list, or to customize LSP server settings, seeManual Setup.

Language-Specific Setup

TypeScript

TypeScript Setup
# with typeScript-language-server (stable)npm add -D typescript typescript-language-server# Recommended: use tsgo for full functionalityclaude mcp add typescript npx -- -y @mizchi/lsmcp -p typescript --bin="npx tsgo --lsp --stdio"# with @typescript/native-preview (experimental, fast)npm add -D @typescript/native-previewclaude mcp add typescript npx -- -y @mizchi/lsmcp -p typescript --bin="npx tsgo"

Manual Configuration (.mcp.json)

{"mcpServers": {"typescript": {"command":"npx","args": ["-y","@mizchi/lsmcp","-p","typescript","--bin","npx tsgo --lsp --stdio"      ]    }  }}

Rust

Rust Setup
rustup component add rust-analyzerclaude mcp add rust npx -- -y @mizchi/lsmcp -p rust-analyzer

Manual Configuration (.mcp.json)

{"mcpServers": {"rust": {"command":"npx","args": ["-y","@mizchi/lsmcp","-p","rust-analyzer"]    }  }}

Seeexamples/rust-project/ for a complete example.

Go

Go Setup
# Install gopls (official Go language server)go install golang.org/x/tools/gopls@latestclaude mcp add go npx -- -y @mizchi/lsmcp -p gopls

Manual Configuration (.mcp.json)

{"mcpServers": {"go": {"command":"npx","args": ["-y","@mizchi/lsmcp","-p","gopls"]    }  }}

Seeexamples/go/ for a complete example.

F#

F# Setup
dotnet tool install -g fsautocompleteclaude mcp add fsharp npx -- -y @mizchi/lsmcp -p fsharp --bin="fsautocomplete --adaptive-lsp-server-enabled"

Manual Configuration (.mcp.json)

{"mcpServers": {"fsharp": {"command":"npx","args": ["-y","@mizchi/lsmcp","-p","fsharp","--bin","fsautocomplete"      ]    }  }}

Seeexamples/fsharp-project/ for a complete example.

Python

Python Setup
# Option 1: Using Pyright (recommended)npm install -g pyrightclaude mcp add python npx -- -y @mizchi/lsmcp -p pyright# Option 2: Using python-lsp-serverpip install python-lsp-serverclaude mcp add python npx -- -y @mizchi/lsmcp --bin="pylsp"

Manual Configuration (.mcp.json)

{"mcpServers": {"python": {"command":"npx","args": ["-y","@mizchi/lsmcp","-p","pyright"]    }  }}

Seeexamples/python-project/ for a complete example.

Other Languages

Other Language Support

lsmcp supports any language with an LSP server. Here are some common configurations:

# Gogo install golang.org/x/tools/gopls@latestclaude mcp add go npx -- -y @mizchi/lsmcp --bin="gopls"# C/C++# Install clangd from your package manager or LLVM releasesclaude mcp add cpp npx -- -y @mizchi/lsmcp --bin="clangd"# Java# Install jdtls (Eclipse JDT Language Server)claude mcp add java npx -- -y @mizchi/lsmcp --bin="jdtls"

For more customization options, seeManual Setup.

Manual Setup

For advanced users who want more control over LSP server configuration, you can set up lsmcp manually with custom settings.

Minimal rust-analyzer Example

{"mcpServers": {"rust-minimal": {"command":"npx","args": ["-y","@mizchi/lsmcp","--bin","rust-analyzer"      ],"env": {"RUST_ANALYZER_CONFIG":"{\"assist\":{\"importGranularity\":\"module\"},\"cargo\":{\"allFeatures\":true}}"      }    }  }}

Custom Language Server Setup

You can configure any LSP server by providing the binary path and optional initialization options:

{"mcpServers": {"custom-lsp": {"command":"npx","args": ["-y","@mizchi/lsmcp","--bin","/path/to/your/lsp-server","--initializationOptions","{\"customOption\":\"value\"}"      ]    }  }}

Using Configuration Files

For complex LSP server configurations, you can use the--config option to load settings from a JSON file:

  1. Create a configuration file (e.g.,my-language.json):
{"id":"my-language","name":"My Custom Language","bin":"my-language-server","args": ["--stdio"],"initializationOptions": {"formatOnSave":true,"lintingEnabled":true,"customFeatures": {"autoImport":true    }  }}
  1. Use it with lsmcp:
# Using Claude CLIclaude mcp add my-language npx -- -y @mizchi/lsmcp --config ./my-language.json# Or in .mcp.json{"mcpServers": {"my-language": {"command":"npx","args": ["-y","@mizchi/lsmcp","--config","./my-language.json"]    }  }}

This approach is useful when:

  • You have complex initialization options
  • You want to share configurations across projects
  • You need to version control your LSP settings

Environment Variables

Some LSP servers can be configured via environment variables:

{"mcpServers": {"configured-lsp": {"command":"npx","args": ["-y","@mizchi/lsmcp","--bin","lsp-server"],"env": {"LSP_LOG_LEVEL":"debug","LSP_WORKSPACE":"/path/to/workspace"      }    }  }}

MCP Usage

Command Line Options

# Using language presetsnpx @mizchi/lsmcp -p<preset> --bin'...'npx @mizchi/lsmcp --preset<preset> --bin'...'# Custom LSP servernpx @mizchi/lsmcp --bin'<lsp-command>'

Development

# Install dependenciespnpm install# Buildpnpm build# Run testspnpmtest# Type checkpnpm typecheck# Lintpnpm lint

SeeCLAUDE.md for development guidelines.

Troubleshooting

Common Issues

LSP Server Not Found

Error: LSP server for typescript not found

Solution: Install the language server:

npm add typescript typescript-language-server

Permission Denied

Error: Permission denied for tool 'rename_symbol'

Solution: Update.claude/settings.json to allow lsmcp tools.

Empty Diagnostics

Ifget_diagnostics returns empty results:

  1. Ensure the language server is running:ps aux | grep language-server
  2. Check for tsconfig.json or equivalent config file
  3. Try opening the file first withget_hover

License

MIT - SeeLICENSE file for details.


[8]ページ先頭

©2009-2025 Movatter.jp