Skip to main content
Glama

llms-txt-mcp

by tenequm

llms-txt-mcp

Fast documentation access for Claude Code via llms.txt parsing.

The Problem

Ever seen this error?

Error: MCP tool "fetch_docs" response (251,431 tokens) exceeds maximum allowed tokens (25,000)

You're not alone. This is mcpdoc failing on AI SDK documentation.

mcpdoc fails at scale:

  • 🐌 5+ second structure discovery
  • 💣 1,500 tokens wasted just to list sections
  • Timeouts on files like AI SDK's 30K+ line llms.txt
  • 🗑️ Context pollution - your conversation drowns in documentation dumps

AI SDK's documentation (ai-sdk.dev/llms.txt) breaks mcpdoc due to size.

The Problem in Action

Here's what happens when you try to get AI SDK documentation for building a chatbot:

mcpdoc: Token Limit Exceeded

> use mcpdoc to get ai-sdk documentation on how to build chatbot app ⏺ mcpdoc - fetch_docs(url: "https://ai-sdk.dev/llms.txt") ⎿ Error: MCP tool "fetch_docs" response (251,431 tokens) exceeds maximum allowed tokens (25,000). Please use pagination, filtering, or limit parameters to reduce the response size.

Result: 251,431 tokens attempted → Token limit exceeded

Context7: Drowning in Noise

⏺ Context7 - get-library-docs(topic: "chatbot building guide", tokens: 15000) ⎿ CODE SNIPPETS ======================== … +2380 lines (ctrl+r to expand)

Result: 15,000 tokens of context pollution

llms-txt-mcp

> Search for "chatbot" in AI SDK docs ⏺ docs_query(query: "chatbot", limit: 5, auto_retrieve: false) ⎿ Found 5 relevant sections (≈50 tokens)

Result: <100 tokens

Why This Exists

Built to solve the problem of large documentation files timing out or consuming excessive tokens.

Solution

OperationmcpdocContext7llms-txt-mcp
AI SDK Chatbot Docs251,431 tokens → ERROR15,000 tokens<100 tokens
Structure Discovery5+ seconds2-3 secondsFast
Context UsageFails completely15K tokens50 tokens
Large File SupportTimeoutsTruncatesStreams
AI SDK llms.txt (30K+ lines)FailsPartial132 sections

Token Usage

mcpdoc: [████████████████████████████████] 251K tokens → ERROR Context7: [████████████████] 15K tokens llms-txt: [▪] <100 tokens

Quick Start

# Install and run in one line (requires uv) uvx llms-txt-mcp https://ai-sdk.dev/llms.txt # Or install from source git clone https://github.com/tenequm/llms-mcp-txt.git cd llms-mcp-txt && uv sync uv run llms-txt-mcp https://ai-sdk.dev/llms.txt

For Claude Desktop:

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

{ "mcpServers": { "llms-txt-mcp": { "command": "uvx", "args": ["llms-txt-mcp", "https://ai-sdk.dev/llms.txt"] } } }

That's it. Claude Code can now access AI SDK docs instantly.

How It Works

URL → Parse YAML/Markdown → Embed → Search → Get Section

Key insight: Search first, fetch later. Never dump entire documentation.

  1. Parse: Handles both AI SDK's YAML frontmatter and standard markdown
  2. Index: Embeds sections with BAAI/bge-small-en-v1.5
  3. Search: Semantic search returns top-k results (default: 10)
  4. Get: Fetch exactly what you need with byte-capped responses

Features

🚀 Instant Startup

  • Lazy model loading for fast server startup
  • Preindexing with stale source detection
  • Background indexing - server available immediately

🎯 Surgical Access

  • Search first - find relevant sections without dumping everything
  • Byte-capped responses - protect your context window (default: 75KB)
  • Human-readable IDs - use canonical URLs like https://ai-sdk.dev/llms.txt#rag-agent

📦 Zero Config Required

# Just works uvx llms-txt-mcp https://ai-sdk.dev/llms.txt # Multiple sources? Easy uvx llms-txt-mcp https://ai-sdk.dev/llms.txt https://nextjs.org/llms.txt

🔄 Smart Caching

  • TTL-based refresh (default: 24h)
  • ETag/Last-Modified validation
  • Persistent storage option for instant subsequent starts

🎨 Claude Code Optimized

  • Minimal tool signatures
  • Predictable responses
  • No timeout surprises

Usage Examples

Search Documentation

// In Claude Code (search only) await docs_query({ query: "RAG agent", limit: 5, auto_retrieve: false }) // Returns tiny, focused results without content

Retrieve Specific Sections

// Auto-retrieve top matches (recommended) await docs_query({ query: "RAG agent", limit: 5, auto_retrieve: true, max_bytes: 75000, merge: false }) // Or retrieve explicit IDs await docs_query({ retrieve_ids: [ "https://ai-sdk.dev/llms.txt#rag-agent-000" ], max_bytes: 75000, merge: false })

List Available Sources

await docs_sources() // Returns: [ { host: "ai-sdk.dev", docCount: 132, lastIndexed: "2024-01-..." } ]

Configuration

Basic (Most Users)

uvx llms-txt-mcp https://ai-sdk.dev/llms.txt

With Options

uvx llms-txt-mcp https://ai-sdk.dev/llms.txt \ --ttl 1h # Refresh every hour --store disk # Persist embeddings --store-path ~/.llms-cache # Cache location

Advanced Flags

  • --max-get-bytes N - Byte limit for responses (default: 75000)
  • --embed-model MODEL - Change embedding model (default: BAAI/bge-small-en-v1.5)
  • --no-preindex - Disable automatic pre-indexing on startup
  • --no-background-preindex - Wait for indexing to complete before serving

Note: The default max-get-bytes is 75KB. In practice, going 80KB+ can push responses close to a 25,000-token cap in some clients, so 75KB is a safe default.

Performance

Benchmarks on AI SDK llms.txt (30K+ lines, 132 sections):

MetricPerformance
Parse timeFast (<2s for 30K+ lines)
Index time (first run)Fast initial indexing
Index time (cached)Instant (0ms)
Search latencyFast semantic search
Memory usageLightweight
Model sizeSmall embedding model

Test Results:

17 tests passing Fast parsing performance verified Minimal context usage confirmed Handles 30K+ line files without breaking

When to Use What

ToolBest ForAvoid When
llms-txt-mcpAI SDK, large docs, Claude Code, search-first accessYou need non-llms.txt formats
mcpdocSimple markdown files, small documentationLarge files, AI SDK docs, context matters
context7Broad knowledge base, multiple sourcesYou need freshness control, deterministic sources

Development

Setup

git clone https://github.com/tenequm/llms-mcp-txt.git cd llms-mcp-txt uv sync --all-extras

Development Workflow

# Run the tool uv run llms-txt-mcp --version # Run from anywhere uv run --directory /path/to/llms-mcp-txt llms-txt-mcp --version # Development commands uv run pytest # Run tests uv run ruff check . # Check code quality uv run ruff format . # Format code uv run mypy # Type check # With arguments uv run llms-txt-mcp https://ai-sdk.dev/llms.txt

Local Testing with Inspector

npx @modelcontextprotocol/inspector uv run llms-txt-mcp https://ai-sdk.dev/llms.txt https://nextjs.org/docs/llms.txt https://hono.dev/llms.txt https://orm.drizzle.team/llms.txt https://zod.dev/llms.txt https://docs.docker.com/llms.txt

Architecture

src/ ├── server.py # FastMCP server with all tools ├── parsers/ │ ├── __init__.py │ ├── format_detector.py │ └── parser.py # Multi-format llms.txt parsing └── __init__.py # Package exports

Key Design Decisions:

  • Simple, flat structure following KISS principles
  • Streaming parser for large file support
  • Lazy loading for instant startup
  • Search-first to minimize context usage

Contributing

Issues and PRs welcome! Please ensure:

  • Tests pass (uv run pytest)
  • Code is formatted (uv run ruff format .)
  • Types check (uv run mypy src/)

Credits

Built on FastMCP and the Model Context Protocol.

License

MIT - See LICENSE


-
security - not tested
A
license - permissive license
-
quality - not tested

remote-capable server

The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.

Enables fast, token-efficient access to large documentation files in llms.txt format through semantic search. Solves token limit issues by searching first and retrieving only relevant sections instead of dumping entire documentation.

  1. The Problem
    1. The Problem in Action
      1. mcpdoc: Token Limit Exceeded
      2. Context7: Drowning in Noise
      3. llms-txt-mcp
    2. Why This Exists
      1. Solution
        1. Token Usage
      2. Quick Start
        1. How It Works
          1. Features
            1. 🚀 Instant Startup
            2. 🎯 Surgical Access
            3. 📦 Zero Config Required
            4. 🔄 Smart Caching
            5. 🎨 Claude Code Optimized
          2. Usage Examples
            1. Search Documentation
            2. Retrieve Specific Sections
            3. List Available Sources
          3. Configuration
            1. Basic (Most Users)
            2. With Options
            3. Advanced Flags
          4. Performance
            1. When to Use What
              1. Development
                1. Setup
                2. Development Workflow
                3. Local Testing with Inspector
              2. Architecture
                1. Contributing
                  1. Credits
                    1. License

                      Related MCP Servers

                      • -
                        security
                        F
                        license
                        -
                        quality
                        Enables LLMs to perform semantic search and document management using ChromaDB, supporting natural language queries with intuitive similarity metrics for retrieval augmented generation applications.
                        Last updated -
                        Python
                        • Apple
                      • -
                        security
                        A
                        license
                        -
                        quality
                        Provides a semantic memory layer that integrates LLMs with OpenSearch, enabling storage and retrieval of memories within the OpenSearch engine.
                        Last updated -
                        4
                        Python
                        Apache 2.0
                      • A
                        security
                        F
                        license
                        A
                        quality
                        A server that helps discover and analyze websites implementing the llms.txt standard, allowing users to check if websites have llms.txt files and list known compliant websites.
                        Last updated -
                        2
                        668
                        63
                        JavaScript
                        • Apple
                      • -
                        security
                        A
                        license
                        -
                        quality
                        An MCP server that provides tools to load and fetch documentation from any llms.txt source, giving users full control over context retrieval for LLMs in IDE agents and applications.
                        Last updated -
                        578
                        Python
                        MIT License
                        • Apple

                      View all related MCP servers

                      MCP directory API

                      We provide all the information about MCP servers via our MCP API.

                      curl -X GET 'https://glama.ai/api/mcp/v1/servers/tenequm/llms-txt-mcp'

                      If you have feedback or need assistance with the MCP directory API, please join our Discord server