- 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.
- 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
npm install @freakynit/snippets-mcpAdds a new code snippet to the database.
Parameters:
code(string, required) - The code contenttags(array, optional) - Array of tag stringslanguage(string, optional) - Programming language (auto-detected if not provided)description(string, optional) - Text description for better semantic search
Searches snippets using hybrid semantic and keyword matching.
Parameters:
query(string, optional) - Natural language search querytags(array, optional) - Filter by specific tags (AND logic)language(string, optional) - Filter by programming languagedateStart(ISO date string, optional) - Filter by creation date startdateEnd(ISO date string, optional) - Filter by creation date endlimit(number, optional) - Maximum results to return (default: 10)
Updates an existing snippet. Re-generates embeddings if code, tags, or description change.
Parameters:
id(string, required) - Snippet IDupdates(object) - Object containing fields to update (code, tags, language, description)
Deletes a snippet from the database.
Parameters:
id(string, required) - Snippet ID
Retrieves a single snippet by ID.
Parameters:
id(string, required) - Snippet ID
SNIPPETS_FILE_PATH: Optional, Full path to file to save snippets and embeddings in. Defaults to~/.snippets-mcp-db.json.
The library uses a hybrid search approach:
- Semantic Search (70% weight) - Uses the
all-MiniLM-L6-v2model to perform vector searh against embeddings generated off code, description, tags and language. - Keyword Matching (30% weight) - Traditional text matching for exact term matches based on code and tags.
- 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.
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"
}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"
}
}
}
}