Skip to main content
Glama
filesystem-rag-mcp

filesystem-rag-mcp

filesystem-rag-mcp

Local filesystem RAG MCP server combining vector/semantic search and full-text (BM25) search over files. Compliant with MCP spec 2026-07-28 / 2026-07-29, supporting both stdio and http (Streamable HTTP) transports, along with OAuth 2.1 authentication and Dynamic Client Registration (RFC 7591).

Features

  • MCP Protocol Conformance: Built against MCP specification 2026-07-28 (mcp[cli]>=1.21.0), supporting tool calling, resources (fs://stats, fs://config), and prompts (rag_query).

  • Universal File to Markdown Conversion:

    • Converts virtually any file type to clean, informative Markdown on demand:

      • Documents & Office: PDF, Word (DOCX/DOC), PowerPoint (PPTX/PPT), Excel (XLSX/XLS), RTF, EPUB.

      • Notebooks & Code: Jupyter Notebooks (.ipynb) with inputs/outputs/markdown, Python, JavaScript, TypeScript, Rust, Go, C/C++, Java, Shell, etc.

      • Structured Data: JSON, JSONL, YAML, TOML, XML, CSV, TSV, SQL.

      • Databases: SQLite (.sqlite, .db, .sqlite3) with schema extraction and row previews.

      • Archives: ZIP, TAR, TGZ manifests and directory listings.

      • Media & Audio: MP3, WAV, FLAC, OGG, M4A with metadata tags (ID3, Vorbis) and audio stream properties.

      • Images: Dimensions, format, color mode, and EXIF camera metadata.

      • Emails: .eml and RFC 822 messages with headers, body parts, and attachment lists.

      • Binary & Firmware: Formatted hexdump summaries with embedded printable ASCII string extraction.

  • Deep Content-Type Detection:

    • Integrates Google Magika AI and magic byte inspection so files are classified and converted accurately regardless of extension or missing extensions.

  • Dual Transports:

    • stdio: Standard input/output transport for local desktop assistants and CLI hosts (Claude Desktop, Hermes, etc.).

    • http: Modern Streamable HTTP transport for remote and web deployments.

  • Hybrid Search Architecture:

    • Full-Text: Fast embedded BM25 search via Whoosh with field boosting and prefix matching.

    • Vector / Semantic: Embedded ChromaDB with sentence-transformers embedding generation.

    • Reciprocal Rank Fusion (RRF): Merges sparse full-text and dense semantic scores without manual hyperparameter tuning.

  • OAuth 2.1 & Dynamic Client Registration (RFC 7591):

    • Supports RFC 7591 DCR (/register) to dynamically onboard MCP clients.

    • PKCE S256 code challenge verification.

    • RFC 8414 Authorization Server Metadata (/.well-known/oauth-authorization-server).

    • Protected Resource Metadata (/.well-known/oauth-protected-resource).

    • Strict Bearer token verification using cryptographic JWTs.

  • Path Security:

    • Directory traversal prevention (.., path symlink escapes).

    • Configurable inclusion/exclusion glob patterns.

Related MCP server: mcp-local-rag

Installation

Using uv:

git clone https://github.com/freyajeffers/filesystem-rag-mcp.git
cd filesystem-rag-mcp
uv venv
source .venv/bin/activate
uv pip install -e ".[dev]"

Running the Server

Stdio Transport (Default)

Ideal for desktop clients like Claude Desktop:

filesystem-rag-mcp --transport stdio --root-dir /path/to/my/documents

Streamable HTTP Transport with OAuth 2.1

filesystem-rag-mcp --transport http --host 127.0.0.1 --port 8000 --root-dir /path/to/my/documents

Streamable HTTP Transport without Auth (Dev Mode)

filesystem-rag-mcp --transport http --no-auth --host 127.0.0.1 --port 8000 --root-dir /path/to/my/documents

Available MCP Tools

  • ping:

    • Rapid health check and liveness probe verifying server connectivity, version, and active workspaces.

  • search:

    • Query parameters:

      • query (string, required): Natural language search query or keywords.

      • mode (string, default: "hybrid"): hybrid, fulltext, or semantic.

      • top_k (integer, default: 10): Maximum number of search hits.

      • alpha (float, default: 0.5): Weighting between full-text (0.0) and vector (1.0).

      • path_glob (string, optional): Glob pattern (e.g. src/**/*.py, docs/*.md) to filter search hits.

      • rerank (boolean, default: false): Apply neural cross-encoder reranking (FlashRank) over top candidates.

      • fuzzy (boolean, default: false): Enable typo-tolerant fuzzy matching / query term expansion for misspelled terms.

      • wait_for_indexing (boolean, default: false): If false, immediately executes searches using whatever index is currently available without blocking caller; if true, waits for background thorough indexing to complete.

    • Returns ranked search hits with match scores, source indexes, contextual snippets, and an index_state object notifying the caller of background indexing progress.

  • grep_search:

    • Fast, sandboxed regex or exact substring search across files with line numbers and context lines.

  • read_files_batch:

    • Concurrently reads and converts multiple files in a single tool call.

  • refresh_file:

    • Incrementally re-indexes a single file in <50ms without global disk traversal.

  • get_chunk_context:

    • Retrieves preceding and succeeding chunk neighbors around a given chunk_id.

  • deep_search:

    • Multi-hop search decomposing complex queries across topics and sub-queries with deduplicated chunk aggregation.

  • pack_context:

    • Assembles a clean, token-bounded Markdown prompt bundle (e.g. 4000 tokens) with contiguous chunk stitching.

  • get_corpus_graph:

    • Generates an architectural dependency and reference topology graph identifying system hubs and orphans.

  • git_search:

    • Safe local git inspection: commit history, diffs, and line-by-line blame without shell execution.

  • search_symbols:

    • Fast AST/regex extraction of function and class declarations across Python, JS/TS, and generic code.

  • find_symbol_references:

    • Finds call-sites, imports, and usages of symbols across workspace files with line numbers and snippet context.

  • patch_file:

    • Atomically patches files with exact substring replacement, sandboxed path validation, dry-run support, and immediate $<50\text{ms}$ incremental re-indexing.

  • add_workspace / list_workspaces:

    • Multi-root and monorepo scoping to register and search across multiple project paths dynamically.

  • list_directory:

    • Sandboxed tree/directory exploration tool.

    • Parameters:

      • rel_path (string, default: ""): Target folder inside workspace root.

      • max_depth (integer, default: 2): Traversal depth limit.

      • pattern (string, optional): Glob pattern filter for entries.

      • include_files (boolean, default: true): Include file entries.

      • include_dirs (boolean, default: true): Include directory entries.

      • limit (integer, default: 150): Maximum entries returned.

    • Returns file metadata, sizes, detected MIME/format labels, and convertibility flags.

  • get_index_status:

    • Query parameters:

      • wait (boolean, default: false): If true, synchronously waits for background indexing to finish before returning.

      • timeout_seconds (float, default: 30.0): Maximum duration to wait.

    • Returns live indexing status, indicating whether quick or thorough indexes are running or ready, plus chunk counts and timestamps.

  • fetch_targeted_data:

    • Fine-grained, targeted data extraction from structured and tabular files:

      • SQLite: Execute read-only SQL queries via query parameter (e.g. SELECT id, name FROM users WHERE active=1).

      • JSON / JSONL: Query paths via query parameter (e.g. users[0].address.city or config.database).

      • CSV / TSV: Select specific columns, apply row offsets/limits, and value match filters.

      • Text / Code: Extract exact line ranges via start_line and end_line.

  • read_file_markdown:

    • Automatically converts diverse document and data formats (PDF, DOCX, PPTX, XLSX, HTML, IPYNB, CSV, RTF, JSON, YAML, TOML, XML, code) to clean Markdown.

    • Returns { "rel_path", "abs_path", "markdown", "length_chars" }.

  • download_file_raw:

    • Downloads binary or text files as base64 with auto-detected MIME type and size headers.

    • Returns { "rel_path", "abs_path", "mime_type", "total_size_bytes", "returned_size_bytes", "truncated", "base64_data" }.

  • read_file:

    • Read plain text files with optional byte truncation.

  • get_chunk:

    • Inspect full chunk contents by ID.

  • refresh_index:

    • Force re-indexing of documents and chunk caching.

Configuration Generator & Presets

Generate ready-to-paste JSON client configs directly from the CLI:

# Print configs for Claude Desktop, Zed, and Hermes
filesystem-rag-mcp --config-snippet all

# Specific targets:
filesystem-rag-mcp --config-snippet claude
filesystem-rag-mcp --config-snippet zed
filesystem-rag-mcp --config-snippet hermes

System Diagnostics (--doctor)

Run immediate environment and health verification to check Python version, directories, core dependencies, optional document converters, and system tools:

# Interactive diagnostic output with checkmarks and suggestions
filesystem-rag-mcp --doctor

# Machine-readable JSON output for automated health probes
filesystem-rag-mcp --doctor --json

Operational & Performance Guards

  • Offline / Air-Gapped Mode: Use --offline / FSRAG_OFFLINE_MODE=1 to disable outbound HuggingFace network requests and operate strictly on cached weights.

  • Large File Protection: max_convert_file_bytes (default: 50MB) prevents OOM crashes on huge files by safely providing leading stream extracts.

  • Vector Binary Exclusion: By default, raw binary files falling back to hexdumps are indexed in BM25 full-text search but excluded from dense vector embeddings (index_binary_vectors=False) to avoid noise in vector similarity space.

  • Graceful Shutdown: Process termination cleanups are registered with atexit to flush persistent indexes and release file watcher threads cleanly.

Developer Workflow

Use the provided Makefile for standardized development, testing, and linting tasks:

make help        # Show all available development commands
make install     # Set up virtual environment and install in editable mode
make lint        # Run ruff lint checks
make format      # Format codebase with ruff
make typecheck   # Strict static type analysis with mypy
make test        # Run pytest test suite
make ci          # Run full local CI gate (format, lint, mypy, pytest)
make doctor      # Run environment diagnostic checks

License

MIT

Available Tools

23 tools
add_workspaceC

Register an additional workspace directory for multi-root monorepos or polyrepos.

Inputs: name (required), path (required). Returns: object

download_file_rawB
Read-only

Download/read a raw file as base64-encoded bytes with MIME type. Suitable for downloading binary files, images, PDFs, etc. Validated against root.

Inputs: rel_path (required), max_bytes. Returns: object

fetch_targeted_dataA

Execute targeted data fetching against structured files. Supports:

  • SQLite: SQL query via query parameter (e.g. 'SELECT * FROM users WHERE role="Admin"')

  • JSON/JSONL: path expression via query parameter (e.g. 'users[0].email' or 'config.db')

  • CSV/TSV: column filtering, row offsets/limits, and value match filters

  • Text/Code: line range extraction via start_line and end_line parameters.

Inputs: rel_path (required), query, columns, end_line, +5 more. Returns: object

find_symbol_referencesB
Read-only

Find call-sites, imports, and usages of a specific symbol across workspace code files. Returns occurrences with file paths, line numbers, usage classification ('import' vs 'reference'), and snippets.

Inputs: symbol_name (required), sub_dir, path_glob, workspace, +1 more. Returns: object

get_chunkB
Read-only

Fetch a single chunk by its id. Returns the chunk text and metadata.

Inputs: chunk_id (required). Returns: object

get_chunk_contextB
Read-only

Fetch contextual neighbor chunks surrounding a chunk_id from the same file. Expands awareness of the document before and after a search hit.

Inputs: chunk_id (required), after_chunks, before_chunks. Returns: object

get_corpus_graphB
Read-only

Construct an architectural dependency and reference topology graph of the workspace. Detects central architectural hubs (highest in-degree), file dependencies, and orphan files.

Inputs: sub_dir, max_files. Returns: object

get_index_statusA

Inspect the live indexing state: background quick/thorough task status, indexed text and vector chunk counts, and completion timestamps. Set wait=True and optional timeout_seconds to synchronously await index completion.

Inputs: wait, timeout_seconds. Returns: object

list_directoryC
Read-only

Explore the sandboxed filesystem tree. Returns directory/file metadata including size, detected MIME/type, conversion support, and relative path. Supports depth and glob filtering.

Inputs: limit, pattern, rel_path, max_depth, +3 more. Returns: object

list_workspacesA
Read-only

List all registered workspace roots and their status.

Inputs: no named parameters. Returns: object

pack_contextA
Read-only

Assemble a clean, token-bounded Markdown prompt context pack from search hits. Groups contiguous chunks by file, dedupes, and trims to strict token budgets (e.g. 4000 tokens).

Inputs: query (required), alpha, rerank, path_glob, +2 more. Returns: object

patch_fileA

Atomically patch a sandboxed file in the workspace by replacing an exact substring with new content. Automatically triggers immediate incremental re-indexing (<50ms) upon successful edit.

Inputs: rel_path (required), new_string (required), old_string (required), dry_run, +2 more. Returns: object

pingA
Read-only

Health check and liveness probe verifying server connectivity and runtime readiness.

Inputs: no named parameters. Returns: object

read_fileA
Read-only

Read a file's contents from the configured root. The path is validated against the root; symlinks that escape are refused.

Inputs: rel_path (required), max_bytes. Returns: object

read_file_markdownB
Read-only

Convert any document (PDF, DOCX, PPTX, XLSX, HTML, IPYNB, CSV, RTF, JSON, YAML, text, code) to clean Markdown. Validated against root.

Inputs: rel_path (required). Returns: object

read_files_batchA
Read-only

Inspect multiple files concurrently in a single roundtrip. Returns a mapping of relative paths to contents or structured error objects. Supports Markdown conversion (as_markdown=True) or raw text.

Inputs: rel_paths (required), as_markdown, max_bytes_per_file. Returns: object

refresh_fileB

Incrementally (re-)chunk and re-index a single specific file into full-text and vector stores in <50ms without walking the rest of the workspace.

Inputs: rel_path (required). Returns: object

refresh_indexA

Walk the configured root directory, (re-)chunk every text file, and (re-)embed + index all chunks. Safe to call repeatedly; stale chunks are evicted. May be slow on large corpora.

Inputs: full_rebuild. Returns: object

search_symbolsB
Read-only

Search for function and class declarations/definitions across Python, JS/TS, and generic code. Returns symbol names, lines, parameters, and docstrings without full text scanning.

Inputs: name, sub_dir, path_glob, workspace, +2 more. Returns: object

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    B3.4/5.0

    Scored across 23 tools

    Disambiguation4/5

    Most tools have clearly distinct purposes (search=hybrid semantic, grep_search=regex, search_symbols=declarations, find_symbol_references=usages, deep_search=multi-hop). There is mild overlap in the read family (read_file, read_file_markdown, download_file_raw, read_files_batch) and between refresh_index/refresh_file, but descriptions differentiate scope and format well.

    Naming Consistency4/5

    Predominantly consistent snake_case with a verb_noun pattern (get_chunk, read_file, add_workspace, list_workspaces, refresh_index). A few deviations break the pattern: 'ping' is a bare verb, and git_search/grep_search use noun_verb ordering, but overall the convention is predictable.

    Tool Count3/5

    23 tools sits in the heavy band for a single server. The domain is genuinely broad (search, indexing, git, multi-format reads, workspaces, graph analysis), so most tools earn their place, but several closely related read/search variants push it toward over-scoped.

    Completeness4/5

    Coverage of the RAG/filesystem lifecycle is strong: indexing, refresh (full and incremental), hybrid/regex/symbol search, chunk navigation, multi-format reads, git inspection, and workspace management are all present. The notable gap is write operations—only patch_file exists, with no create/delete file, limiting mutation workflows.

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      Not graded
      quality
      B
      maintenance
      Enables any MCP-compatible AI assistant to search, filter, and retrieve information from a local document collection using a hybrid search pipeline with vector, BM25, reranking, and LLM enrichment.
      4
      -
    • A
      license
      A
      quality
      D
      maintenance
      MCP server that enables local hybrid semantic and keyword search over private PDF, DOCX, Markdown, and text documents without sending data to embedding APIs.
      9
      MIT
    • A
      license
      B
      quality
      B
      maintenance
      Enables local hybrid search over Obsidian and Markdown vaults via MCP, combining vector retrieval, full-text search, reranking, graph navigation, and safe CRUD while keeping data local.
      43
      1
      MIT
    • F
      license
      Not graded
      quality
      Not graded
      maintenance
      Enables fast local hybrid search over a folder of markdown files via MCP, combining BM25 and vector similarity with explicit relevance verdicts and no LLM or network calls at query time.
      1
      -