Skip to main content
Glama
MCP Prompt Library Server

MCP Prompt Library Server

by soniccccc

MCP Prompt Library Server

A personal prompt library with semantic search capabilities using ChromaDB and the Model Context Protocol (MCP). This server allows you to store, search, and retrieve prompts using semantic similarity, making it easy to find relevant prompts even when you don't remember the exact wording.

Features

  • Semantic Search: Find similar prompts using natural language queries

  • Persistent Storage: All prompts are stored in a local ChromaDB database

  • MCP Integration: Works seamlessly with Claude Desktop and other MCP clients

  • Rich Metadata: Track source, creation time, and statistics for each prompt

  • Easy Retrieval: Get specific prompts by ID or search by content

Related MCP server: Fast Context MCP

Installation

Prerequisites

  • Python 3.8 or higher

  • pip or uv package manager

Setup

  1. Clone the repository:

    git clone <repository-url>
    cd MCP_Prompt_Library
  2. Install dependencies:

    # Using uv (recommended)
    uv sync
    
    # Or using pip
    pip install -r requirements.txt
  3. Environment Setup (optional):

    # Set custom ChromaDB path (defaults to ./chroma_db)
    export CHROMA_DB_PATH="/path/to/your/chroma_db"

Usage

Running the Server

The server can be run in two ways:

  1. Direct execution (for testing):

    python prompt_library_mcp_server.py
  2. As an MCP server (recommended): Configure your MCP client (e.g., Claude Desktop) to use this server.

Claude Desktop Configuration

Add this to your claude_desktop_config.json:

{
  "mcpServers": {
    "prompt-library": {
      "command": "/path/to/your/project/.venv/bin/python",
      "args": ["/path/to/your/project/prompt_library_mcp_server.py"],
      "env": {
        "CHROMA_DB_PATH": "/path/to/your/project/chroma_db"
      }
    }
  }
}

Important: Make sure to use the Python interpreter from your virtual environment and update the paths to match your actual project location.

Available Tools

The server provides three main tools:

1. store_prompt

Add a new prompt to your library.

Parameters:

  • prompt (required): The prompt text to store

  • source (optional): Where this prompt was used (e.g., "claude", "gpt4", "cursor")

Example:

{
  "prompt": "Explain the attention mechanism in transformers",
  "source": "claude"
}

2. search_prompts

Search for similar prompts using semantic similarity.

Parameters:

  • keywords (required): Keywords to search for in previous prompts

  • limit (optional): Number of results to return (default: 8, max: 20)

Example:

{
  "keywords": "transformer attention",
  "limit": 5
}

3. get_prompt

Retrieve a specific prompt by its ID.

Parameters:

  • prompt_id (required): The unique identifier for the prompt

Example:

{
  "prompt_id": "prompt_1234567890"
}

Testing

Run the test suite to verify functionality:

python test_server.py

This will:

  • Test prompt storage and retrieval

  • Test semantic search functionality

  • Verify error handling

  • Clean up test data automatically

Database Structure

The server uses ChromaDB for persistent storage with the following structure:

  • Collection: prompt_library

  • Documents: The actual prompt text

  • Metadata:

    • prompt_id: Unique identifier

    • timestamp: Creation timestamp (ISO format)

    • source: Where the prompt was used

    • character_count: Number of characters

    • word_count: Number of words

API Response Format

All responses are returned as JSON with the following structure:

Search Response

{
  "search_keywords": "query terms",
  "found": 3,
  "total_prompts_in_library": 15,
  "prompts": [
    {
      "id": "prompt_1234567890",
      "prompt": "Full prompt text...",
      "similarity": "95.2%",
      "created": "2024-01-15T10:30:00",
      "source": "claude",
      "preview": "First 100 characters..."
    }
  ]
}

Store Response

{
  "status": "success",
  "prompt_id": "prompt_1234567890",
  "source": "claude",
  "stats": {
    "characters": 150,
    "words": 25
  },
  "total_prompts": 16
}

Get Response

{
  "status": "found",
  "prompt_id": "prompt_1234567890",
  "prompt_text": "Full prompt text...",
  "metadata": {
    "created": "2024-01-15T10:30:00",
    "source": "claude",
    "character_count": 150,
    "word_count": 25
  }
}

Development

Project Structure

MCP_Prompt_Library/
├── prompt_library_mcp_server.py  # Main server implementation
├── test_server.py                # Test suite
├── requirements.txt              # Python dependencies
├── pyproject.toml               # Project configuration
├── README.md                    # This file
└── chroma_db/                   # ChromaDB database files

Adding New Features

  1. New Tools: Add tool definitions in setup_handlers()

  2. Database Changes: Modify the metadata structure in store_prompt()

  3. Search Improvements: Enhance the search_prompts() method

Error Handling

The server includes comprehensive error handling:

  • Graceful handling of empty collections

  • Proper error messages for missing prompts

  • Exception catching with informative error responses

Troubleshooting

Common Issues

  1. "spawn python ENOENT": Make sure to use the virtual environment Python path in your MCP configuration

  2. "No such file or directory": Verify the paths in your MCP configuration match your actual project location

  3. Import errors: Ensure all dependencies are installed in your virtual environment

Debugging

  • Check the MCP server logs in Claude Desktop

  • Run test_server.py to verify functionality

  • Use direct execution mode for debugging

License

This project is licensed under the MIT License - see the LICENSE file for details.

Copyright (c) 2025 B Chahal

Contributing

Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      A local-only MCP server that uses SQLite to store, search, and manage a personal library of AI prompts. It enables developers to organize and reuse prompts across multiple AI clients like Claude and Cursor while keeping all data on their local machine.
      8 npm
      1
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      Provides persistent long-term memory and local RAG document search for Claude Desktop, fully offline. Enables memory save/search and document retrieval via MCP.
      MIT