loading…
Search for a command to run...
loading…
CodeMirror extension that implements the Model Context Protocol (MCP) for resource mentions and prompt commands
CodeMirror extension that implements the Model Context Protocol (MCP) for resource mentions and prompt commands
A CodeMirror extension that implements the Model Context Protocol (MCP) for resource mentions and prompt commands.
@resource mentions@resource mentions with click handling/prompt commandsnpm install @marimo-team/codemirror-mcp @modelcontextprotocol/sdk
# or
pnpm add @marimo-team/codemirror-mcp @modelcontextprotocol/sdk
This module requires the following peer dependencies:
@codemirror/view@codemirror/state@modelcontextprotocol/sdkimport { WebSocketClientTransport } from "@modelcontextprotocol/sdk/client/websocket.js";
import { mcpExtension, extractResources } from '@marimo-team/codemirror-mcp';
import { EditorView } from '@codemirror/view';
const transport = new WebSocketClientTransport(new URL('ws://localhost:8080'));
const view = new EditorView({
extensions: [
// ... other extensions
mcpExtension({
// Required options
transport: transport,
// Optional options
logger: console,
clientOptions: {
name: 'your-client',
version: '1.0.0'
},
onResourceClick: (resource) => {
// Open resource
// e.g. open in a tab, etc.
},
}),
// Handle submit
keymap.of([
{
key: 'Enter',
run: () => {
const resources = extractResources(view);
const formattedResources = resources
.map(
({ resource }) =>
`${resource.uri} (${resource.type}): ${resource.description || resource.name}`
)
.join('\n');
const prompt = `${view.state.doc.toString()}\n\nResources:\n${formattedResources}`;
// ... submit prompt to AI server
// const response = await generateText(prompt);
},
},
]),
],
parent: document.querySelector('#editor'),
});
@resource-uri syntax to reference resources/command syntax for prompt commands# Install dependencies
pnpm install
# Run tests
pnpm test
# Run demo
pnpm dev
MIT
Run in your terminal:
claude mcp add codemirror-mcp -- npx pro tip
Just installed codemirror-mcp? Say to Claude: "remember why I installed codemirror-mcpand what I want to try" — it'll save into your Vault.
CSA PROJECT - FZCO © 2026 IFZA Business Park, DDP, Premises Number 31174 - 001
Security
Low riskAutomated heuristic from public metadata — not a security guarantee.