neo4j-prefiltering-mcp
Automatically discovers vector indexes in a Neo4j database and exposes each as a semantic search tool with metadata pre-filtering, enabling natural language queries with dynamic filter support.
README
Neo4j Prefiltering Vector Search MCP Server
An MCP (Model Context Protocol) server that automatically discovers vector indexes in a Neo4j database and exposes each one as a semantic search tool. Built with FastMCP and LangChain embeddings, so it works with any embedding provider out of the box.
How It Works
On startup the server:
- Connects to Neo4j and runs
SHOW INDEXESto find everyVECTORindex. - Samples one node per indexed property to detect its type (string, numeric, date, bool, or vector).
- Identifies the embedding property and the remaining filterable metadata properties.
- Registers an MCP tool
search_<index_name>for each discovered index, complete with a dynamically generated description listing the available filters.
If no vector indexes are found, the server exits with an error.
Prerequisites
- Python 3.10+
- A running Neo4j instance (5.x+ with vector index support)
- At least one vector index already created in the database
- An API key or credentials for your chosen embedding provider
Installation
First, clone the repository:
git clone https://github.com/tomasonjo/neo4j-prefiltering-mcp.git
cd neo4j-prefiltering-mcp
Using uvx (recommended)
No installation needed — just run it directly from the local folder:
uvx --from /path/to/neo4j-prefiltering-mcp neo4j-prefiltering-mcp
Using pip
pip install /path/to/neo4j-prefiltering-mcp
Then run:
neo4j-prefiltering-mcp
Embedding providers
The base package does not include an embedding provider. Install the one you need as an extra:
# OpenAI
pip install "/path/to/neo4j-prefiltering-mcp[openai]"
# Cohere
pip install "/path/to/neo4j-prefiltering-mcp[cohere]"
# HuggingFace
pip install "/path/to/neo4j-prefiltering-mcp[huggingface]"
Or with uvx:
uvx --from /path/to/neo4j-prefiltering-mcp --with langchain-openai neo4j-prefiltering-mcp
Configuration
All configuration is done through environment variables.
| Variable | Default | Description |
|---|---|---|
NEO4J_URI |
bolt://localhost:7687 |
Neo4j connection URI |
NEO4J_USER |
neo4j |
Neo4j username |
NEO4J_PASSWORD |
password |
Neo4j password |
NEO4J_DATABASE |
neo4j |
Neo4j database name |
EMBEDDING_MODEL |
openai:text-embedding-3-small |
LangChain embedding model spec |
The EMBEDDING_MODEL value is passed directly to langchain.embeddings.init_embeddings(). Any provider string it supports will work:
# OpenAI
export EMBEDDING_MODEL="openai:text-embedding-3-small"
# Cohere
export EMBEDDING_MODEL="cohere:embed-english-v3.0"
# HuggingFace
export EMBEDDING_MODEL="huggingface:BAAI/bge-small-en-v1.5"
Make sure the corresponding provider SDK and API key env var are set (e.g. OPENAI_API_KEY, COHERE_API_KEY).
Usage
Claude Desktop
Add the server to your claude_desktop_config.json:
{
"mcpServers": {
"neo4j-vector": {
"command": "uvx",
"args": ["--from", "/path/to/neo4j-prefiltering-mcp", "--with", "langchain-openai", "neo4j-prefiltering-mcp"],
"env": {
"NEO4J_URI": "bolt://localhost:7687",
"NEO4J_USER": "neo4j",
"NEO4J_PASSWORD": "your-password",
"NEO4J_DATABASE": "neo4j",
"EMBEDDING_MODEL": "openai:text-embedding-3-small",
"OPENAI_API_KEY": "sk-..."
}
}
}
}
Claude Code
claude mcp add neo4j-vector -- uvx --from /path/to/neo4j-prefiltering-mcp --with langchain-openai neo4j-prefiltering-mcp
Standalone
neo4j-prefiltering-mcp
The server communicates over stdio by default, which is the standard transport for local MCP tool servers.
Cursor / Continue / Other MCP Clients
Point the client at the server as a stdio server. The exact config format varies by client — consult its docs and use the command + args pattern shown above.
Tool Interface
Each discovered index is exposed as a tool with the following parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
query |
str |
Yes | Natural-language search text (embedded at call time) |
top_k |
int |
No | Number of results to return (default 10) |
filters |
dict |
No | Metadata filters (keys and accepted types are index-specific) |
Filter Types
The server infers filter types by sampling a node from each index:
| Detected Type | Filter Format | Example |
|---|---|---|
float / int |
{"min": ..., "max": ...} |
{"min": 0.5, "max": 1.0} |
date |
{"min": "...", "max": "..."} |
{"min": "2024-01-01", "max": "2024-12-31"} |
bool |
true / false |
true |
string |
"exact value" |
"en" |
Both min and max are optional within a range filter — you can supply either or both.
Example Tool Call
Given an index called news_articles on :Article nodes with metadata properties language (string) and sentiment (float):
{
"name": "search_news_articles",
"arguments": {
"query": "recent breakthroughs in fusion energy",
"top_k": 5,
"filters": {
"language": "en",
"sentiment": { "min": 0.6 }
}
}
}
Response Format
The tool returns a JSON array of results, each containing the matched node's properties (minus the raw embedding vector) and a similarity score:
[
{
"doc": {
"title": "Fusion Milestone Reached at NIF",
"language": "en",
"sentiment": 0.92,
"published": "2025-01-15"
},
"score": 0.941
}
]
Project Structure
.
├── pyproject.toml
├── src/
│ └── neo4j_prefiltering_mcp/
│ ├── __init__.py
│ └── server.py
└── README.md
License
MIT
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。