Skip to main content

Semantic Search MCP Server

Universal, schema-agnostic semantic search for any Neo4j knowledge graph.

One tool. Works everywhere. No configuration needed.

What It Does

Searches across ALL vector indexes in your Neo4j database using semantic similarity. Returns anything that matches your natural language query above a threshold.

Works with:

  • Any node type
  • Any relationship type
  • Any schema
  • Any knowledge graph with embeddings

Installation

1. Install Dependencies

pip install -r mcp_servers/semantic_search/requirements.txt

2. Configure Environment Variables

# Required
export OPENAI_API_KEY="sk-..."
export NEO4J_PASSWORD="your-password"

# Optional (defaults shown)
export NEO4J_URI="bolt://localhost:7687"
export NEO4J_USER="neo4j"
export EMBEDDING_MODEL="text-embedding-3-small"

3. Register with Claude Desktop

Add to ~/Library/Application Support/Claude/claude_desktop_config.json (macOS):

{
  "mcpServers": {
    "semantic-search": {
      "command": "python",
      "args": ["-m", "mcp_servers.semantic_search.server"],
      "cwd": "/path/to/your/e2r-rd",
      "env": {
        "OPENAI_API_KEY": "sk-...",
        "NEO4J_PASSWORD": "your-password"
      }
    }
  }
}

4. Restart Claude Desktop

Usage

The Tool: semantic_search

One simple tool with three parameters:

semantic_search(
    query: str,          # Natural language query
    limit: int = 10,     # Max results (max: 100)
    threshold: float = 0.7  # Min similarity (0-1)
)

Examples:

semantic_search("database failures")
semantic_search("kubernetes scaling", limit=20)
semantic_search("cache problems", threshold=0.8)

Returns:

Found 5 results matching 'database failures':

1. **Redis Cache** [Service] (similarity: 0.923) - mentioned 15 times
2. **PostgreSQL** [Service] (similarity: 0.887) - mentioned 12 times
3. **cache timeout** [Action] (similarity: 0.845) - mentioned 8 times
4. **database connection pool** [GenericEntity] (similarity: 0.821)
5. **connection failures** [Metric] (similarity: 0.798) - mentioned 6 times

How It Works

  1. Auto-discovers all vector indexes in your database
  2. Generates one embedding for your query (via OpenAI)
  3. Searches all indexes in parallel
  4. Filters by threshold
  5. Returns top results sorted by similarity

No schema knowledge required!

Prerequisites

Your Neo4j database needs:

  1. Nodes with embeddings - Any nodes with an embedding property (list of floats)
  2. Vector indexes - Created on the embedding properties

Create Vector Indexes

CREATE VECTOR INDEX my_index_name IF NOT EXISTS
FOR (n:MyNodeLabel) ON (n.embedding)
OPTIONS {indexConfig: {
    `vector.dimensions`: 1536,
    `vector.similarity_function`: 'cosine'
}}

Repeat for each node type that has embeddings.

Testing

# Set environment variables
export OPENAI_API_KEY="sk-..."
export NEO4J_PASSWORD="your-password"

# Run test script
python mcp_servers/semantic_search/test_search.py

Troubleshooting

No results found

Check:

  1. Neo4j is running
  2. Vector indexes are created (SHOW INDEXES in Neo4j)
  3. Nodes have embeddings populated
  4. Try lowering the threshold (default: 0.7)

Connection errors

Check:

  • Neo4j URI is correct
  • Neo4j password is correct
  • Network connectivity
  • Neo4j is running: docker ps or Neo4j Desktop

MCP server not appearing

Check:

  1. Claude Desktop config JSON is valid
  2. cwd path is absolute and correct
  3. Claude Desktop was restarted
  4. Check Claude Desktop logs for errors

Architecture

semantic_search/
├── config.py            # Environment configuration
├── semantic_search.py   # Core search engine
├── server.py            # MCP server
├── test_search.py       # Test script
└── README.md            # This file

Key Features

  • Schema-agnostic: Discovers indexes at runtime
  • Single embedding: Generated once, used everywhere
  • Parallel search: Searches all indexes simultaneously
  • Threshold filtering: Only returns good matches
  • Error resilient: Continues if one index fails
  • Simple interface: One tool, three parameters

Configuration Reference

Environment Variables

# Required
OPENAI_API_KEY         # OpenAI API key for embeddings
NEO4J_PASSWORD         # Neo4j password

# Optional
NEO4J_URI              # Default: bolt://localhost:7687
NEO4J_USER             # Default: neo4j
EMBEDDING_MODEL        # Default: text-embedding-3-small
DEFAULT_LIMIT          # Default: 10
MAX_LIMIT              # Default: 100

Tool Parameters

Parameter Type Default Description
query string required Natural language query
limit integer 10 Max results (max: 100)
threshold float 0.7 Min similarity (0-1)

Threshold Guide

  • 0.9+: Very strict, near-exact matches
  • 0.8-0.9: Strong semantic similarity
  • 0.7-0.8: Good matches (default range)
  • 0.6-0.7: Loose matches, more results
  • <0.6: Very loose, may include noise

Examples

Basic Search

semantic_search("monitoring alerts")

Strict Matching

semantic_search("postgresql database", threshold=0.85)

Broad Exploration

semantic_search("cloud infrastructure", limit=50, threshold=0.6)

Development

To modify the tool:

  1. Edit semantic_search.py to change search logic
  2. Edit server.py to change tool interface
  3. Run test_search.py to validate

License

Part of the e2r-rd project.

Metadata

Release files for neo4j-semantic-search-mcp 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for neo4j-semantic-search-mcp 0.1.0
File Size Uploaded
neo4j_semantic_search_mcp-0.1.0.tar.gz 7.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for neo4j-semantic-search-mcp 0.1.0
File Interpreter ABI Platform
neo4j_semantic_search_mcp-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 16.7 kB

Release files / neo4j_semantic_search_mcp-0.1.0.tar.gz

Download URL neo4j_semantic_search_mcp-0.1.0.tar.gz
Size 7.6 kB
Tags Source
SHA-256 checksum
How to use checksums
b707590338cb4094487e3c27f7d26ba13325911a5f9dc724a76fbba88694ffdc
BLAKE2b-256 checksum
How to use checksums
aadcab44b1b08581276e1fdf84c5bd3d6ce5e57c083b4b5b32d1b0b33d2f1691
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.7.3

Release files / neo4j_semantic_search_mcp-0.1.0-py3-none-any.whl

Download URL neo4j_semantic_search_mcp-0.1.0-py3-none-any.whl
Size 9.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e3cc35d9dbb1d17c157dec53c2d57cd9cd12cb56373b3ddcf4e18c7a8ef4654d
BLAKE2b-256 checksum
How to use checksums
eadbd613a453882e7bbc85059714de778d1681c1b66472721970078e3c48de0d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.7.3

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page