Skip to main content
Glama
scheme-langserver-bridge

scheme-langserver-bridge

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/hover

  • Scope-aware completions — via textDocument/completion (includes local let and lambda bindings)

  • Exact definition locations — via textDocument/definition

  • Cross-reference search — via textDocument/references

  • Syntax / semantic diagnostics — via textDocument/publishDiagnostics

  • Safe 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/symbol requires scheme-langserver ≥ 2.1.0 (tested up to 2.1.10).

  • textDocument/rename, textDocument/signatureHelp, and textDocument/codeAction are 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.git

Or with uv:

uv pip install git+https://github.com/ufo5260987423/scheme-langserver-kimi-plugin.git

Via Nix

nix run .#scheme-langserver-bridge

Or enter the development shell:

nix develop
uv sync --extra dev

From source

git clone https://github.com/ufo5260987423/scheme-langserver-kimi-plugin.git
cd scheme-langserver-kimi-plugin
uv sync --extra dev

Configuring Kimi

Add the bridge as an MCP server:

kimi mcp add --transport stdio scheme-langserver -- \
  python3 -m scheme_langserver_bridge

Or 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):

  1. Project config — .scheme-langserver.toml (or .scheme-langserver.json) in the project root

  2. Environment variables

  3. 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 = 300

Supported fields:

Field

Type

Description

langserver_path

string

Override the scheme-langserver executable path

multi_thread

string

enable / disable

type_inference

string

enable / disable

top_environment

string

R6RS / R7RS / s7 / goldfish / fluent (Ansys Fluent Scheme, requires scheme-langserver ≥ 2.1.10)

log_path

string

Override the log file path

cache_path

string

Directory for workspace FASL cache (scheme-langserver 2.1.3+; default: .scheme-langserver-cache in project root)

auto_update

bool

Allow auto-download when no executable is found

max_memory_mb

int

Sub-process memory limit in MB (default: 2048)

max_cpu_seconds

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/...) with HEAD requests 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_update in project config or SCHEME_LANGSERVER_AUTO_UPDATE env var (default true).

  • Currently supports Linux x86_64 glibc only. Other platforms will receive a manual-installation hint.

Environment variables

Variable

Description

Default

SCHEME_LANGSERVER_PATH

Path to the scheme-langserver executable

auto-discover

SCHEME_LANGSERVER_LOG_PATH

Log file path

.scheme-langserver.log in cwd

SCHEME_LANGSERVER_MULTI_THREAD

Multi-threading enable / disable

enable

SCHEME_LANGSERVER_TYPE_INFERENCE

Type inference enable / disable

enable

SCHEME_LANGSERVER_TOP_ENVIRONMENT

Top-level environment: R6RS / R7RS / s7 / goldfish / fluent (Ansys Fluent Scheme, requires scheme-langserver ≥ 2.1.10)

R6RS

SCHEME_LANGSERVER_CACHE_PATH

Directory for workspace FASL cache (scheme-langserver 2.1.3+; default: .scheme-langserver-cache in project root)

.scheme-langserver-cache in project root

SCHEME_LANGSERVER_TIMEOUT

Request timeout in seconds

30.0

SCHEME_LANGSERVER_COMPLETION_TIMEOUT

Completion request timeout in seconds

30.0

SCHEME_LANGSERVER_MAX_MEMORY_MB

Sub-process memory limit in MB

2048

SCHEME_LANGSERVER_MAX_CPU_SECONDS

Sub-process CPU time limit in seconds

180

SCHEME_LANGSERVER_AUTO_UPDATE

Allow auto-download when no executable is found

true

SCHEME_BRIDGE_LOGLEVEL

Bridge log level: DEBUG / INFO / WARNING / ERROR

INFO

SCHEME_BRIDGE_REPORT_DIR

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 at SCHEME_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 at SCHEME_LANGSERVER_MAX_CPU_SECONDS (default 180 s). If the server consumes more CPU time, the kernel sends SIGXCPU and 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):

  1. The bridge first terminates (SIGTERM) the scheme-langserver process.

  2. It waits up to 3 seconds for graceful exit.

  3. If the process is still alive, it is killed (SIGKILL).

  4. 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_shutdown followed by lsp_initialize to 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 scripts

  • Open 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:

  1. Place a .scheme-langserver.toml in your project root with top_environment = "fluent" so the bridge analyzes code against ANSYS Fluent's Scheme dialect (requires scheme-langserver ≥ 2.1.10).

  2. Fill in the FPGA project path at the end of the prompt file.

  3. 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

lsp_initialize

Start scheme-langserver for a project root

lsp_open

Open a file so the server can analyze it

lsp_change

Push updated file contents to the server

lsp_close

Close a file

lsp_restart

Restart scheme-langserver and reopen tracked documents

lsp_hover

Get type/docs for a symbol at a position

lsp_complete

Get completion candidates at a position

lsp_definition

Find where a symbol is defined

lsp_references

Find all references to a symbol

lsp_rename

Compute workspace edits to rename a symbol

lsp_signature

Get function signature help

lsp_document_symbol

List all symbols in a file

lsp_workspace_symbol

Search symbols across the workspace

lsp_code_action

Get quick fixes / refactorings for a range

lsp_diagnostics

Get errors and warnings (critical for catching unmatched brackets / tokenizer failures in Scheme)

lsp_export_debug_report

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:

  1. 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 tools with a spinner — by design.

  2. The bridge itself starts fast (cold initialize response ≈ 1 s), so the actual connection finishes within a few seconds.

  3. 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-langserver line:

    grep "Connected MCP server" ~/.kimi/logs/kimi.log
  • Or 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.

  • ruff and pyright must be installed through nixpkgs (they are included in the dev shell via uv / pyproject.toml dev dependencies).

  • On NixOS, the bridge will pick up scheme-langserver from PATH if 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 check

Architecture

Kimi CLI  <--MCP (stdio)-->  scheme-langserver-bridge  <--LSP (stdio)-->  scheme-langserver

The bridge is a thin Python layer that:

  1. Spawns scheme-langserver as a subprocess with configurable resource limits.

  2. Speaks JSON-RPC 2.0 over stdio with the LSP server.

  3. Exposes LSP operations as MCP tools for Kimi to call.

  4. Manages document sync, timeouts, crash detection, and graceful shutdown.

Available Tools

17 tools
lsp_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

    A3.9/5.0

    Scored across 17 tools

    Disambiguation5/5

    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.

    Naming Consistency5/5

    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.

    Tool Count4/5

    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.

    Completeness4/5

    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

    ActivitySlowing
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      B
      maintenance
      Bridges 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.
      19
      2,580 npm
      23
      MIT
    • A
      license
      B
      quality
      D
      maintenance
      Windows-first MCP bridge for Kimi Code CLI, exposing code analysis, editing, sessions, and diagnostics as tools for AI agents.
      6
      MIT
    • A
      license
      A
      quality
      D
      maintenance
      Bridges 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.
      14
      116 npm
      1
      MIT