CodeMirror MCP Server for Resource Mentions and Prompts
Integrate an MCP server into CodeMirror to power resource mentions and prompt commands for context-aware, extensible in-editor workflows.
npm install @marimo-team/codemirror-mcp @modelcontextprotocol/sdkOverview
This MCP (Model Context Protocol) server integrates with CodeMirror to enable resource mentions and prompt-based commands inside the editor. It exposes a small HTTP API that enumerates editor-aware resources (files, snippets, docs, URLs) and prompt templates (summaries, refactors, searches). A CodeMirror extension can query the MCP server while the user types to show mention/autocomplete lists and to call prompt commands that use the selected context.
Using an MCP server provides a consistent, extensible way to surface and resolve contextual items for LLMs and editor tooling. Instead of hard-coding mentions and commands in the extension, the MCP server centralizes resource discovery and prompt execution, making workflows easier to customize and scale across projects or teams.
Features
- Lightweight HTTP API to list and search resources and prompts
- Resource mention resolution for in-editor autocompletion (e.g., @file, @doc)
- Prompt templates and server-side prompt handlers (e.g., /summarize, /refactor)
- Pluggable backends: file system, Git, search index, external services
- JSON configuration for resources and prompt templates
- Simple client integration example for CodeMirror
Installation / Configuration
Clone and run the server locally (Node.js example):
Minimal Express-style server example (illustrative):
// server.js
;
;
;
// Example resources
;
'/mcp/resources',;
'/mcp/prompts/execute',;
3000,'MCP server listening on :3000';
Dockerfile example:
FROM node:18-alpine
WORKDIR /app
COPY . .
RUN npm ci --production
CMD ["node", "server.js"]
Configuration file example (resources and prompts):
Available Resources
The MCP server typically exposes resources with this schema:
- id: string (unique identifier, e.g., file:src/index.js)
- type: string (file, doc, snippet, url, issue)
- title: string (human-friendly)
- text: string (optional content for context)
- metadata: object (size, path, language, tags)
Common resource types:
- file — code files in the repo
- doc — documentation pages, README
- snippet — small reusable code snippets
- url — external resources or API docs
- issue/pr — links to issue tracker items
Available prompts (examples):
- summarize — produce a concise summary of selected resource
- explain — explain the code or concept under selection
- translate — convert code between languages or natural language between locales
- insert-template — insert a code template or boilerplate
Integration with CodeMirror (example)
Client-side snippet to query the MCP server and show mentions (pseudo-code):
// Use your existing CodeMirror completion source
;
Invoking a prompt (client → MCP):
;
;
;
// Insert result into editor or show a preview
Use Cases
- Context-aware completions: When a user types @ or /, surface project files, docs, or snippets to include as context for an LLM completion.
- In-editor prompts: Run server-handled prompts like /summarize or /refactor on a selected function and insert or preview the output.
- Cross-repo linking: Mention other repositories, issues, or design docs to create links or fetch context for AI assistants.
- Team-specific workflows: Customize the MCP server to expose internal resources (API specs, templates) and prompt handlers that align with team conventions.
This MCP server pattern decouples the editor UI from resource discovery and execution logic, making it easier to adapt prompt behavior or resource sources without changing editor extensions.