Socket
Book a DemoInstallSign in
Socket

code-context-mcp

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

code-context-mcp

MCP server for semantic code search powered by MongoDB Atlas Vector Search and Voyage AI embeddings

latest
Source
npmnpm
Version
1.0.4
Version published
Weekly downloads
9
-40%
Maintainers
1
Weekly downloads
 
Created
Source

code-context-mcp

npm version License: MIT MCP Compatible

An MCP (Model Context Protocol) server that provides semantic code search capabilities to AI assistants using MongoDB Atlas Vector Search and Voyage AI embeddings.

🚀 Features

  • Semantic Code Search: Find relevant code based on meaning, not just keywords
  • MongoDB Atlas Vector Search: Unified platform for vectors and data
  • Voyage AI Embeddings: State-of-the-art code embeddings (MongoDB exclusive)
  • Native Hybrid Search: Combine vector and text search with MongoDB's $rankFusion
  • Real-time Sync: Automatic updates with MongoDB Change Streams
  • Multi-language Support: TypeScript, JavaScript, Python, Java, Go, Rust, C++

📋 Prerequisites

🔧 Installation

For Claude Desktop

# Install globally
npm install -g code-context-mcp

# Or use npx (recommended)
npx code-context-mcp

Configuration

Add to your Claude Desktop configuration:

macOS: ~/Library/Application Support/Claude/claude_desktop_config.json Windows: %APPDATA%\Claude\claude_desktop_config.json

{
  "mcpServers": {
    "code-context": {
      "command": "npx",
      "args": ["code-context-mcp"],
      "env": {
        "MONGODB_URI": "mongodb+srv://username:password@cluster.mongodb.net/",
        "VOYAGE_API_KEY": "va_xxx"
      }
    }
  }
}

For Other AI Assistants

Cursor

Add to ~/.cursor/mcp.json:

{
  "mcpServers": {
    "code-context": {
      "command": "npx",
      "args": ["code-context-mcp"],
      "env": {
        "MONGODB_URI": "mongodb+srv://...",
        "VOYAGE_API_KEY": "va_xxx"
      }
    }
  }
}

Windsurf

Add to your Windsurf configuration:

{
  "mcpServers": {
    "code-context": {
      "command": "npx",
      "args": ["code-context-mcp"],
      "env": {
        "MONGODB_URI": "mongodb+srv://...",
        "VOYAGE_API_KEY": "va_xxx"
      }
    }
  }
}

🛠️ Available Tools

The MCP server provides the following tools to AI assistants:

index_codebase

Index a codebase for semantic search.

{
  "path": "/path/to/project",
  "name": "my-project"
}

search_code

Search for code semantically.

{
  "projectPath": "/path/to/project",
  "query": "authentication middleware",
  "limit": 10,
  "threshold": 0.7
}

get_file_content

Retrieve specific file content.

{
  "projectPath": "/path/to/project",
  "relativePath": "src/auth.ts",
  "startLine": 10,
  "endLine": 50
}

list_indexed_projects

List all indexed projects.

clear_index

Clear the index for a project.

{
  "projectPath": "/path/to/project"
}

get_project_stats

Get statistics about an indexed project.

{
  "projectPath": "/path/to/project"
}

⚙️ Configuration

Environment Variables

VariableDescriptionRequiredDefault
MONGODB_URIMongoDB Atlas connection string-
VOYAGE_API_KEYVoyage AI API key-
MONGODB_DATABASEDatabase namecode_context
MONGODB_COLLECTIONCollection nameembeddings
VOYAGE_MODELVoyage AI modelvoyage-3.5
BATCH_SIZEEmbedding batch size10
MAX_FILE_SIZEMax file size (MB)10

Voyage AI Models

ModelBest ForPerformance
voyage-context-3RAG systems, long documents+14.24% vs OpenAI
voyage-3-largeHighest accuracy+9.74% vs OpenAI
voyage-3.5General purpose (default)+8.26% vs OpenAI
voyage-3.5-liteHigh throughput+6.34% vs OpenAI
voyage-code-3Source codeBest for code

🏗️ MongoDB Atlas Setup

1. Create a Vector Search Index

In MongoDB Atlas:

  • Navigate to your cluster
  • Click "Search" → "Create Search Index"
  • Choose "Atlas Vector Search"
  • Use this configuration:
{
  "fields": [{
    "type": "vector",
    "path": "embedding",
    "numDimensions": 1024,
    "similarity": "cosine"
  }]
}

2. Enable Hybrid Search (Optional)

For MongoDB 8.0+, create both vector and text indexes:

{
  "mappings": {
    "fields": {
      "embedding": {
        "type": "knnVector",
        "dimensions": 1024,
        "similarity": "cosine"
      },
      "content": {
        "type": "string",
        "analyzer": "lucene.standard"
      }
    }
  }
}

📊 Performance

Based on 2025 benchmarks:

  • Storage: 83% less than competitors with int8 quantization
  • Accuracy: Up to 14.24% better retrieval than OpenAI
  • Speed: Native hybrid search 30% faster
  • Cost: 96% storage reduction with binary quantization

🔍 Example Usage in Claude

Once configured, you can use natural language commands:

"Index my TypeScript project at /Users/me/my-project"

"Search for authentication middleware in my-project"

"Show me the implementation of the UserService class"

"Find all database connection code"

"What files handle error logging?"

🐛 Troubleshooting

Connection Issues

  • MongoDB Connection Failed

    • Verify your connection string
    • Check IP whitelist in Atlas
    • Ensure cluster is running
  • Voyage AI Authentication Failed

    • Verify API key is correct
    • Check API key has credits
  • MCP Not Responding

    • Check logs in stderr
    • Verify environment variables
    • Restart AI assistant

Debug Mode

Set DEBUG=true in environment variables for verbose logging:

{
  "env": {
    "DEBUG": "true",
    "MONGODB_URI": "...",
    "VOYAGE_API_KEY": "..."
  }
}

🤝 Contributing

Contributions are welcome! Please see our Contributing Guide.

📄 License

MIT License - see LICENSE for details.

Built with 💚 by MongoDB and Voyage AI

Keywords

mcp

FAQs

Package last updated on 07 Aug 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.