scheme-langserver-bridge
This MCP server bridges Kimi CLI to scheme-langserver, exposing LSP tools for real-time Scheme code intelligence (hover, completions, definitions, diagnostics, etc.).
Initialize/restart/shutdown the language server (
lsp_initialize,lsp_restart,lsp_shutdown).Sync files by opening, changing, and closing documents (
lsp_open,lsp_change,lsp_close).Query code intelligence: hover type/docs, completions, go-to-definition, references, signature help, document/workspace symbols, and code actions (
lsp_hover,lsp_complete,lsp_definition,lsp_references,lsp_signature,lsp_document_symbol,lsp_workspace_symbol,lsp_code_action).Get diagnostics for errors/warnings, especially bracket mismatch and syntax failures (
lsp_diagnostics).Compute rename edits across files (
lsp_rename) — may be unsupported and return method not found.Export a debug report for upstream issue reporting (
lsp_export_debug_report).
Provides Scheme language intelligence for Ansys Fluent's Scheme scripting environment, including hover information, completions, definitions, references, and diagnostics.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@scheme-langserver-bridge Show me the type of `fold-left` in this Scheme file."
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
scheme-langserver-bridge
MCP (Model Context Protocol) bridge that connects Kimi Code CLI to scheme-langserver, giving Kimi real-time language intelligence when working with Scheme code.
What this does
When you ask Kimi to write, refactor, or explain Scheme code, Kimi can now call scheme-langserver behind the scenes to obtain:
Precise type information — via
textDocument/hoverScope-aware completions — via
textDocument/completion(includes localletandlambdabindings)Exact definition locations — via
textDocument/definitionCross-reference search — via
textDocument/referencesSyntax / semantic diagnostics — via
textDocument/publishDiagnosticsSafe rename edits — via
textDocument/rename(server support is on the roadmap)Function signatures — via
textDocument/signatureHelp(server support is on the roadmap)Workspace-wide symbol search — via
workspace/symbol(requires scheme-langserver ≥ 2.1.0 (tested up to 2.1.10))Code actions — via
textDocument/codeAction(server support is on the roadmap)
Important: You (the user) never interact with scheme-langserver directly. Kimi invokes the bridge tools automatically when it judges that precise code information would help its reasoning.
Related MCP server: kimi-code-mcp
Known limitations of scheme-langserver
scheme-langserver is actively developed and not infallible:
Type inference is experimental and may be wrong or hang on complex code.
Macro support (
syntax-case,syntax-rules) is incomplete. Production builds fall back to hand-written rules.Analysis of unfinished code is best-effort.
Implementation-specific Chez Scheme extensions may not be recognized.
workspace/symbolrequires scheme-langserver ≥ 2.1.0 (tested up to 2.1.10).textDocument/rename,textDocument/signatureHelp, andtextDocument/codeActionare exposed by the bridge but still on the server's roadmap; the server may return "method not found".
Kimi is expected to treat LSP output as a reference, cross-check it against its own training knowledge, and gracefully fall back when the server returns errors or nonsense.
Installation
From GitHub (any OS)
Note: This package is not published on PyPI. Install directly from the Git repository instead.
Requires Python 3.12+ and a local scheme-langserver executable.
pip install git+https://github.com/ufo5260987423/scheme-langserver-kimi-plugin.gitOr with uv:
uv pip install git+https://github.com/ufo5260987423/scheme-langserver-kimi-plugin.gitVia Nix
nix run .#scheme-langserver-bridgeOr enter the development shell:
nix develop
uv sync --extra devFrom source
git clone https://github.com/ufo5260987423/scheme-langserver-kimi-plugin.git
cd scheme-langserver-kimi-plugin
uv sync --extra devConfiguring Kimi
Add the bridge as an MCP server:
kimi mcp add --transport stdio scheme-langserver -- \
python3 -m scheme_langserver_bridgeOr manually edit ~/.kimi/mcp.json:
{
"mcpServers": {
"scheme-langserver": {
"command": "python3",
"args": ["-m", "scheme_langserver_bridge"],
"env": {
"SCHEME_LANGSERVER_PATH": "/path/to/scheme-langserver/run"
}
}
}
}Configuration
Configuration is resolved in the following priority (highest first):
Project config —
.scheme-langserver.toml(or.scheme-langserver.json) in the project rootEnvironment variables
Built-in defaults
Project configuration file
Create .scheme-langserver.toml in your project root:
langserver_path = "/nix/store/.../bin/scheme-langserver"
multi_thread = "enable"
type_inference = "enable"
top_environment = "R6RS"
cache_path = ".scheme-langserver-cache"
auto_update = true
max_memory_mb = 4096
max_cpu_seconds = 300Supported fields:
Field | Type | Description |
| string | Override the scheme-langserver executable path |
| string |
|
| string |
|
| string |
|
| string | Override the log file path |
| string | Directory for workspace FASL cache (scheme-langserver 2.1.3+; default: |
| bool | Allow auto-download when no executable is found |
| int | Sub-process memory limit in MB (default: 2048) |
| int | Sub-process CPU time limit in seconds (default: 180) |
Auto-download
If no scheme-langserver executable is found locally, the bridge can automatically download the latest release from GitHub:
Uses GitHub's static redirect URL (
releases/latest/download/...) withHEADrequests to detect the latest version without consuming API rate limits.Downloads are cached to
~/.cache/scheme-langserver-bridge/versions/<version>/.Version-check results are cached with a 1-hour TTL.
Controlled by
auto_updatein project config orSCHEME_LANGSERVER_AUTO_UPDATEenv var (defaulttrue).Currently supports Linux x86_64 glibc only. Other platforms will receive a manual-installation hint.
Environment variables
Variable | Description | Default |
| Path to the scheme-langserver executable | auto-discover |
| Log file path |
|
| Multi-threading |
|
| Type inference |
|
| Top-level environment: |
|
| Directory for workspace FASL cache (scheme-langserver 2.1.3+; default: |
|
| Request timeout in seconds |
|
| Completion request timeout in seconds |
|
| Sub-process memory limit in MB |
|
| Sub-process CPU time limit in seconds |
|
| Allow auto-download when no executable is found |
|
| Bridge log level: |
|
| Default directory for debug crash reports | current working dir |
Resource Limits
The bridge applies hard resource limits to the scheme-langserver child process via Unix setrlimit:
Memory (
RLIMIT_AS): capped atSCHEME_LANGSERVER_MAX_MEMORY_MB(default 2048 MB). If the server tries to allocate beyond this limit, the OS will deny the allocation.CPU time (
RLIMIT_CPU): capped atSCHEME_LANGSERVER_MAX_CPU_SECONDS(default 180 s). If the server consumes more CPU time, the kernel sendsSIGXCPUand terminates it.Core dumps (
RLIMIT_CORE): disabled to avoid filling disk on crashes.
Timeout and force-kill behavior
If an LSP request exceeds its timeout (default 30 s, or the completion-specific timeout):
The bridge first terminates (
SIGTERM) the scheme-langserver process.It waits up to 3 seconds for graceful exit.
If the process is still alive, it is killed (
SIGKILL).All pending requests receive a timeout error so Kimi can fall back to its own knowledge.
Crash detection and recovery
The bridge monitors the LSP process:
If the process exits unexpectedly (stdout EOF, stderr close), the bridge marks it as crashed.
Any subsequent tool call returns an error telling Kimi to call
lsp_shutdownfollowed bylsp_initializeto restart the server.On shutdown signals (
SIGINT,SIGTERM), the bridge gracefully stops the LSP server before exiting.
Debug reporting
When scheme-langserver crashes or behaves abnormally, the bridge automatically generates a debug report containing:
LSP traffic log (
ready-for-analyse.log) — compatible with upstream replay scriptsOpen file snapshots
Server stderr and own log
Environment metadata (versions, args, diagnostics)
You can also manually export a report at any time:
lsp_export_debug_report(output_path="/optional/path")⚠️ Reports contain your source code. Review before posting to a public issue tracker.
Reports are saved to
SCHEME_BRIDGE_REPORT_DIR(or the current working directory) as:scheme-langserver-debug-report-YYYYMMDD-HHMMSS/
Usage Examples
Below are typical Kimi conversations that trigger LSP tools automatically:
1. "帮我看看这个 factorial 函数的定义在哪里"
Kimi will call:
lsp_definition(file_path="/project/math.scm", line=5, character=9)And receive the exact file, line, and column where factorial is defined, e.g.:
{
"uri": "file:///project/utils.scm",
"range": {
"start": { "line": 12, "character": 7 },
"end": { "line": 12, "character": 16 }
}
}2. "补全这行代码"
When your cursor is inside a let binding, Kimi calls:
lsp_complete(file_path="/project/main.scm", line=8, character=14)The result includes local bindings (e.g., n, acc) that a plain text search would miss:
[
{ "label": "factorial", "kind": 3 },
{ "label": "n", "kind": 6 },
{ "label": "acc", "kind": 6 }
]3. "这个变量是什么类型"
Kimi calls:
lsp_hover(file_path="/project/main.scm", line=4, character=12)And gets the inferred type signature and documentation:
{
"contents": [
"```scheme\n(: factorial (-> integer? integer?))\n```",
"Compute n! recursively."
]
}4. Switching scheme-langserver executables
To test a local development build of scheme-langserver, pass langserver_path to
lsp_initialize or lsp_restart:
lsp_restart(langserver_path="/home/dev/scheme-langserver/run")The bridge will use that executable and reopen all tracked documents. This is useful when iterating on scheme-langserver itself.
Example Prompt: Fluent–FPGA Co-Verification
docs/提示词-fluent-fpga协同代码生成.md contains a ready-to-use prompt template (in Chinese) that drives Kimi to generate Fluent Scheme code for CFD–FPGA co-verification workflows.
How to use it:
Place a
.scheme-langserver.tomlin your project root withtop_environment = "fluent"so the bridge analyzes code against ANSYS Fluent's Scheme dialect (requires scheme-langserver ≥ 2.1.10).Fill in the FPGA project path at the end of the prompt file.
Paste the prompt into a Kimi Code CLI session with this bridge configured.
Kimi will then read the FPGA project, and generate three Fluent Scheme modules — verify/ (reference-solution comparison with error metrics), convert/ (bidirectional FPGA ↔ Fluent data conversion), and exp/ (parameter sweeps and experiment automation) — self-checking each file with lsp_diagnostics / lsp_definition via this bridge.
Available MCP Tools
All tools are prefixed with lsp_:
Tool | Purpose |
| Start scheme-langserver for a project root |
| Open a file so the server can analyze it |
| Push updated file contents to the server |
| Close a file |
| Restart scheme-langserver and reopen tracked documents |
| Get type/docs for a symbol at a position |
| Get completion candidates at a position |
| Find where a symbol is defined |
| Find all references to a symbol |
| Compute workspace edits to rename a symbol |
| Get function signature help |
| List all symbols in a file |
| Search symbols across the workspace |
| Get quick fixes / refactorings for a range |
| Get errors and warnings (critical for catching unmatched brackets / tokenizer failures in Scheme) |
| Export a debug report for upstream issue reporting |
Troubleshooting
Status bar shows MCP Servers: 0/1 connected, 0 tools with a spinning indicator
This is usually not a real connection failure, but a startup-timing artifact of Kimi CLI:
In interactive shell mode, Kimi CLI defers MCP server loading so the UI can appear immediately, then connects in the background. While this is happening, the status bar shows
0/1 connected, 0 toolswith a spinner — by design.The bridge itself starts fast (cold
initializeresponse ≈ 1 s), so the actual connection finishes within a few seconds.However, the prompt status bar may not repaint immediately after the background connection completes — the old spinner frame can linger on screen until your next keystroke or UI refresh.
How to verify the server actually connected:
Check the Kimi CLI log for a
Connected MCP server: scheme-langserverline:grep "Connected MCP server" ~/.kimi/logs/kimi.logOr simply ask Kimi in the conversation — if the
lsp_*tools are loaded, the connection succeeded.
If the spinner persists for more than ~15 seconds, it is a genuine connection failure. Check ~/.kimi/logs/kimi.log for the underlying error (common causes: wrong command/args in ~/.kimi/mcp.json, missing python3, or the venv path being moved).
NixOS Specific Notes
Enter the development environment with
nix develop.ruffandpyrightmust be installed through nixpkgs (they are included in the dev shell viauv/pyproject.tomldev dependencies).On NixOS, the bridge will pick up
scheme-langserverfromPATHif it is installed via nixpkgs.
Development
nix develop # enter dev shell
uv sync --extra dev # install Python deps
pytest # run tests
ruff check --fix # lint
pyright # type checkArchitecture
Kimi CLI <--MCP (stdio)--> scheme-langserver-bridge <--LSP (stdio)--> scheme-langserverThe bridge is a thin Python layer that:
Spawns scheme-langserver as a subprocess with configurable resource limits.
Speaks JSON-RPC 2.0 over stdio with the LSP server.
Exposes LSP operations as MCP tools for Kimi to call.
Manages document sync, timeouts, crash detection, and graceful shutdown.
Available Tools
17 toolslsp_changeA
Notify the language server that a file has changed (like pressing Save).
Send the new full text of the file. This keeps the server's internal state in sync with the actual file contents.
When to use: IMMEDIATELY after you modify a Scheme file via filesystem tools (WriteFile/StrReplaceFile). If you skip this step, subsequent diagnostics and queries will operate on stale content.
Inputs: text (required), file_path (required). Returns: object
lsp_closeA
Close a file in the language server.
When to use: When you are completely done with a file or at session end. Do NOT close files just because you paused editing; frequent open/close wastes server resources.
Inputs: file_path (required). Returns: object
lsp_code_actionB
Get code actions (quick fixes, refactorings) for a range.
Limitation: codeAction is on the scheme-langserver roadmap and may return -32601 "method not found" or behave incompletely.
Inputs: end_line (required), file_path (required), start_line (required), end_character (required), +1 more. Returns: object
lsp_completeA
Trigger auto-completion at the cursor position.
Like pressing Ctrl+Space in an IDE. Returns identifiers available in the current scope, including local bindings (let, lambda parameters) that may not be obvious from a simple text search.
Confidence: MEDIUM. The list may miss identifiers generated by macros.
Inputs: line (required), character (required), file_path (required). Returns: object
lsp_definitionB
Go to Definition: jump to where the symbol is defined.
Like pressing F12 in an IDE. Returns file URI, line, and column.
Confidence: HIGH. Reliable for locating definitions across files.
Inputs: line (required), character (required), file_path (required). Returns: object
lsp_diagnosticsA
Get diagnostic messages (errors, warnings) from the language server.
When to use: After lsp_change to check for errors, like IDE real-time linting. Also useful before finishing a task to ensure no errors were introduced.
Why this matters for Scheme: S-expressions are catastrophically sensitive to
bracket balance. A single missing or extra parenthesis can render the entire file
unparseable. Diagnostics will catch unmatched brackets, tokenizer errors, and
structural syntax failures with high reliability — things LLMs often miss by eye.
scheme-langserver 2.1.2+ restored clear bracket-mismatch diagnostics
(unclosed parenthesis, unexpected close bracket) in the fault-tolerant tokenizer.
Always pull diagnostics after significant edits.
Confidence: HIGH for basic syntax (brackets, undefined ids). MEDIUM/LOW for semantic errors and implementation-specific extensions (Chez-specific forms may be falsely flagged).
Args: file_path: If provided, returns diagnostics for that file only. If omitted, returns diagnostics for all open files.
Inputs: file_path. Returns: object
lsp_document_symbolA
Show the file's symbol outline (functions, variables, macros).
Like the Outline / Structure panel in an IDE.
Confidence: MEDIUM. Symbols generated by macros may be missing.
Inputs: file_path (required). Returns: object
lsp_export_debug_reportA
Export a debug report for scheme-langserver upstream issue reporting.
The report contains the LSP traffic log, open project files, environment info, and server stderr. Review before sharing publicly — it includes source code.
When to use: scheme-langserver crashed or returned clearly wrong results, and you want to help debug by generating a report for the upstream issue tracker (https://github.com/ufo5260987423/scheme-langserver/issues).
Inputs: output_path. Returns: object
lsp_hoverA
Show hover tooltip (type, docs) for the symbol under the cursor.
Like hovering the mouse over an identifier in an IDE.
Confidence: MEDIUM. Type inference is experimental; info about macro-expanded identifiers may be inaccurate. Cross-check with your knowledge.
Args: file_path: Absolute path to the file. line: Zero-based line number. character: Zero-based character (column) position.
Inputs: line (required), character (required), file_path (required). Returns: object
lsp_initializeA
Initialize the scheme-langserver connection.
Must be called before any other LSP tool. Provides the project root directory so the language server can resolve imports and analyze the codebase.
Args: root_dir: Project root directory. langserver_path: Optional path to a specific scheme-langserver executable. If provided, it overrides environment variables and project config. This is useful for switching between scheme-langserver builds at runtime, e.g. when debugging a local development build.
Inputs: root_dir (required), langserver_path. Returns: object
lsp_openA
Open a file in the language server (like opening a tab in an editor).
The server needs to know file contents before it can provide hover, completion, or diagnostics for that file.
When to use: When you start working on a Scheme file. Keep the file open for the duration of the session; do NOT open and close repeatedly.
Inputs: file_path (required), language_id. Returns: object
lsp_referencesB
Find All References: list every usage of the symbol across the workspace.
Like Shift+F12 in an IDE.
Confidence: HIGH. Reliable for assessing impact before refactoring.
Args: include_declaration: Whether to include the definition site in the results.
Inputs: line (required), character (required), file_path (required), include_declaration. Returns: object
lsp_renameA
Compute workspace edits to rename a symbol.
Returns a set of text document edits that can be applied to safely rename the symbol across all files.
Limitation: rename is on the scheme-langserver roadmap and may return -32601 "method not found". If so, fall back to manual renaming.
Inputs: line (required), new_name (required), character (required), file_path (required). Returns: object
lsp_restartA
Restart the scheme-langserver connection and reopen tracked documents.
Use this when you want scheme-langserver to pick up configuration changes
(e.g. a new cache_path), switch to a different executable, or recover
from a stuck server. After restarting, all currently open files are
re-opened automatically so the server state is restored.
Args: root_dir: Project root directory. If omitted, the previously used root_dir is reused; if there is none, it is inferred from open documents or the current working directory. langserver_path: Optional path to a specific scheme-langserver executable. If provided, it overrides environment variables and project config. This lets you instantly switch to a local build for debugging or comparison.
Inputs: root_dir, langserver_path. Returns: object
lsp_shutdownB
Gracefully shut down the scheme-langserver connection.
Inputs: no named parameters. Returns: object
lsp_signatureA
Get signature help for a function call.
Shows parameter names and types for the function being called at the given position.
Limitation: signatureHelp is on the scheme-langserver roadmap and may return -32601 "method not found". If so, fall back to your own knowledge.
Inputs: line (required), character (required), file_path (required). Returns: object
lsp_workspace_symbolA
Search symbols across the entire workspace.
Like Ctrl+T / Go to Symbol in an IDE. Returns all symbols matching the query string across all indexed files.
Confidence: MEDIUM. Accuracy depends on index completeness. Requires scheme-langserver >= 2.1.0.
Inputs: query (required). Returns: object
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 17 tools
Each tool maps to a distinct LSP operation or lifecycle event, so there is no meaningful overlap: open/change/close manage document state, hover/complete/definition/references/signature query different perspectives, and document_symbol vs workspace_symbol are explicitly scoped to file vs workspace. The few related pairs are differentiated clearly by name and description.
All 17 tools follow the same lsp_ snake_case prefix and mostly mirror standard LSP method names, making the set predictable and easy to navigate. Even though some names are nouns rather than verb_noun phrases, the convention is uniform across the whole server.
17 tools is at the upper end of comfortable scope, but nearly every one corresponds to a distinct LSP feature or lifecycle step needed by a language-server bridge. The count feels justified rather than bloated; it is only slightly above the typical well-scoped range.
The set covers the full editing loop: initialize, open/change/close documents, query symbols/references/hover/completion, and fetch diagnostics, plus shutdown/restart and troubleshooting. Minor gaps remain (e.g., formatting, document highlighting) and a few exposed features (rename/signature/code_action) are documented as possibly unsupported by the server, but there are no critical dead ends for the core workflow.
Maintenance
Related MCP Connectors
Shared memory MCP server for Claude Code, Codex, Gemini CLI and Cursor. Cited, editable.
Lean 4 MCP server: compile, prove theorems, and formalize math with Mathlib.
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
Remote MCP server that gives Claude, ChatGPT, Cursor or any MCP client Google search volume, CPC, competition and similar keywords for 50+ countries. Works with no signup at 20 lookups a day; sign in with OAuth or an API key for higher limits, or $4.99 a month for unlimited.
Related MCP Servers
- AlicenseAqualityBmaintenanceBridges Claude Code to Language Server Protocol (LSP) servers to enable semantic code intelligence features like navigation, refactoring, and real-time diagnostics. It supports multiple languages including TypeScript, Python, and Rust with multi-root workspace capabilities.192,580 npm23MIT
- AlicenseBqualityDmaintenanceMCP server wrapping Kimi Code CLI (kimi-k2.5) to provide tools for filesystem, shell, web, and agent operations.1436 npm7MIT
- AlicenseBqualityDmaintenanceWindows-first MCP bridge for Kimi Code CLI, exposing code analysis, editing, sessions, and diagnostics as tools for AI agents.6MIT
- AlicenseAqualityDmaintenanceBridges MCP clients to Moonshot AI's Kimi Code CLI, enabling file analysis, brainstorming, batch tasks, code reviews, and session management within editors like Claude Desktop and Cursor.14116 npm1MIT