Skip to content

kcp-protocol/kcp

Repository files navigation

KCP — Knowledge Context Protocol

KCP — Knowledge Context Protocol

A new architectural layer for AI-generated knowledge governance.

KCP proposes "Layer 8" above the OSI Application Layer — a standard for publishing, discovering, verifying, and tracking the lineage of knowledge artifacts produced by AI agents.

🌐 Leia em Português


The Problem

AI agents generate valuable knowledge every day — analyses, reports, decisions, code reviews. But this knowledge:

  • Dies in chat sessions — no persistence, no discovery
  • Has no provenance — who created it? from what data? is it trustworthy?
  • Can't be shared — locked in proprietary formats and platforms
  • Has no lineage — when knowledge builds on other knowledge, there's no trail

The Solution

KCP defines a protocol for knowledge artifacts — signed, content-addressed, discoverable units of AI-generated knowledge with full lineage tracking.

┌────────────────────────────────────────────────────────┐
│  Layer 8: Knowledge & Context (KCP)                    │
│  Governance · Persistence · Discovery · Lineage        │
├────────────────────────────────────────────────────────┤
│  Layer 7: Application (HTTP, DNS, FTP)                 │
├────────────────────────────────────────────────────────┤
│  Layers 1-6: Transport, Network, etc.                  │
└────────────────────────────────────────────────────────┘

Key Features

  1. Signed artifacts — Every knowledge artifact is signed with Ed25519 for authenticity
  2. Content-addressed — SHA-256 hashing ensures integrity
  3. Lineage trackingderivedFrom chains show how knowledge evolves
  4. Three operating modes — Local (SQLite), Corporate Hub, Federated (P2P)
  5. Zero infrastructure — Works locally with no server, no config, no accounts
  6. Transparent to users — AI assistant skills abstract all complexity

SDK Status

SDK Language Tests Status
Python Python 3.13 · pytest 216 tests Production-ready
TypeScript Node.js 25 · Jest 37 tests Production-ready
Go Go 1.22 · go test 64 tests Production-ready
MCP Bridge Python · pytest-asyncio 23 tests Production-ready
Total 227 tests All passing

Public Peer Network

KCP peers are open nodes anyone can sync with. No account needed.

Peer URL Status Region
peer01 https://peer01.kcp-protocol.org ✅ Live South America
peer02 https://peer02.kcp-protocol.org ✅ Live South America
peer03 https://peer03.kcp-protocol.org ✅ Live South America
peer04 https://peer04.kcp-protocol.org ✅ Live South America
peer05 https://peer05.kcp-protocol.org ✅ Live South America
peer06 https://peer06.kcp-protocol.org ✅ Live South America
peer07 https://peer07.kcp-protocol.org ✅ Live South America
peer08 https://peer08.kcp-protocol.org ✅ Live South America

~8.000 artifacts seeded across the network. See live status at kcp-protocol.org/status.html

# Check peer health
curl https://peer01.kcp-protocol.org/kcp/v1/health

# Add peer and sync
kcp peer add https://peer01.kcp-protocol.org
kcp sync https://peer01.kcp-protocol.org --pull

Security: Public peers require the X-KCP-Client header on sync operations. The KCP SDK sends this automatically. Rate limits: 20 req/s (read), 10 req/s (write), 5 req/s (sync).

Quick Start

Install

# Install from source (PyPI package coming soon)
git clone https://github.com/kcp-protocol/kcp
cd kcp && make setup-python

Try it now (interactive demos)

git clone https://github.com/kcp-protocol/kcp
cd kcp
make setup-python            # create venv + install deps

# Demo 1 — cross-session: publish in one process, read in another
make demo                    # Session 1: publish 3 artifacts
make demo-read               # Session 2: NEW process reads, searches, verifies signatures

# Demo 2 — MCP tools: all 6 MCP tools working standalone (no editor needed)
make demo-mcp

# Demo 3 — peer sync: two nodes exchange knowledge over HTTP
make peer-demo

# Demo 4 — connect to your editor (Claude Desktop, Cursor, Windsurf)
make setup-mcp-claude        # auto-configures Claude Desktop
make setup-mcp-cursor        # auto-configures Cursor
make setup-mcp-windsurf      # auto-configures Windsurf

Use as library (no server)

from kcp import KCPNode

node = KCPNode(user_id="alice@example.com")

# Publish knowledge
artifact = node.publish(
    title="Rate Limiting Strategies",
    content="## Token Bucket\n\nThe most common approach...",
    format="markdown",
    tags=["architecture", "rate-limiting"],
)

# Search
results = node.search("rate limiting")

# Track lineage
derived = node.publish(
    title="Rate Limiting in gRPC",
    content="Building on general strategies...",
    derived_from=artifact.id,
)

CLI

kcp init
kcp publish --title "My Analysis" report.md
kcp search "authentication"
kcp serve --port 8800          # Web UI + P2P
kcp peer add https://peer.trycloudflare.com
kcp sync https://peer.trycloudflare.com

Web UI

Start the server and open http://localhost:8800/ui:

kcp serve

Operating Modes

Mode For Storage Config
🏠 Local Individual users SQLite (~/.kcp/kcp.db) None (zero config)
🏢 Hub Organizations PostgreSQL + S3 KCP_HUB=url
🌐 Federation Cross-org sharing Hub-to-hub sync Hub config

All modes use the same API. The backend is transparent to the user.

Documentation

Document Description
SPEC.md Full protocol specification
ARCHITECTURE.md Architecture, storage, P2P, security
Identity Guide 🔐 Backup & recovery of your KCP identity
AI_AGENT_GUIDE.md Integration guide for AI agents (LLMs, Copilot, Claude)
llms.txt LLM indexing manifest (llmstxt.org convention)
RFC-001-CORE.md Formal RFC (root)
RFC KCP-001 Formal RFC (detailed)
RFC KCP-002 KCP ↔ MCP Bridge — persistent artifacts as MCP context
MCP Server KCP MCP Server — Claude Desktop / Cursor / Windsurf integration
Whitepaper Academic paper
Comparison vs Semantic Web, MCP, etc.
Use Cases 10 real-world use cases
Roadmap 4-phase development plan
Presentation Executive presentation (PT-BR)
Python SDK Python SDK documentation
Go SDK Go SDK documentation
TypeScript SDK TypeScript SDK documentation
Testing Guide Running & writing tests for all SDKs
Contributing Contribution guidelines

🔐 Identity & Recovery

Your KCP identity is your cryptographic signature — it proves you created your knowledge artifacts.

Create Identity (first time)

kcp identity create

This generates a 12-word recovery phrase like:

abandon ability able about above absent absorb abstract absurd abuse access accident

⚠️ Write these words down and store safely! Anyone with these words has your identity.

Recover Identity (new computer)

kcp identity recover

Enter your 12 words and your identity is restored — same Node ID, same signature, same access to your private artifacts.

Learn More

  • 📖 Full Identity Guide — backup strategies, security tips, FAQ
  • 🔒 Uses BIP-39 standard (same as crypto wallets)

Project Structure

kcp/
├── SPEC.md                    # Protocol specification
├── ARCHITECTURE.md            # Architecture & design
├── demo.py                    # Cross-session demo (make demo + make demo-read)
├── demo_mcp.py                # MCP tools demo — 6 tools standalone (make demo-mcp)
├── Makefile                   # All tasks: test, demo, setup-mcp-*
├── sdk/
│   ├── python/                # Python SDK (reference implementation)
│   ├── go/                    # Go SDK (Go 1.22, 64 tests ✅)
│   └── typescript/            # TypeScript SDK (37 tests ✅)
├── mcp-server/                # MCP Bridge (23 tests ✅)
│   ├── kcp_mcp_server/
│   │   └── server.py          # 6 MCP tools: publish, search, get, lineage, list, stats
│   ├── setup_mcp.py           # Auto-configure Claude Desktop / Cursor / Windsurf
│   └── tests/                 # 23 async tests
├── rfcs/                      # Formal RFCs (KCP-001, KCP-002)
├── docs/                      # Documentation + landing page
│   ├── index.html             # Landing page (kcp-protocol.org)
│   ├── assets/                # Logo SVGs + social card
│   └── *.md                   # Whitepaper, comparison, use-cases, roadmap
└── examples/                  # Example payloads

Contributing

See CONTRIBUTING.md. All contributions welcome — code, docs, use cases, translations.

License

MIT


Author: Thiago Silva
Status: Beta — protocol stable, ecosystem expanding
Feedback: Open an issue

About

Knowledge Context Protocol — A new architectural layer for AI-generated knowledge governance

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors