Skip to main content
Glama

Solr MCP

A Python package for accessing Apache Solr indexes via Model Context Protocol (MCP). This integration allows AI assistants like Claude to perform powerful search queries against your Solr indexes, combining both keyword and vector search capabilities.

Features

  • MCP Server: Implements the Model Context Protocol for integration with AI assistants

  • Hybrid Search: Combines keyword search precision with vector search semantic understanding

  • Vector Embeddings: Generates embeddings for documents using Ollama with nomic-embed-text

  • Unified Collections: Store both document content and vector embeddings in the same collection

  • Docker Integration: Easy setup with Docker and docker-compose

  • Optimized Vector Search: Efficiently handles combined vector and SQL queries by pushing down SQL filters to the vector search stage, ensuring optimal performance even with large result sets and pagination

Related MCP server: mssql-mcp

Architecture

Vector Search Optimization

The system employs an important optimization for combined vector and SQL queries. When executing a query that includes both vector similarity search and SQL filters:

  1. SQL filters (WHERE clauses) are pushed down to the vector search stage

  2. This ensures that vector similarity calculations are only performed on documents that will match the final SQL criteria

  3. Significantly improves performance for queries with:

    • Selective WHERE clauses

    • Pagination (LIMIT/OFFSET)

    • Large result sets

This optimization reduces computational overhead and network transfer by minimizing the number of vector similarity calculations needed.

Quick Start

  1. Clone this repository

  2. Start SolrCloud with Docker:

    docker-compose up -d
  3. Install dependencies:

    python -m venv venv
    source venv/bin/activate  # On Windows: venv\Scripts\activate
    pip install uv
    uv sync
  4. Process and index the sample document:

    python scripts/process_markdown.py data/bitcoin-whitepaper.md --output data/processed/bitcoin_sections.json
    python scripts/create_unified_collection.py unified
    python scripts/unified_index.py data/processed/bitcoin_sections.json --collection unified
  5. Run the MCP server (stdio transport, for local MCP clients):

    uv run run-server

For more detailed setup and usage instructions, see the QUICKSTART.md guide.

MCP client configuration

The server speaks MCP over stdio by default. Install and run it from Git with uv:

{
  "mcpServers": {
    "solr-mcp-server": {
      "command": "uvx",
      "args": [
        "--from",
        "git+https://github.com/kevinbtalbert/solr-mcp-python-stdio@main",
        "run-server"
      ],
      "env": {
        "SOLR_BASE_URL": "https://solr-app.yoururlhere.ylcu-atmi.cloudera.site/solr",
        "MCP_TRANSPORT": "stdio"
      }
    }
  }
}

Use this block in Cursor MCP settings, Claude Desktop, or Agent Studio MCP configuration.

Set SOLR_BASE_URL to your Solr Admin base URL (including the /solr path). The server uses plain HTTP/HTTPS with no login or API keys—suitable for open Solr endpoints. ZooKeeper is not required: when ZOOKEEPER_HOSTS is unset, collections are discovered through Solr’s HTTP API. For local SolrCloud with ZK directly reachable, optionally set ZOOKEEPER_HOSTS to a comma-separated list (e.g. localhost:2181).

MCP tools (Agent Studio / Claude)

Tool

Use for

list-collections

Discover collection names

get-schema

Field names and types before querying

search

Primary — Lucene /select (full text, filters, facets, sort)

sql-select

Solr SQL when you need it explicitly

semantic-select / vector-select

SQL + vector similarity (requires embeddings setup)

get-default-text-vectorizer

Embedding model dimensions for semantic search

After changing this repo, refresh the MCP server (restart the host or bump the git ref) so clients pick up new tool names. No mcp or ZooKeeper parameters are required in tool calls.

Local checkout

{
  "mcpServers": {
    "solr-mcp-server": {
      "command": "uvx",
      "args": [
        "--from",
        "file:///absolute/path/to/solr-mcp-python-stdio",
        "run-server"
      ],
      "env": {
        "SOLR_BASE_URL": "https://your-solr-host.example.com/solr"
      }
    }
  }
}

Transport

Set MCP_TRANSPORT to choose how the server connects to the client:

Value

Use case

stdio (default)

Cursor, Claude Desktop, and other subprocess-based MCP hosts

sse

HTTP/SSE deployment (e.g. run-server --transport sse --port 8000)

Requirements

  • Python 3.10 or higher

  • Docker and Docker Compose

  • SolrCloud 9.x

  • Ollama (for embedding generation)

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contributing

Contributions are welcome! Please see CONTRIBUTING.md for guidelines.

Available Tools

7 tools
get-default-text-vectorizerA

Get the default embedding model used for semantic-select.

Returns model name, vector dimensionality, and service URL. Use this to ensure Solr vector fields match the embedding model dimensions.

Inputs: no named parameters. Returns: result

get-schemaA

Retrieve schema information for a Solr collection.

Returns field definitions, field types, and copy-field relationships from the Schema API. Call this before search when you need valid field names or types.

Parameters:

  • collection: Solr collection name

Inputs: collection (required). Returns: result

list-collectionsA

List all available Solr collections in the cluster.

Inputs: no named parameters. Returns: result

semantic-selectA

Semantic (vector) search combined with SQL filtering (advanced).

Extends sql-select with semantic search: natural language text is embedded and matched against a dense_vector/knn_vector field. Results rank by similarity; ORDER BY is not allowed in query.

Parameters:

  • query: SQL query to execute

  • text: Natural language text converted to a vector for similarity search

  • field: Vector field name (optional; auto-detected when omitted)

  • vector_provider: Optional model@host:port (e.g. nomic-embed-text@localhost:11434)

Inputs: text (required), query (required), field, vector_provider. Returns: result

sql-selectA

Execute SQL SELECT queries against Solr (advanced).

Prefer the search tool for Lucene/full-text queries. Use this when you need Solr's SQL interface explicitly.

Collection/Field Rules:

  • Collections are used as table names (case-insensitive)

  • Field names are case-sensitive and must exist in Solr schema

  • SELECT * only allowed with LIMIT clause

  • Unlimited queries restricted to docValues-enabled fields

  • Reserved words must be backtick-escaped

WHERE Clause Differences:

  • Field must be on one side of predicate

  • No comparing two constants or two fields

  • No subqueries

  • Solr syntax in values:

    • '[0 TO 100]' for ranges

    • '(term1 term2)' for non-phrase OR search

  • String literals use single-quotes

Supported Features:

  • Operators: =, <>, >, >=, <, <=, IN, LIKE (wildcards), BETWEEN, IS [NOT] NULL

  • Functions: COUNT(*), COUNT(DISTINCT), MIN, MAX, SUM, AVG

  • GROUP BY: Uses faceting (fast) for low cardinality, map_reduce (slow) for high cardinality

  • ORDER BY: Requires docValues-enabled fields

  • LIMIT/OFFSET: Use 'OFFSET x FETCH NEXT y ROWS ONLY' syntax

    • Performance of OFFSET degrades beyond 10k docs per shard

Parameters:

  • query: SQL query to execute

Inputs: query (required). Returns: result

vector-selectA

Vector similarity search combined with SQL filtering (advanced).

Extends sql-select with a query vector matched against a dense_vector/knn_vector field. ORDER BY is not allowed in query.

Parameters:

  • query: SQL query to execute

  • vector: Query vector (dimensions must match the vector field)

  • field: Vector field name (optional; auto-detected when omitted)

Inputs: query (required), vector (required), field. Returns: result

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.9/5.0

    Scored across 7 tools

    Disambiguation4/5

    The four query tools (search, sql-select, semantic-select, vector-select) overlap in purpose, but descriptions explicitly steer agents—search for Lucene/full-text, sql-select for the SQL interface, and the two vector variants differ clearly by taking either natural-language text or a precomputed vector. Boundaries are mostly clear with only minor potential confusion between semantic-select and vector-select.

    Naming Consistency4/5

    All names use consistent kebab-case (get-default-text-vectorizer, list-collections, get-schema, sql-select, etc.), which is predictable and readable. Minor deviation: a few tools are noun-style rather than verb_noun (search, sql-select, vector-select), but the pattern is still coherent.

    Tool Count5/5

    Seven tools is well-scoped for a Solr query server, with each tool covering a distinct capability (listing, schema introspection, full-text search, SQL, semantic, vector, and vectorizer defaults). No filler or redundancy that would suggest bloat.

    Completeness3/5

    The read/query surface is fairly complete (collections, schema, multiple query modes), but there are no write operations—no document indexing/update/delete and no collection create/delete—which are core Solr lifecycle operations. Agents can search but cannot mutate data or manage collections, leaving notable gaps.

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      C
      maintenance
      Connects AI assistants to Obsidian vaults via the Local REST API to search notes, retrieve content, and perform semantic searches. It features self-healing multi-URL connectivity and supports both stdio and HTTP transports for flexible deployment.
      283 npm
      13
      MIT
    • A
      license
      A
      quality
      D
      maintenance
      Exposes any Microsoft SQL Server database to AI agents with multi-database support, keyword lookup, free SELECT queries, and three transport modes (stdio/SSE/Streamable HTTP).
      4
      1,789 npm
      MIT
    • A
      license
      A
      quality
      B
      maintenance
      Provides managed Apache Solr search as MCP tools, enabling hybrid retrieval, server-side GPU embeddings, document indexing, and grounded RAG answers without managing infrastructure.
      10
      MIT
    • F
      license
      A
      quality
      C
      maintenance
      Enables LLM agents to search and retrieve a hybrid knowledge base of manuals, videos, PDFs, DOCX files and images through tools for hybrid BM25-plus-vector search with facet and tag filters, full document retrieval, semantically similar document lookup, and timestamped video transcript segments. It ships with an in-memory backend for instant local use and an identical Elasticsearch backend for production deployment over stdio or authenticated HTTP.
      5
      -