JSPM

@writechoice/docusaurus-plugin-llms-txt

0.1.11
    • ESM via JSPM
    • ES Module Entrypoint
    • Export Map
    • Keywords
    • License
    • Repository URL
    • TypeScript Types
    • README
    • Created
    • Published
    • Downloads 76
    • Score
      100M100P100Q110787F
    • License MIT

    Docusaurus plugin that generates llms.txt, llms-full.txt, and .md routes for all pages

    Package Exports

    • @writechoice/docusaurus-plugin-llms-txt

    Readme

    @writechoice/docusaurus-plugin-llms-txt

    Docusaurus plugin that makes your documentation AI-readable at build time.

    • Generates /llms.txt — a structured index of all your pages following the llms.txt spec
    • Generates /llms-full.txt — all doc content merged into a single file in sidebar order
    • Serves every doc page as raw Markdown at /{path}.md
    • Injects a <link rel="alternate" type="text/plain" href="/llms.txt"> tag into every page
    • Optional functions/[[path]].js for Cloudflare Pages to handle Accept: text/markdown content negotiation
    • Optional MCP server that exposes your docs as tools AI clients (Claude Code, Cursor, Claude.ai) can query at runtime

    Installation

    npm install @writechoice/docusaurus-plugin-llms-txt

    Usage

    // docusaurus.config.js
    export default {
      plugins: ['@writechoice/docusaurus-plugin-llms-txt'],
    };

    With options

    export default {
      plugins: [
        [
          '@writechoice/docusaurus-plugin-llms-txt',
          {
            generateLlmsTxt: true,
            generateMarkdownFiles: true,
            generateLlmsFullTxt: true,
            description: 'API documentation for My Platform',
            deployTarget: 'cloudflare',
            generateMcp: true,
            maxMcpContent: 8000,
          },
        ],
      ],
    };

    Options

    Option Type Default Description
    generateLlmsTxt boolean true Write /llms.txt to the build output
    generateMarkdownFiles boolean true Write /{permalink}.md for each doc
    generateLlmsFullTxt boolean true Write /llms-full.txt with all docs merged
    description string '' Summary line in llms.txt (falls back to site tagline, then title)
    deployTarget string|null null Hosting target. Determines where deploy-specific files are written. Currently supports 'cloudflare'.
    generateMcp boolean false Generate an MCP server that exposes your docs as queryable tools. Requires deployTarget to be set.
    maxMcpContent number 8000 Maximum characters of content stored per page in the MCP index. Lower values reduce bundle size.

    What gets generated

    /llms.txt

    A plain-text index organized by sidebar section:

    # My Site
    
    > API documentation for My Platform
    
    ## Getting Started
    
    - [Introduction](/getting-started.md): Overview of the platform
    - [Authentication](/authentication.md): How to authenticate
    
    ## API Reference
    
    - [Endpoints](/api/endpoints.md)

    /{permalink}.md

    Each doc page is available as clean Markdown (frontmatter stripped, # Title prepended):

    GET /docs/introduction.md  →  # Introduction\n\nContent here...

    /llms-full.txt

    All docs concatenated in sidebar order, separated by ---, for feeding entire documentation to an LLM in one request.

    Cloudflare Pages function

    When deployTarget: 'cloudflare' is set, a functions/[[path]].js file is written to your project root during build. Cloudflare Pages picks it up alongside any other functions you have — it does not trigger Advanced Mode (_worker.js) and does not interfere with other routes in your functions/ folder. It intercepts requests with Accept: text/markdown and serves the pre-built .md file, enabling standard HTTP content negotiation.

    MCP server

    When generateMcp: true and deployTarget is set, the plugin generates two additional files during build:

    • functions/docs-data.json — a JSON index of all your docs (title, description, content, URL, version)
    • functions/mcp.js — a self-contained Cloudflare Pages Function that implements the Model Context Protocol over HTTP

    The MCP server exposes three tools:

    Tool Description
    list_docs Lists all indexed pages with title, path, and description
    get_doc Returns the full content of one or more pages by path (batch reads supported)
    search_docs Keyword search with relevance scoring; supports filtering by version and language

    The content served by these tools comes directly from the same .md pages the plugin generates — they are always in sync.

    Connecting an AI client

    After deploying, your MCP endpoint is available at https://your-site.pages.dev/mcp.

    Claude Code — add to .claude/settings.json in your project:

    {
      "mcpServers": {
        "docs": { "url": "https://your-site.pages.dev/mcp" }
      }
    }

    Cursor — Settings → MCP → Add server → paste the URL.

    Claude.ai — Settings → Integrations → Add → paste the URL.

    Future deploy targets

    generateMcp is designed to work alongside deployTarget. Support for additional targets (Vercel, Netlify) will generate the MCP function in the correct location for each platform automatically — no other changes needed.

    Compatibility

    Docusaurus Node
    >= 3.0.0 >= 18

    Companion package

    This plugin handles the build side — generating the files. To give users a Copy page button in the UI that lets them copy Markdown, open the page in ChatGPT or Claude, or view the raw .md directly, install the companion theme package:

    npm install @writechoice/docusaurus-theme-llms-txt

    Together they cover the full AI-readiness stack: the plugin makes your content machine-readable, the theme gives users the tools to use it.

    See @writechoice/docusaurus-theme-llms-txt for setup instructions.

    License

    MIT