This MCP Code Snippet Server provides a standardized interface for managing code snippets across different programming languages. It allows you to create, list, and delete snippets with support for language categorization and tagging.
Before installing, ensure you have the required prerequisites:
To install the MCP Code Snippet Server:
git clone [email protected]:ngeojiajun-deriv/mcp-code-snippets.git
cd mcp-code-snippets
npm run build
npm link
The server provides three main functions for managing code snippets.
To create a new code snippet, you'll need to provide:
Example usage:
// Create a new JavaScript snippet
const response = await client.create({
title: "Hello World Function",
language: "javascript",
code: "function helloWorld() {\n console.log('Hello, World!');\n}",
tags: ["beginner", "example"]
});
You can retrieve snippets with optional filtering parameters:
Example usage:
// List all JavaScript snippets
const jsSnippets = await client.list({
language: "javascript"
});
// List snippets with the "beginner" tag
const beginnerSnippets = await client.list({
tag: "beginner"
});
// List all snippets
const allSnippets = await client.list({});
To remove a snippet, you need to provide its unique identifier:
Example usage:
// Delete a snippet by ID
await client.delete({
id: "snippet-12345"
});
The server automatically stores all snippets in local persistent storage, so your snippets will be preserved between server restarts.
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"cursor-rules-mcp": {
"command": "npx",
"args": [
"-y",
"cursor-rules-mcp"
]
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.