Skip to main content

A zero-config MCP server that turns any folder of documents into a queryable multi-agent knowledge base

Project description

kb-agent-mcp

A zero-config pip-installable MCP server that turns any folder of documents into a queryable, multi-agent knowledge base.

Connect it to Claude Desktop, Bob, Cursor, or any MCP-compatible AI tool — then ask questions in natural language.


Features

  • Zero configuration — point at a folder, run one command, start asking questions
  • Multi-domain routing — automatically routes questions to the right knowledge domain
  • README-first RAG — uses compact AUTO-INDEX blocks for fast answers; falls back to full-document search for complex/data questions
  • Passthrough mode — works with no local LLM; your AI tool answers using retrieved context
  • Supports all major document types — PDF, DOCX, XLSX (with streaming aggregation for large files), PPTX, MD, TXT, CSV, BoxNote
  • ChromaDB vector search — persistent, hash-based change detection (only re-indexes changed files)
  • Multi-session memory — per-session conversation history with configurable timeout
  • Hot-reloadkb-agent-watch keeps indexes in sync as you add/modify files
  • LLM providers — Ollama (local), OpenAI, Anthropic, any OpenAI-compatible endpoint

Quick Start

# Install
pip install kb-agent-mcp

# Run the setup wizard
cd /path/to/your/documents
kb-agent-setup

# Or manually: generate indexes and domain configs
kb-agent-generate

# Start the MCP server (stdio — for Claude Desktop / Bob)
kb-agent-serve

# Or HTTP/SSE
kb-agent-serve --transport http --port 8765

Installation

pip install kb-agent-mcp

# With OpenAI embeddings
pip install "kb-agent-mcp[openai]"

# With Anthropic
pip install "kb-agent-mcp[anthropic]"

# For development
pip install "kb-agent-mcp[dev]"

Requires Python 3.10+.


MCP Tools

Once the server is running, the following tools are available:

Tool Description
ask(question, format?, session_id?) Query all relevant domains and return a markdown answer
list_domains() List indexed knowledge domains with descriptions
reindex() Re-scan KB_ROOT and rebuild all ChromaDB indexes
clear_memory(session_id?) Clear conversation history for a session
show_memory(session_id?) Show current session state and recent history

ask examples

ask("What is IBM ACE?")
ask("What is our Q3 revenue by product?", format="table")
ask("Explain the architecture of CP4I", format="bullets")
ask("How many deals closed last quarter?", session_id="my-session")

Configuration

All configuration is via environment variables (or a .env file):

# Required
KB_ROOT=/path/to/your/KnowledgeBase

# LLM provider (default: ollama)
KB_LLM_PROVIDER=ollama          # ollama | openai | anthropic | custom | passthrough
KB_LLM_BASE_URL=http://localhost:11434
KB_MODEL=qwen3:14b
KB_API_KEY=                     # required for openai/anthropic/custom

# Embeddings
KB_EMBED_MODEL=                 # auto-detected from provider; or set explicitly

# Context budgets (chars, ~4 chars = 1 token)
KB_BUDGET_TOTAL=24000
KB_BUDGET_INDEX=8000
KB_BUDGET_FULL_README=24000
KB_BUDGET_RAG_FILE=4000

# Session memory
KB_SESSION_TIMEOUT_HOURS=2
KB_SESSION_MAX_TURNS=20
KB_SESSION_MAX_ANSWER_CHARS=400

# Ignore these top-level folders
KB_IGNORE_FOLDERS=archive,tmp

Passthrough mode

When KB_LLM_PROVIDER=passthrough (or when Ollama is unreachable and KB_PASSTHROUGH_FALLBACK is not false), the server automatically detects that no local LLM is available and returns the retrieved document context as clean markdown:

> **No local LLM detected.** Retrieved context is provided below —
> use it to answer the question.

### BizOps Agent
*Source: BizOps/Revenue.xlsx*

Q1 revenue: $1.2M
Q2 revenue: $1.5M

The calling AI tool (Claude, Bob, Cursor) receives this directly from the ask tool and can answer the question from the context — no special parsing or configuration needed on the client side.

To disable the automatic fallback (hard-fail instead):

KB_PASSTHROUGH_FALLBACK=false

This is the recommended mode for most users — no local model required.


Folder Structure

Each top-level folder under KB_ROOT becomes a knowledge domain:

~/KnowledgeBase/
  ACE Docs/          ← domain "ACE Docs"
    Installation.pdf
    API Reference.md
    domain_config.yaml   ← generated by kb-agent-generate
  BizOps/            ← domain "BizOps"
    Revenue.xlsx
    Won Deals.xlsx
    domain_config.yaml
  .kb_index/         ← ChromaDB + session memory (auto-created)
    chroma/
    session_memory/

Files in nested subfolders are indexed into their parent domain.


domain_config.yaml

Generated by kb-agent-generate, one per domain folder. Edit manually to tune the agent:

folder_name: BizOps
agent_name: BizOps Agent
description: Business operations — CP4I and ACE revenue, won deals, renewals
keywords:
  - revenue
  - quota
  - attainment
  - ACE
  - CP4I
top_n: 5
max_chars: 8000
system_prompt: |
  You are the BizOps Agent, a specialist in IBM APC region business data.
  CRITICAL: For revenue questions use only Revenue Report files (Rev Act @ PC column).
  Be concise, accurate, and cite the source file.
retrieval_rules:
  pin_files:
    - "*Revenue*.xlsx"      # always included for data questions
  boost_keywords:
    - revenue               # ranked to top of results
  question_classifier:
    data_patterns:
      - "\\brevenue\\b"     # regex → bypass README-first, use raw file content
    complex_patterns: []

CLI Commands

Command Description
kb-agent-setup Interactive setup wizard
kb-agent-generate Build ChromaDB indexes + generate domain_config.yaml
kb-agent-serve Start the MCP server
kb-agent-watch Watch for file changes and auto-update indexes

kb-agent-generate flags

kb-agent-generate               # incremental — skip unchanged
kb-agent-generate --force       # regenerate all domain_config.yaml files
kb-agent-generate --no-llm      # index only, use minimal YAML defaults
kb-agent-generate --domain Foo  # only process the "Foo" folder

kb-agent-serve flags

kb-agent-serve                           # stdio (Claude Desktop / Bob)
kb-agent-serve --transport http          # HTTP/SSE on port 8765
kb-agent-serve --transport http --port 9000
kb-agent-serve --version

Connecting to Claude Desktop

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

{
  "mcpServers": {
    "knowledge-base": {
      "command": "kb-agent-serve",
      "env": {
        "KB_ROOT": "/path/to/your/KnowledgeBase"
      }
    }
  }
}

Connecting to Bob

After running kb-agent-generate, a SKILL.md is auto-installed at:

~/.bob/skills/knowledgebase-agent/SKILL.md

Bob will automatically load it. Configure the server in your Bob MCP settings with:

{
  "command": "kb-agent-serve",
  "env": { "KB_ROOT": "/path/to/your/KnowledgeBase" }
}

Backward Compatibility

This package (kb-agent-mcp) is built alongside the original agents/ and scripts/ system. Nothing in the existing codebase is modified. Both systems can run independently from the same KB_ROOT.


Development

git clone <this-repo>
cd KnowledgeBase
pip install -e ".[dev]"
pytest tests/ -q

Releasing

Merging to main triggers the CI/CD pipeline, which automatically:

  1. Bumps the patch version in pyproject.toml (e.g. 0.1.00.1.1)
  2. Commits the bump back to main with [skip ci] to prevent re-triggering
  3. Builds the wheel + source distribution
  4. Publishes to PyPI as kb-agent-mcp

For a minor or major version bump (e.g. 0.2.0 or 1.0.0), manually edit version in pyproject.toml in your PR before merging — CI will auto-bump the patch on top of it.


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

kb_agent_mcp-0.1.2.tar.gz (63.8 kB view details)

Uploaded Source

Built Distribution

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

kb_agent_mcp-0.1.2-py3-none-any.whl (55.4 kB view details)

Uploaded Python 3

File details

Details for the file kb_agent_mcp-0.1.2.tar.gz.

File metadata

  • Download URL: kb_agent_mcp-0.1.2.tar.gz
  • Upload date:
  • Size: 63.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for kb_agent_mcp-0.1.2.tar.gz
Algorithm Hash digest
SHA256 ed1dbbaf5d609919d03ef76ed225886eb29e02a80dc80386e56a04d06a52ecf9
MD5 32150abcd76fd412a222631567dc847b
BLAKE2b-256 dc50d1a08eb7175a8c3f8d9959b03fa94a03a06371a2d8059af90bf8e6653c84

See more details on using hashes here.

Provenance

The following attestation bundles were made for kb_agent_mcp-0.1.2.tar.gz:

Publisher: publish.yml on amiya-anupam/kb-agent-mcp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file kb_agent_mcp-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: kb_agent_mcp-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 55.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for kb_agent_mcp-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c1959373f5e11a1fad2caa6ab5e6f31f2bdeb8ca4bb17b119eb703c362759120
MD5 0357d0d0bc8d4e924d22881c6748ef34
BLAKE2b-256 e9ba2bda20a0615890fc15f3e8de2660738b7a99acf884c3065419914e1c0e58

See more details on using hashes here.

Provenance

The following attestation bundles were made for kb_agent_mcp-0.1.2-py3-none-any.whl:

Publisher: publish.yml on amiya-anupam/kb-agent-mcp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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