LSP MCP Server for Rell
An MCP server for interacting with the Rell Language Server Protocol interface. It enables LLMs to query LSP Hover and Completion providers for Rell projects.
README
LSP MCP Server for Rell
An MCP (Model Context Protocol) server for interacting with the Rell Language Server Protocol (LSP) interface. This server acts as a bridge that allows LLMs to query LSP Hover and Completion providers for Rell projects.
Note: This project is based on @Tritlo/lsp-mcp with slight modifications to remove all extensions and use it specifically with the default Rell language server. The Rell LSP JAR file is automatically downloaded and managed by this server.
Overview
The MCP Server works by:
- Starting an LSP client that connects to a LSP server
- Exposing MCP tools that send requests to the LSP server
- Returning the results in a format that LLMs can understand and use
This enables LLMs to utilize the Rell LSP for more accurate code suggestions and analysis.
Configuration:
{
"mcpServers": {
"rell-lsp-mcp": {
"type": "stdio",
"command": "node",
"args": [
"/path/to/this/project/dist/index.js"
]
}
}
}
Features
MCP Tools
get_info_on_location: Get hover information at a specific location in a fileget_completions: Get completion suggestions at a specific location in a fileget_code_actions: Get code actions for a specific range in a fileopen_document: Open a file in the LSP server for analysisclose_document: Close a file in the LSP serverget_diagnostics: Get diagnostic messages (errors, warnings) for open filesstart_lsp: Start the LSP server with a specified root directoryrestart_lsp_server: Restart the LSP server without restarting the MCP serverset_log_level: Change the server's logging verbosity level at runtime
MCP Resources
lsp-diagnostics://resources for accessing diagnostic messages with real-time updates via subscriptionslsp-hover://resources for retrieving hover information at specific file locationslsp-completions://resources for getting code completion suggestions at specific positions
Additional Features
- Comprehensive logging system with multiple severity levels
- Colorized console output for better readability
- Runtime-configurable log level
- Detailed error handling and reporting
- Simple command-line interface
Prerequisites
- Node.js (v16 or later)
- npm
- Java JDK (for running the Rell LSP server)
Installation
Building the MCP Server
-
Clone this repository:
git clone <-repository-url> cd lsp-mcp -
Install dependencies:
npm install -
Build the MCP server:
npm run build
Testing
The project includes integration tests for the Rell LSP support. These tests verify that the LSP-MCP server correctly handles LSP operations like hover information, completions, diagnostics, and code actions with the Rell language server.
Running Tests
To run the Rell LSP tests:
npm test
Test Coverage
The tests verify the following functionality:
- Automatic downloading and initialization of the Rell LSP server
- Opening Rell files for analysis
- Getting hover information for functions and types
- Getting code completion suggestions
- Getting diagnostic error messages
- Getting code actions for errors
Usage
Run the MCP server directly with Node.js:
node dist/index.js
The server automatically downloads and manages the Rell LSP server JAR file, so no additional configuration is needed. The Rell LSP server will be downloaded to ~/chromia/lsp-mcp/ on first use.
Important: Starting the LSP Server
You must explicitly start the LSP server by calling the start_lsp tool before using any LSP functionality. This ensures proper initialization with the correct root directory for your Rell project:
{
"tool": "start_lsp",
"arguments": {
"root_dir": "/path/to/your/project"
}
}
Logging
The server includes a comprehensive logging system with 8 severity levels:
debug: Detailed information for debugging purposesinfo: General informational messages about system operationnotice: Significant operational eventswarning: Potential issues that might need attentionerror: Error conditions that affect operation but don't halt the systemcritical: Critical conditions requiring immediate attentionalert: System is in an unstable stateemergency: System is unusable
By default, logs are sent to:
- Console output with color-coding for better readability
- MCP notifications to the client (via the
notifications/messagemethod)
Viewing Debug Logs
For detailed debugging, you can:
-
Use the
claude --mcp-debugflag when running Claude to see all MCP traffic between Claude and the server:claude --mcp-debug -
Change the log level at runtime using the
set_log_leveltool:{ "tool": "set_log_level", "arguments": { "level": "debug" } }
The default log level is info, which shows moderate operational detail while filtering out verbose debug messages.
API
The server provides the following MCP tools:
get_info_on_location
Gets hover information at a specific location in a file.
Parameters:
file_path: Path to the fileline: Line numbercolumn: Column position
Example:
{
"tool": "get_info_on_location",
"arguments": {
"file_path": "/path/to/your/file.rell",
"line": 3,
"column": 5
}
}
get_completions
Gets completion suggestions at a specific location in a file.
Parameters:
file_path: Path to the fileline: Line numbercolumn: Column position
Example:
{
"tool": "get_completions",
"arguments": {
"file_path": "/path/to/your/file.rell",
"line": 3,
"column": 10
}
}
get_code_actions
Gets code actions for a specific range in a file.
Parameters:
file_path: Path to the filestart_line: Start line numberstart_column: Start column positionend_line: End line numberend_column: End column position
Example:
{
"tool": "get_code_actions",
"arguments": {
"file_path": "/path/to/your/file.rell",
"start_line": 3,
"start_column": 5,
"end_line": 3,
"end_column": 10
}
}
start_lsp
Starts the LSP server with a specified root directory. This must be called before using any other LSP-related tools.
Parameters:
root_dir: The root directory for the LSP server (absolute path recommended)
Example:
{
"tool": "start_lsp",
"arguments": {
"root_dir": "/path/to/your/project"
}
}
restart_lsp_server
Restarts the LSP server process without restarting the MCP server. This is useful for recovering from LSP server issues or for applying changes to the LSP server configuration.
Parameters:
root_dir: (Optional) The root directory for the LSP server. If provided, the server will be initialized with this directory after restart.
Example without root_dir (uses previously set root directory):
{
"tool": "restart_lsp_server",
"arguments": {}
}
Example with root_dir:
{
"tool": "restart_lsp_server",
"arguments": {
"root_dir": "/path/to/your/project"
}
}
open_document
Opens a file in the LSP server for analysis. This must be called before accessing diagnostics or performing other operations on the file.
Parameters:
file_path: Path to the file to open
Example:
{
"tool": "open_document",
"arguments": {
"file_path": "/path/to/your/file.rell",
}
}
close_document
Closes a file in the LSP server when you're done working with it. This helps manage resources and cleanup.
Parameters:
file_path: Path to the file to close
Example:
{
"tool": "close_document",
"arguments": {
"file_path": "/path/to/your/file"
}
}
get_diagnostics
Gets diagnostic messages (errors, warnings) for one or all open files.
Parameters:
file_path: (Optional) Path to the file to get diagnostics for. If not provided, returns diagnostics for all open files.
Example for a specific file:
{
"tool": "get_diagnostics",
"arguments": {
"file_path": "/path/to/your/file"
}
}
Example for all open files:
{
"tool": "get_diagnostics",
"arguments": {}
}
set_log_level
Sets the server's logging level to control verbosity of log messages.
Parameters:
level: The logging level to set. One of:debug,info,notice,warning,error,critical,alert,emergency.
Example:
{
"tool": "set_log_level",
"arguments": {
"level": "debug"
}
}
MCP Resources
In addition to tools, the server provides resources for accessing LSP features including diagnostics, hover information, and code completions:
Diagnostic Resources
The server exposes diagnostic information via the lsp-diagnostics:// resource scheme. These resources can be subscribed to for real-time updates when diagnostics change.
Resource URIs:
lsp-diagnostics://- Diagnostics for all open fileslsp-diagnostics:///path/to/file- Diagnostics for a specific file
Important: Files must be opened using the open_document tool before diagnostics can be accessed.
Hover Information Resources
The server exposes hover information via the lsp-hover:// resource scheme. This allows you to get information about code elements at specific positions in files.
Resource URI format:
lsp-hover:///path/to/file?line={line}&column={column}&language_id={language_id}
Parameters:
line: Line number (1-based)column: Column position (1-based)
Example:
lsp-hover:///home/user/project/src/main.rell?line=42&column=10&language_id=rell
Code Completion Resources
The server exposes code completion suggestions via the lsp-completions:// resource scheme. This allows you to get completion candidates at specific positions in files.
Resource URI format:
lsp-completions:///path/to/file?line={line}&column={column}&language_id={language_id}
Parameters:
line: Line number (1-based)column: Column position (1-based)
Example:
lsp-completions:///home/user/project/src/main.rell?line=42&column=10
Listing Available Resources
To discover available resources, use the MCP resources/list endpoint. The response will include all available resources for currently open files, including:
- Diagnostics resources for all open files
- Hover information templates for all open files
- Code completion templates for all open files
Subscribing to Resource Updates
Diagnostic resources support subscriptions to receive real-time updates when diagnostics change (e.g., when files are modified and new errors or warnings appear). Subscribe to diagnostic resources using the MCP resources/subscribe endpoint.
Note: Hover and completion resources don't support subscriptions as they represent point-in-time queries.
Working with Resources vs. Tools
You can choose between two approaches for accessing LSP features:
- Tool-based approach: Use the
get_diagnostics,get_info_on_location, andget_completionstools for a simple, direct way to fetch information. - Resource-based approach: Use the
lsp-diagnostics://,lsp-hover://, andlsp-completions://resources for a more RESTful approach.
Both approaches provide the same data in the same format and enforce the same requirement that files must be opened first.
Troubleshooting
- If the server fails to start, make sure the path to the LSP executable is correct
- Check the log file (if configured) for detailed error messages
License
MIT License
Acknowledgments
- @Tritlo/lsp-mcp for the original implementation
- Chromaway for the Rell language and LSP server
- Anthropic for the Model Context Protocol specification
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。