Skip to main content

An MCP server to expose Memvid functionalities to AI clients

Project description

Memvid MCP Server 🎥

A Model Context Protocol (MCP) server that exposes Memvid video memory functionalities to AI clients. This server allows you to encode text, PDFs, and other content into video memory format for efficient semantic search and chat interactions.

🌟 Features

  • Text Encoding: Add text chunks or full text documents to video memory
  • PDF Processing: Extract and encode content from PDF files
  • Video Memory Building: Generate compressed video representations of your data
  • Semantic Search: Query your encoded data using natural language
  • Chat Interface: Have conversations with your encoded knowledge base
  • Multi-Connection Support: Handle multiple concurrent client connections
  • Comprehensive Logging: Detailed logging to stderr for debugging
  • Graceful Shutdown: Proper resource cleanup and signal handling

📋 Requirements

  • Python 3.10 or higher
  • uv package manager
  • memvid package
  • MCP-compatible client (e.g., Claude Desktop)

🚀 Installation

1. Set up the environment

cd /memvid_mcp_server
uv venv --python 3.12 --seed
source .venv/bin/activate

2. Install dependencies

uv add -e .

H.265 Encoding with Docker

The server automatically manages Docker installation and lifecycle:

  1. Automatic Docker Setup: If Docker is not installed, the server will install it automatically
  2. Container Management: The memvid package handles its own Docker container building and management
  3. Lifecycle Management: Docker daemon is started when MCP server starts

The memvid package (installed in the venv) contains all necessary Docker configurations and will automatically:

  • Build the memvid-h265 container when needed
  • Use Docker for H.265 encoding when codec='h265' is specified
  • Handle all container lifecycle internally

No manual Docker setup or external repository paths are required.h265using theDockerfilelocated in thedocker/` directory.

Once the Docker image is built, memvid will automatically detect and use it when video_codec='h265' is specified in build_video.

3. Test the server (optional)

uv run python memvid_mcp_server/main.py

⚙️ Configuration

Claude Desktop Setup

  1. Copy the example configuration:
cp example_mcp_config.json ~/.config/claude-desktop/config.json
  1. Or manually add to your Claude Desktop config:
{
  "mcpServers": {
    "memvid-mcp-server": {
      "command": "uv",
      "args": [
        "--directory",
        "/home/ty/Repositories/memvid_mcp_server",
        "run",
        "python",
        "memvid_mcp_server/main.py"
      ],
      "env": {
        "PYTHONPATH": "/home/ty/Repositories/memvid_mcp_server",
        "PYTHONWARNINGS": "ignore"
      }
    }
  }
}
  1. Restart Claude Desktop to load the server.

🛠️ Available Tools

get_server_status

Check the current status of the memvid server including version information.

add_chunks

Add a list of text chunks to the encoder.

  • chunks: List of text strings to add

add_text

Add a single text document to the encoder.

  • text: Text content to add
  • metadata: Optional metadata dictionary

add_pdf

Process and add a PDF file to the encoder.

  • pdf_path: Path to the PDF file

build_video

Build the video memory from all added content.

  • video_path: Output path for the video file
  • index_path: Output path for the index file
  • codec: Video codec to use ('h265' or 'h264', default: 'h265')
  • show_progress: Whether to show progress during build (default: True)
  • auto_build_docker: Whether to auto-build docker if needed (default: True)
  • allow_fallback: Whether to allow fallback options (default: True)

search_memory

Perform semantic search on the built video memory.

  • query: Natural language search query
  • top_k: Number of results to return (default: 5)

chat_with_memvid

Have a conversation with your encoded knowledge base.

  • message: Message to send to the chat system

📖 Usage Workflow

  1. Add Content: Use add_text, add_chunks, or add_pdf to add your data
  2. Build Video: Use build_video to create the video memory representation
  3. Search or Chat: Use search_memory for queries or chat_with_memvid for conversations

🔧 Development

Testing

# Install development dependencies
uv add --dev pytest pytest-asyncio black ruff mypy

# Run tests
uv run pytest

# Format code
uv run black memvid_mcp_server/
uv run ruff check memvid_mcp_server/

Debugging

  • Check logs in Claude Desktop: ~/Library/Logs/Claude/mcp*.log (macOS) or equivalent
  • Enable debug logging by setting LOG_LEVEL=DEBUG in environment
  • Use get_server_status tool to check server state

🔧 Troubleshooting

Common Issues

  1. JSON Parsing Errors: All output is properly redirected to stderr to prevent protocol interference
  2. Import Errors: The server gracefully handles missing memvid package with clear error messages
  3. Connection Issues: Check Claude Desktop logs and use get_server_status to diagnose issues
  4. Video Build Failures: Ensure sufficient disk space and valid paths

Logging Configuration

The server implements comprehensive stdout redirection to prevent any library output from interfering with the MCP JSON-RPC protocol:

  • All memvid operations are wrapped with stdout redirection
  • Progress bars, warnings, and model loading messages are captured
  • Only structured JSON responses are sent to Claude Desktop
  • All diagnostic information is logged to stderr

Error Messages

  • "Memvid not available": Install the memvid package: uv add memvid
  • "Video memory not built": Run build_video before searching or chatting
  • "LLM not available": Expected warning - memvid will work without external LLM providers

📄 License

MIT License - see the LICENSE file for details.

🤝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Submit a pull request

📚 Related Projects


Generated with improvements for production reliability and MCP best practices.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

iflow_mcp_angrysky56_memvid_mcp_server-0.2.1.tar.gz (358.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file iflow_mcp_angrysky56_memvid_mcp_server-0.2.1.tar.gz.

File metadata

  • Download URL: iflow_mcp_angrysky56_memvid_mcp_server-0.2.1.tar.gz
  • Upload date:
  • Size: 358.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.17 {"installer":{"name":"uv","version":"0.9.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for iflow_mcp_angrysky56_memvid_mcp_server-0.2.1.tar.gz
Algorithm Hash digest
SHA256 0735eb2a93d09e5278977e1ec3fb5edfcb4d225d84974be2fceeeb36222e2f74
MD5 5f924de62749600c4352e70edb87f9d8
BLAKE2b-256 29e81106a7bbd7b890c55f70314cad86f81b349d6a0e36dc738adaf737d8f243

See more details on using hashes here.

File details

Details for the file iflow_mcp_angrysky56_memvid_mcp_server-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: iflow_mcp_angrysky56_memvid_mcp_server-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 14.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.17 {"installer":{"name":"uv","version":"0.9.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for iflow_mcp_angrysky56_memvid_mcp_server-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 dedd0b85fd9761056ecc146f5d03ed2045f934587977bbbdb0e3ae64223b872b
MD5 26a7b0a6fd870475900e864e6d425bb7
BLAKE2b-256 9cc8bb8a518125b11e722985bf9b771fa68d8203a4c47364afc5f48a79f70965

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page