Enhance CodeMirror with MCP for resource mentions prompts autocomplete themes and resource interactions
The CodeMirror-MCP Server is an extension designed to implement the Model Context Protocol (MCP) for resource mentions and prompt commands within the CodeMirror editor framework. It provides developers a robust toolset to integrate AI applications more effectively by enabling seamless interaction between AI models, data sources, and user-generated content.
The CodeMirror-MCP Server offers several key features that enhance its integration capabilities:
@resource
mentions, allowing users to quickly access and reference relevant resources within their documents.@resource
mentions, providing a rich user experience with immediate access to resource details upon interaction./prompt
commands, enabling quick invocation of specific AI functionalities or commands within the text editor.The CodeMirror-MCP Server is built on top of MCP, a standardized protocol designed for universal communication between AI applications and tools. The protocol flow diagram illustrates how data flows between the AI application, the MCP client, the server, and the ultimate target resource or tool.
graph TD
A[AI Application] -->|MCP Client| B[MCP Server]
B --> C[Resource/Tool]
style A fill:#e1f5fe
style B fill:#f3e5f5
style C fill:#e8f5e8
The CodeMirror-MCP Server supports a range of MCP clients, each with varying levels of support for resources, tools, and prompts. The compatibility matrix provides an overview of which clients are fully supported.
MCP Client | Resources | Tools | Prompts | Status |
---|---|---|---|---|
Claude Desktop | ✅ | ✅ | ✅ | Full Support |
Continue | ✅ | ✅ | ✅ | Full Support |
Cursor | ❌ | ✅ | ❌ | Tools Only |
To get started, developers can install the CodeMirror-MCP Server and its dependencies using either npm or pnpm.
# Install dependencies using npm
npm install @marimo-team/codemirror-mcp @modelcontextprotocol/sdk
# Alternatively, use pnpm
pnpm add @marimo-team/codemirror-mcp @modelcontextprotocol/sdk
The CodeMirror-MCP Server requires the following peer dependencies:
@codemirror/view
@codemirror/state
@modelcontextprotocol/sdk
Imagine a developer working on complex algorithms where they need frequent references to external documentation and examples. With the CodeMirror-MCP Server, they can effortlessly add @resource
mentions for relevant resources and use /prompt
commands to generate optimized code snippets. This setup enhances their productivity and keeps them focused on coding.
In an interactive environment where users might need to execute specific AI prompts, the CodeMirror-MCP Server allows for seamless integration. For instance, a user could insert /prompt analyze
to trigger an analysis command in real-time, receiving results directly within the editor context.
The CodeMirror-MCP Server seamlessly integrates with various MCP clients such as Claude Desktop, Continue, and Cursor. By enabling these clients to communicate effectively, developers can provide a richer user experience that leverages AI capabilities for enhanced productivity.
Here's an example of how to configure the CodeMirror-MCP Server:
import { 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'),
});
The performance and compatibility matrix further detail the CodeMirror-MCP Server's capabilities, ensuring that developers can rely on robust integration with MCP clients.
Feature | Claude Desktop | Continue | Cursor |
---|---|---|---|
Resource Autocomplete | ✅ | ✅ | ❌ |
Tool Integration | ✅ | ✅ | ✅ |
Prompt Commands | ✅ | ✅ | ❌ |
Developers can further customize the behavior of the CodeMirror-MCP Server through various configuration options. This includes setting up security measures to protect sensitive data and ensuring that only authorized users have access.
{
"mcpServers": {
"[server-name]": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-[name]"],
"env": {
"API_KEY": "your-api-key"
}
}
}
}
Q: How does the CodeMirror-MCP Server enhance AI application integration? A: It provides a standardized protocol for seamless communication between AI applications and tools, improving usability and efficiency.
Q: Which MCP clients are supported by the CodeMirror-MCP Server? A: The server supports Claude Desktop, Continue, and Cursor with varying levels of resource and prompt support.
Q: Can I customize the styles and themes in the CodeMirror-MCP Server? A: Yes, you can customize the theme through a range of styling options provided by the extension.
Q: How do I handle security concerns when using the CodeMirror-MCP Server? A: You can configure environment variables like API keys and use secure protocols to protect sensitive information.
Q: What are the next steps for developers looking to integrate MCP servers into their projects? A: Start by installing the necessary packages, configuring the server according to your requirements, and testing it with various clients to ensure compatibility.
The CodeMirror-MCP Server encourages contributions from the developer community. If you are interested in contributing or have any questions, please refer to the project's GitHub repository for detailed guidelines.
pnpm
.pnpm install
.For more information about the MCP protocol, its applications, and related resources, visit Model Context Protocol.
RuinedFooocus is a local AI image generator and chatbot image server for seamless creative control
Learn to set up MCP Airflow Database server for efficient database interactions and querying airflow data
Simplify MySQL queries with Java-based MysqlMcpServer for easy standard input-output communication
Access NASA APIs for space data, images, asteroids, weather, and exoplanets via MCP integration
Explore CoRT MCP server for advanced self-arguing AI with multi-LLM inference and enhanced evaluation methods
Build stunning one-page websites track engagement create QR codes monetize content easily with Acalytica