Snippets MCP

Snippets MCP

Enables storing, searching, and managing code snippets using hybrid semantic search and keyword matching with automatic language detection and tag-based organization.

Category
Visit Server

README

Snippets MCP

  • MCP server for storing, searching, and managing code snippets using semantic search and traditional keyword matching.
  • Just tell your coding agent (claude code, cursor, cline, opencode, etc.) to save a certain snippet. That's it.
  • When needed, just tell it to search for code snippets related to: your query.

Features

  • Semantic search using AI embeddings to find snippets by meaning, not just keywords
  • Hybrid search combining semantic similarity and keyword matching
  • Automatic programming language detection
  • Tag-based organization and filtering
  • Date range filtering
  • No database needed. JSON based storage.
  • Vector embeddings cached for fast retrieval

Installation

npm install @freakynit/snippets-mcp

Available Tools

add-snippet

Adds a new code snippet to the database.

Parameters:

  • code (string, required) - The code content
  • tags (array, optional) - Array of tag strings
  • language (string, optional) - Programming language (auto-detected if not provided)
  • description (string, optional) - Text description for better semantic search

search-snippets

Searches snippets using hybrid semantic and keyword matching.

Parameters:

  • query (string, optional) - Natural language search query
  • tags (array, optional) - Filter by specific tags (AND logic)
  • language (string, optional) - Filter by programming language
  • dateStart (ISO date string, optional) - Filter by creation date start
  • dateEnd (ISO date string, optional) - Filter by creation date end
  • limit (number, optional) - Maximum results to return (default: 10)

update-snippet

Updates an existing snippet. Re-generates embeddings if code, tags, or description change.

Parameters:

  • id (string, required) - Snippet ID
  • updates (object) - Object containing fields to update (code, tags, language, description)

delete-snippet

Deletes a snippet from the database.

Parameters:

  • id (string, required) - Snippet ID

get-snippet

Retrieves a single snippet by ID.

Parameters:

  • id (string, required) - Snippet ID

Environment Variables

  1. SNIPPETS_FILE_PATH: Optional, Full path to file to save snippets and embeddings in. Defaults to ~/.snippets-mcp-db.json.

How It Works

The library uses a hybrid search approach:

  1. Semantic Search (70% weight) - Uses the all-MiniLM-L6-v2 model to perform vector searh against embeddings generated off code, description, tags and language.
  2. Keyword Matching (30% weight) - Traditional text matching for exact term matches based on code and tags.
  3. Hard Filters - Applied first to narrow results by tags, language, and date range.

Embeddings are generated once when adding/updating snippets and cached for fast retrieval.

Storage

Snippets are stored in a JSON file specified by environment variable SNIPPETS_FILE_PATH, or at default path: ~/.snippets-mcp-db.json with the following structure:

{
  "id": "uuid",
  "code": "string",
  "language": "string",
  "tags": ["array"],
  "description": "string",
  "embedding": [/* vector array */],
  "createdAt": "ISO date",
  "updatedAt": "ISO date"
}

Configuring using mcpServers json

For Mac and Linux

{
  "mcpServers": {
    "snippets-mcp": {
      "command": "npx",
      "args": ["-y", "@freakynit/snippets-mcp@latest"],
      "env": {
        "SNIPPETS_FILE_PATH": "Optional... path to save snippets and embeddings in.. should have .json extension"
      }
    }
  }
}

For Windows

{
  "mcpServers": {
    "snippets-mcp": {
      "command": "cmd",
      "args": ["/k", "npx", "-y", "@freakynit/snippets-mcp@latest"],
      "env": {
        "SNIPPETS_FILE_PATH": "Optional... path to save snippets and embeddings in.. should have .json extension"
      }
    }
  }
}

License

MIT

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
E2B

E2B

Using MCP to run code via e2b.

Official
Featured