Skip to main content

Full Text Search MCP

A full-text search server using Tantivy that can be used as both an MCP (Model Context Protocol) server and a Python library.

Installation

pip install -e .

Usage

Combined FastAPI + MCP Server (one process)

fts-mcp-plus-api --config example_config.yaml
# MCP served at /mcp, REST API at the root paths (e.g., /search, /fetch)

As an MCP Server (CLI)

python -m full_text_search.mcp \
    --data-file data.jsonl \
    --id-column id \
    --text-column content \
    --searchable-columns title content tags \
    --description "My document search index" \
    --host 0.0.0.0 \
    --port 8000

As a Python Library

The FullTextSearchMCP class can be imported and used programmatically:

from full_text_search.mcp import FullTextSearchMCP

# Create and initialize the search server
server = FullTextSearchMCP()
server.initialize(
    data_file="data.jsonl",
    id_column="id", 
    text_column="content",
    searchable_columns=["title", "content", "tags"],
    description="My search index"
)

# Use search functionality directly
results = server.search("python programming", limit=10)
print(results)

# Retrieve specific documents
docs = server.read_documents(["doc1", "doc2"])
print(docs)

# Or run as MCP server programmatically
server.run_server(host="localhost", port=8080)

Creating an MCP Server Instance

You can also create a FastMCP server instance for integration with other applications:

from full_text_search.mcp import FullTextSearchMCP

server = FullTextSearchMCP()
server.initialize(
    data_file="data.jsonl",
    id_column="id",
    text_column="content", 
    searchable_columns=["title", "content"],
    description="My search index"
)

# Get the FastMCP server instance
mcp_server = server.create_mcp_server()
# Use mcp_server with your preferred transport

Data Format

The input data should be in JSONL format (one JSON object per line):

{"id": "1", "title": "Python Basics", "content": "Introduction to Python programming..."}
{"id": "2", "title": "Advanced Python", "content": "Advanced concepts in Python..."}

Features

  • Full-text search using Tantivy search engine
  • Modular design - can be used as a library or standalone server
  • No global state - all functionality encapsulated in the FullTextSearchMCP class
  • MCP protocol support for integration with AI assistants
  • Flexible column mapping - specify which columns to search and how to identify documents
  • Document retrieval by ID for full content access

API Methods

FullTextSearchMCP.initialize()

Initialize the search index with your data.

Parameters:

  • data_file: Path to JSONL file containing documents
  • id_column: Name of column containing unique document IDs
  • text_column: Name of main text column for content
  • searchable_columns: List of column names to make searchable
  • description: Description of what this search index contains
  • index_path: Optional path for index storage (defaults to {data_file}_index)

FullTextSearchMCP.search(query, limit=5)

Search documents and return previews.

Parameters:

  • query: Search query string
  • limit: Maximum number of results to return

Returns: Formatted string with search results and previews

FullTextSearchMCP.read_documents(document_ids)

Retrieve full content for specific document IDs.

Parameters:

  • document_ids: List of document IDs to retrieve

Returns: Formatted string with full document content

FullTextSearchMCP.create_mcp_server()

Create a FastMCP server instance with search tools.

Returns: FastMCP server instance

FullTextSearchMCP.run_server(host="0.0.0.0", port=8000)

Run the MCP server.

Parameters:

  • host: Host address for the server
  • port: Port number for the server

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fts_mcp-0.0.13.tar.gz (80.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fts_mcp-0.0.13-py3-none-any.whl (96.7 kB view details)

Uploaded Python 3

File details

Details for the file fts_mcp-0.0.13.tar.gz.

File metadata

  • Download URL: fts_mcp-0.0.13.tar.gz
  • Upload date:
  • Size: 80.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.0

File hashes

Hashes for fts_mcp-0.0.13.tar.gz
Algorithm Hash digest
SHA256 e27a8ff1e669ee3c0dd5b5c1eacf4e7d96c6426eb87aa572d66c603a5c870d6e
MD5 b28a1005ed92f859924657cf5fad5bcb
BLAKE2b-256 5e781660b6cc7b1768ffab552bc8b50565fdf79ff08964a6473497d6bf1cba6e

See more details on using hashes here.

File details

Details for the file fts_mcp-0.0.13-py3-none-any.whl.

File metadata

  • Download URL: fts_mcp-0.0.13-py3-none-any.whl
  • Upload date:
  • Size: 96.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.0

File hashes

Hashes for fts_mcp-0.0.13-py3-none-any.whl
Algorithm Hash digest
SHA256 ffd4c15b2ca09407eb33fbcc41e0b865f55a7db4ac6671507f90d7993ba9f68c
MD5 ebf5c89cf0eabfa090c9e958eba38cb0
BLAKE2b-256 3e0bf2ddfdba656328deaeab8b31ffe583b586c58efce704f0c9974ba4e66570

See more details on using hashes here.

Release history Release notifications | RSS feed

0.0.14

2 files

This release

0.0.13 This release

2 files

0.0.12

2 files

0.0.11

2 files

0.0.10

2 files

0.0.8

2 files

0.0.7

2 files

0.0.6

2 files

0.0.5

2 files

0.0.4

2 files

0.0.3

2 files

0.0.2

2 files

0.0.1

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page