Skip to main content

Turn your API docs into an intelligent MCP server with deterministic routing and layered knowledge injection.

Project description

DocChat MCP

Turn your API docs into an intelligent MCP server with deterministic routing and layered knowledge injection.

English | 中文

PyPI version License: MIT

DocChat transforms your API documentation into a smart MCP server. AI coding assistants like Claude Code can query your API docs through natural language — with ~80% of queries resolved via deterministic routing (zero LLM cost).

Use Case

You're building an app that calls a third-party API. You want Claude Code to understand that API — parameters, response fields, error codes, best practices — so it can write correct integration code.

Your API docs → DocChat → MCP server (runs locally) → Claude Code queries it while coding

DocChat is the bridge: it turns your docs into structured knowledge that AI assistants can search and retrieve on demand.

How It Works

                          Your machine
┌───────────────────────────────────────────────────┐
│                                                   │
│  Claude Code ◄── stdio ──► docchat mcp            │
│    (LLM)                    (local process)       │
│      │                         │                  │
│      │ "How do I call          │ reads from       │
│      │  the users API?"        ▼                  │
│      │                    ./my-api-docs/           │
│      │                    ├── META.yaml            │
│      │                    ├── GUIDE.md             │
│      ▼                    └── ...                  │
│  Generates answer                                 │
│  using retrieved docs                             │
│                                                   │
└───────────────────────────────────────────────────┘

The engine handles routing + knowledge retrieval. The AI client handles reasoning. No external services, no extra LLM calls.

Quick Start

1. Install

pip install docchat-mcp

2. Create your knowledge pack

Option A: Import from OpenAPI spec (recommended)

docchat import your-api-spec.json

This parses your OpenAPI spec (JSON/YAML, v2.0/3.x) and generates feed skeletons + an AUTHORING.md guide. Then let your AI assistant fill in the details:

# In Claude Code (skill is auto-installed as /docchat-author)
> Help me improve the docs based on the spec

# In other AI tools
> Read AUTHORING.md and help me improve the docs

Option B: Let AI do everything

If you have a documentation URL or just a description of your API, skip import entirely — just tell your AI assistant:

> I need a docchat knowledge pack for the Petstore API.
  Docs: https://petstore.swagger.io
  Read AUTHORING.md for the format.

Option C: Start from scratch (manual)

docchat init --name my-api

Then create each feed directory manually. See docs/writing-guide.md for the format.

3. Validate and build

docchat validate    # Check format
docchat build       # Verify index loads correctly

4. Connect to Claude Code

# Register as a local MCP server (runs on your machine via stdio)
claude mcp add my-api -- docchat mcp --dir ./my-api-docs/

# Or via uvx (no prior install needed)
claude mcp add my-api -- uvx docchat-mcp mcp --dir ./my-api-docs/

That's it. Now when you ask Claude Code about your API, it queries DocChat's MCP server locally, retrieves the relevant docs, and generates accurate answers.

Team sharing (optional)

If you want multiple people to use the same knowledge pack:

# Start HTTP server on a shared machine
docchat serve --port 8000

# Team members connect remotely
claude mcp add my-api --transport http http://your-server:8000/mcp/

Features

  • Deterministic routing — trigger keywords, field names, and feed codes match queries without LLM
  • Layered knowledge injection — feed-level, overview, shared, and topic-matched knowledge
  • AI-assisted authoring — built-in docchat-author skill guides AI to generate complete knowledge packs from any source (spec files, URLs, or descriptions)
  • Custom dimensions — organize feeds by any hierarchy (product, version, region, etc.)
  • MCP native — 4 tools, 3 resources, 2 prompts — works with any MCP client
  • Zero LLM dependency — the engine only provides data; AI reasoning is done by the client
  • OpenAPI importdocchat import spec.json generates feed skeletons from OpenAPI specs (v2.0/3.x)
  • CLI toolinginit / import / build / validate / serve / mcp

Knowledge Pack Structure

my-api/
├── docchat.yaml          # Pack config (name, dimensions, assistant)
├── AUTHORING.md          # AI authoring guide (tool-agnostic)
├── .claude/skills/       # Claude Code auto-discovers this skill
│   └── docchat-author.md
├── _shared/              # Shared knowledge (error codes, auth, etc.)
│   ├── INDEX.yaml        # Topic keywords for matching
│   └── error_codes.md
├── _overview/            # API overview
│   └── INDEX.md
└── feeds/                # One directory per API endpoint
    ├── get-users/
    │   ├── META.yaml     # Triggers, fields, description
    │   ├── GUIDE.md      # Usage guide
    │   ├── FAQ.md        # Optional: troubleshooting
    │   └── fields/       # Optional: field reference
    └── get-posts/
        ├── META.yaml
        └── GUIDE.md

See docs/knowledge-pack-format.md for the full specification.

Custom Dimensions

Organize feeds by any hierarchy via docchat.yaml:

# Simple API (all feeds flat)
dimensions: []

# Two dimensions (product x sport)
dimensions:
  - key: product
    values: { rest: "REST API", ws: "WebSocket" }
  - key: sport
    values: { soccer: "Soccer", basketball: "Basketball" }

MCP Tools

Tool Description
list_feeds List all available feeds
search_by_field Find feeds by field name
get_feed_info Get feed details + documentation
route_question Route a query and return matched feeds + knowledge

Updating

Knowledge files changed (META.yaml, GUIDE.md, etc.): Restart Claude Code. The MCP server reloads on startup.

Engine updated (new docchat-mcp version):

pip install --upgrade docchat-mcp
# Then restart Claude Code

# If using uvx, clear cache first:
uv cache clean docchat-mcp

Why Not RAG?

Approach Limitation DocChat
Swagger UI Browse only, no Q&A Natural language queries
ChatGPT + docs Full context dump, token overflow Layered injection
RAG (embeddings) Embedding quality varies, routing opaque Deterministic routing (~80% zero LLM)
No MCP AI can't access docs MCP native, Claude Code direct

Demo

See it in action at docchat.site

License

MIT

Project details


Download files

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

Source Distribution

docchat_mcp-0.3.0.tar.gz (138.2 kB view details)

Uploaded Source

Built Distribution

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

docchat_mcp-0.3.0-py3-none-any.whl (32.8 kB view details)

Uploaded Python 3

File details

Details for the file docchat_mcp-0.3.0.tar.gz.

File metadata

  • Download URL: docchat_mcp-0.3.0.tar.gz
  • Upload date:
  • Size: 138.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.15

File hashes

Hashes for docchat_mcp-0.3.0.tar.gz
Algorithm Hash digest
SHA256 4c1556a0e1caadc25882da2a355b95ec4c240c996556ee3342f874b7d13ecde5
MD5 510dcd4ddb7c6c26294c4e94d9fbb78e
BLAKE2b-256 652f336f31e2b6ef035328bf096e8f0c4534b33d4d63a676da9add7d46b0f10b

See more details on using hashes here.

File details

Details for the file docchat_mcp-0.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for docchat_mcp-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4e45fbfa5241b6d9a090ce0eb92c8b3f4ac56f875c97bbb22c89aa1fcfa5083d
MD5 ce3b17d65d1e24a3cdaa9b12c40b3df6
BLAKE2b-256 0bd9354e9e8b551a7657283869e40bad163f472847c8573c5313947b3666cb8a

See more details on using hashes here.

Supported by

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