API Reference

Three ways to access knowledgelib.io programmatically: MCP server, REST API, or direct file access.

Option 1: MCP Server (Recommended)

The fastest path for Claude, Cursor, and any MCP-compatible client.

Installation

npx knowledgelib-mcp

Claude Desktop Configuration

{
  "mcpServers": {
    "knowledgelib": {
      "command": "npx",
      "args": ["knowledgelib-mcp"],
      "env": {
        "KNOWLEDGELIB_API_KEY": "your-api-key"
      }
    }
  }
}

Available Tools

ToolDescriptionParameters
query_knowledge Semantic search across all knowledge units query (string), domain (optional), limit (default: 3)
get_unit Retrieve a specific knowledge unit by ID unit_id (string)
list_domains List all available domains and unit counts None

Option 2: REST API

Base URL: https://knowledgelib.io/api/v1

Authentication

# Free tier: 1,000 queries/month, no key required for public endpoints
# Paid tier: API key in header
curl -H "Authorization: Bearer YOUR_API_KEY" \
  https://knowledgelib.io/api/v1/query?q=best+earbuds+2026

Endpoints

GET /api/v1/query

Semantic search across all knowledge units. Returns top matching units ranked by relevance.

# Request
GET /api/v1/query?q=best+wireless+earbuds+under+150&limit=3&domain=consumer_electronics

# Response
{
  "query": "best wireless earbuds under 150",
  "results": [
    {
      "id": "consumer-electronics/audio/wireless-earbuds-under-150/2026",
      "canonical_question": "What are the best wireless earbuds under $150 in 2026?",
      "confidence": 0.88,
      "last_verified": "2026-02-07",
      "relevance_score": 0.97,
      "url": "https://knowledgelib.io/consumer-electronics/audio/wireless-earbuds-under-150/2026",
      "raw_md": "https://knowledgelib.io/api/v1/units/consumer-electronics/audio/wireless-earbuds-under-150/2026.md",
      "token_estimate": 1800
    }
  ],
  "total_results": 1,
  "query_cost_tokens": 42
}

GET /api/v1/units/{unit_id}.md

Retrieve the raw markdown of a specific knowledge unit. This is the most token-efficient way to consume a unit.

# Request
GET /api/v1/units/consumer-electronics/audio/wireless-earbuds-under-150/2026.md

# Response: raw markdown with YAML frontmatter
# Content-Type: text/markdown; charset=utf-8

GET /api/v1/units/{unit_id}.json

Retrieve a knowledge unit as structured JSON (frontmatter parsed into fields, body as string).

# Response
{
  "id": "consumer-electronics/audio/wireless-earbuds-under-150/2026",
  "metadata": {
    "canonical_question": "What are the best wireless earbuds under $150 in 2026?",
    "confidence": 0.88,
    "last_verified": "2026-02-07",
    "sources": [...],
    ...
  },
  "body": "# Best Wireless Earbuds Under $150 (2026)\n\n## Summary\n..."
}

GET /catalog.json

Full catalog of all available knowledge units with metadata. No authentication required.

GET /.well-known/ai-knowledge.json

Discovery manifest describing the service, endpoints, and capabilities. No authentication required.

Option 3: Direct Web Fetch

Every knowledge unit has a public web page. AI agents using web search + web fetch can consume units directly:

  1. Web search finds the page (optimized for AI-style queries)
  2. Fetch the page — the body IS the markdown knowledge unit
  3. Optionally, read <meta name="ai:raw"> to get the raw .md URL

This requires zero setup. Any AI agent with web search capability can use knowledgelib.io.

Pricing

Simple per-request pricing: $0.10 per query. Still a win — agents typically burn $0.50-$5.00 in compute to get the same answer from raw web.

What you payWhat it replacesYour saving
$0.10 / query$0.50 - $5.00 in agent compute (3-5 web searches + parsing + reasoning)5x - 50x cost reduction

MCP server queries are billed the same way — every MCP tool call = one API request.

OpenAPI Specification

Full OpenAPI 3.0 spec available at: /api/v1/openapi.json

Compatible with LangChain, CrewAI, AutoGen, and any framework that supports OpenAPI tool definitions.