Code Snippet Manager MCP server

Manages and stores code snippets across languages, enabling creation, listing, and deletion with flexible filtering and tagging.
Back to servers
Provider
Jia Jun Ngeo
Release date
Jan 10, 2025
Language
TypeScript
Stats
7 stars

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.

Installation

Before installing, ensure you have the required prerequisites:

  • Node.js (18.x, 20.x, or 22.x)
  • npm

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

Usage

The server provides three main functions for managing code snippets.

Creating Snippets

To create a new code snippet, you'll need to provide:

  • title (required): Name of the snippet
  • language (required): Programming language
  • code (required): The actual code content
  • tags (optional): Array of tags for categorization

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"]
});

Listing Snippets

You can retrieve snippets with optional filtering parameters:

  • language (optional): Filter snippets by programming language
  • tag (optional): Filter snippets by tag

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({});

Deleting Snippets

To remove a snippet, you need to provide its unique identifier:

  • id (required): Unique identifier of the snippet to delete

Example usage:

// Delete a snippet by ID
await client.delete({
  id: "snippet-12345"
});

Storage

The server automatically stores all snippets in local persistent storage, so your snippets will be preserved between server restarts.

How to add this MCP server to Cursor

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.

Adding an MCP server to Cursor globally

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"
            ]
        }
    }
}

Adding an MCP server to a project

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.

How to use the MCP server

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.

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later