Qdrant MCP Server

Qdrant MCP Server

Enables semantic code search across codebases using Qdrant vector database and OpenAI embeddings, allowing users to find code by meaning rather than just keywords through natural language queries.

Category
访问服务器

README

Qdrant MCP Server

A Model Context Protocol (MCP) server that provides semantic code search capabilities using Qdrant vector database and OpenAI embeddings.

Features

  • 🔍 Semantic Code Search - Find code by meaning, not just keywords
  • 🚀 Fast Indexing - Efficient incremental indexing of large codebases
  • 🤖 MCP Integration - Works seamlessly with Claude and other MCP clients
  • 📊 Background Monitoring - Automatic reindexing of changed files
  • 🎯 Smart Filtering - Respects .gitignore and custom patterns
  • 💾 Persistent Storage - Embeddings stored in Qdrant for fast retrieval

Installation

Prerequisites

  • Node.js 18+
  • Python 3.8+
  • Docker (for Qdrant) or Qdrant Cloud account
  • OpenAI API key

Quick Start

# Install the package
npm install -g @kindash/qdrant-mcp-server

# Or with pip
pip install qdrant-mcp-server

# Set up environment variables
export OPENAI_API_KEY="your-api-key"
export QDRANT_URL="http://localhost:6333"  # or your Qdrant Cloud URL
export QDRANT_API_KEY="your-qdrant-api-key"  # if using Qdrant Cloud

# Start Qdrant (if using Docker)
docker run -p 6333:6333 qdrant/qdrant

# Index your codebase
qdrant-indexer /path/to/your/code

# Start the MCP server
qdrant-mcp

Configuration

Environment Variables

Create a .env file in your project root:

# Required
OPENAI_API_KEY=sk-...

# Qdrant Configuration
QDRANT_URL=http://localhost:6333
QDRANT_API_KEY=  # Optional, for Qdrant Cloud
QDRANT_COLLECTION_NAME=codebase  # Default: codebase

# Indexing Configuration
MAX_FILE_SIZE=1048576  # Maximum file size to index (default: 1MB)
BATCH_SIZE=10  # Number of files to process in parallel
EMBEDDING_MODEL=text-embedding-3-small  # OpenAI embedding model

# File Patterns
INCLUDE_PATTERNS=**/*.{js,ts,jsx,tsx,py,java,go,rs,cpp,c,h}
EXCLUDE_PATTERNS=**/node_modules/**,**/.git/**,**/dist/**

MCP Configuration

Add to your Claude Desktop config (~/.claude/config.json):

{
  "mcpServers": {
    "qdrant-search": {
      "command": "qdrant-mcp",
      "args": ["--collection", "my-codebase"],
      "env": {
        "OPENAI_API_KEY": "sk-...",
        "QDRANT_URL": "http://localhost:6333"
      }
    }
  }
}

Usage

Command Line Interface

# Index entire codebase
qdrant-indexer /path/to/code

# Index with custom patterns
qdrant-indexer /path/to/code --include "*.py" --exclude "tests/*"

# Index specific files
qdrant-indexer file1.js file2.py file3.ts

# Start background indexer
qdrant-control start

# Check indexer status
qdrant-control status

# Stop background indexer
qdrant-control stop

In Claude

Once configured, you can use natural language queries:

  • "Find all authentication code"
  • "Show me files that handle user permissions"
  • "What code is similar to the PaymentService class?"
  • "Find all API endpoints related to users"
  • "Show me error handling patterns in the codebase"

Programmatic Usage

from qdrant_mcp_server import QdrantIndexer, QdrantSearcher

# Initialize indexer
indexer = QdrantIndexer(
    openai_api_key="sk-...",
    qdrant_url="http://localhost:6333",
    collection_name="my-codebase"
)

# Index files
indexer.index_directory("/path/to/code")

# Search
searcher = QdrantSearcher(
    qdrant_url="http://localhost:6333",
    collection_name="my-codebase"
)

results = searcher.search("authentication logic", limit=10)
for result in results:
    print(f"{result.file_path}: {result.score}")

Architecture

┌─────────────────┐     ┌──────────────────┐     ┌─────────────────┐
│   Claude/MCP    │────▶│  MCP Server      │────▶│     Qdrant      │
│     Client      │     │  (Python)        │     │   Vector DB     │
└─────────────────┘     └──────────────────┘     └─────────────────┘
                               │                           ▲
                               ▼                           │
                        ┌──────────────────┐              │
                        │  OpenAI API      │              │
                        │  (Embeddings)    │──────────────┘
                        └──────────────────┘

Advanced Configuration

Custom File Processors

from qdrant_mcp_server import FileProcessor

class MyCustomProcessor(FileProcessor):
    def process(self, file_path: str, content: str) -> dict:
        # Custom processing logic
        return {
            "content": processed_content,
            "metadata": custom_metadata
        }

# Register processor
indexer.register_processor(".myext", MyCustomProcessor())

Embedding Models

Support for multiple embedding providers:

# OpenAI (default)
indexer = QdrantIndexer(embedding_provider="openai")

# Cohere
indexer = QdrantIndexer(
    embedding_provider="cohere",
    cohere_api_key="..."
)

# Local models (upcoming)
indexer = QdrantIndexer(
    embedding_provider="local",
    model_path="/path/to/model"
)

Performance Optimization

Batch Processing

# Process files in larger batches (reduces API calls)
qdrant-indexer /path/to/code --batch-size 50

# Limit concurrent requests
qdrant-indexer /path/to/code --max-concurrent 5

Incremental Indexing

# Only index changed files since last run
qdrant-indexer /path/to/code --incremental

# Force reindex of all files
qdrant-indexer /path/to/code --force

Cost Estimation

# Estimate indexing costs before running
qdrant-indexer /path/to/code --dry-run

# Output:
# Files to index: 1,234
# Estimated tokens: 2,456,789
# Estimated cost: $0.43

Monitoring

Web UI (Coming Soon)

# Start monitoring dashboard
qdrant-mcp --web-ui --port 8080

Logs

# View indexer logs
tail -f ~/.qdrant-mcp/logs/indexer.log

# View search queries
tail -f ~/.qdrant-mcp/logs/queries.log

Metrics

  • Files indexed
  • Tokens processed
  • Search queries per minute
  • Average response time
  • Cache hit rate

Troubleshooting

Common Issues

"Connection refused" error

  • Ensure Qdrant is running: docker ps
  • Check QDRANT_URL is correct
  • Verify firewall settings

"Rate limit exceeded" error

  • Reduce batch size: --batch-size 5
  • Add delay between requests: --delay 1000
  • Use a different OpenAI tier

"Out of memory" error

  • Process fewer files at once
  • Increase Node.js memory: NODE_OPTIONS="--max-old-space-size=4096"
  • Use streaming mode for large files

Debug Mode

# Enable verbose logging
qdrant-mcp --debug

# Test connectivity
qdrant-mcp --test-connection

# Validate configuration
qdrant-mcp --validate-config

Contributing

We welcome contributions! Please see CONTRIBUTING.md for guidelines.

Development Setup

# Clone the repository
git clone https://github.com/kindash/qdrant-mcp-server
cd qdrant-mcp-server

# Install dependencies
npm install
pip install -e .

# Run tests
npm test
pytest

# Run linting
npm run lint
flake8 src/

License

MIT License - see LICENSE for details.

Acknowledgments

Support

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选