Documentation

MCP Server Setup

The Model Context Protocol (MCP) server exposes your corpora to AI assistants. Instead of manually running queries and pasting results, AI agents can explore the data directly—running searches, examining features, and iterating on queries autonomously.

Prerequisites

  • Python 3.10 or later
  • At least one Text-Fabric corpus
  • An MCP-compatible AI client (Claude Desktop, ChatGPT, or API integration)

Installation

Install Context-Fabric with MCP support:

bash
pip install context-fabric[mcp]

This installs the core library plus the MCP server components.

i

If you already have context-fabric installed, the same command adds MCP support—pip will install only the additional dependencies.

Running the Server

Single Corpus

The simplest configuration loads one corpus:

bash
cfabric-mcp --corpus /path/to/bhsa

The server starts and waits for MCP connections. You won't see much output—that's normal.

Multiple Corpora

Load several corpora at once:

bash
cfabric-mcp --corpus /path/to/bhsa --corpus /path/to/lxx --corpus /path/to/dss

Each corpus becomes available to the AI agent, which can switch between them or run comparative queries.

CLI Options

OptionDescription
--corpus PATHPath to a corpus directory (repeatable)
--default CORPUSSet the default corpus for queries
--log-level LEVELSet logging verbosity (DEBUG, INFO, WARNING, ERROR)

Available MCP Tools

Once connected, AI agents have access to these tools:

ToolPurpose
list_corporaShow available corpora
describe_corpusGet corpus structure overview
list_featuresBrowse available features
describe_featureGet detailed feature info with sample values
get_text_formatsSee text encoding options
searchRun search queries
search_continuePaginate through results
search_csvExport results to CSV file
search_syntax_guideGet help on query syntax
get_passagesRetrieve text by section reference
get_node_featuresGet feature values for specific nodes

Client Setup

Configure your AI client to connect to the MCP server:

Troubleshooting

"Server not found" or Connection Errors

  • Verify the command path is correct and executable
  • Check that Context-Fabric is installed with MCP support
  • Try running cfabric-mcp --help manually to confirm installation

"Corpus not found" Errors

  • Use absolute paths in the configuration
  • Verify the corpus directory exists and contains .tf or .cfm files
  • Check file permissions

Slow Startup

The first query after startup may take a few seconds as corpora load into memory. Subsequent queries are faster thanks to memory-mapped storage.