Skip to main content

CKS MCP Server

Model Context Protocol server for Canonical Knowledge Structure.

Python License Tests PyPI

cks-mcp is an MCP (Model Context Protocol) server that gives LLMs a canonical knowledge backbone. It exposes the tools listed under Available Tools below, backed by the deterministic, immutable semantics of cks-core and the operational management of cks-runtime.

Every tool call creates a Runtime Session and Transaction, producing an immutable Version and collecting Diagnostics. This guarantees full auditability and reproducibility.


Ecosystem

CKS Core is the semantic foundation of the CKS ecosystem. Other projects build upon it:

Project Description Repository
cks-core Canonical semantic engine Deus-corp/cks-core
cks-runtime Operational environment – sessions, transactions, persistence Deus-corp/cks-runtime
cks-mcp MCP server – exposes CKS to LLMs (this repository) Deus-corp/cks-mcp

Quick Start

  1. Install and connect to Claude Desktop (see Installation).
  2. (Optional) For semantic search, set your Hugging Face token: export HF_TOKEN=hf_...
  3. In the chat, start your message with "Use cks-mcp to…".
  4. Claude automatically picks the right tool from the 18 available — validation, evolution, branching, merging, source verification, semantic search, subgraph queries, and more.
  5. Every operation is logged, versioned, and stored in a persistent SQLite database.

Just type "Use cks-mcp to..." and Claude does the rest. That's it. No programming, no command line — just a conversation!

CKS Demo

In the video above, Claude creates a validated knowledge graph about the water cycle from a single sentence, using validate_knowledge and explain_knowledge. Eighteen tools are ready for you: branching, merging, versioning, source verification, subgraph queries, and more — all triggered by plain English.


Why cks-mcp?

LLMs generate plausible but unverified statements. cks-mcp gives them a canonical knowledge backbone: every piece of information must be explicitly structured, validated against formal constraints, and traceable to its origin.

  • Eliminate citation hallucinations — optional extensions like embedding_projection mechanically detect references to non-existent sources.
  • Ensure verification integrity — the verify_source tool performs a real HTTP check and cryptographically signs the result. Any VerificationRecord without a valid signature is automatically rejected, even if the model fails to request the check.
  • Semantic search with real embeddings — the search_semantic tool uses HuggingFace models to find relevant nodes by meaning, not just keywords. A query for "how to train AI models" returns "Gradient Descent" and "Neural Network", not "Banana".
  • Graph-based RAG — combine semantic search with query_subgraph to retrieve a full neighbourhood around the found concepts, giving the LLM the context it needs without hallucinating connections.
  • Full audit trail — every operation is captured in an immutable version history, providing complete accountability for AI-generated knowledge.
  • Time-travel debugginglist_versions, revert_version, and compare_versions give LLMs a full version-control system for knowledge, enabling safe rollbacks and change inspection.

Installation

pip install cks-mcp

The server requires cks-runtime (which includes cks-core) as a dependency.

For semantic search, you also need a Hugging Face token:

export HF_TOKEN=hf_...

Connect to Claude Desktop

  1. Install all three packages into a single virtual environment:

    python3 -m venv cks-env
    source cks-env/bin/activate
    pip install cks-core cks-runtime cks-mcp
    
  2. Open Claude Desktop, go to Settings → Developer → Edit Config. The configuration file (claude_desktop_config.json) will open. Add the following block (adjust the path to your cks-mcp executable):

    {
      "mcpServers": {
        "cks-mcp": {
          "command": "/absolute/path/to/cks-env/bin/cks-mcp"
        }
      }
    }
    
  3. Save the file and fully restart Claude Desktop (Cmd+Q, then reopen). After restart, a connector icon will appear – cks-mcp with eighteen tools is ready to use.


Available Tools

Tool Description
validate_knowledge Validate a Knowledge Structure and return diagnostics. Supports opt‑in extensions (embedding_projection, verification_record). Provenance of VerificationRecord objects is checked automatically.
serialize_knowledge Serialize a Knowledge Structure into canonical JSON.
explain_knowledge Produce a semantic explanation of a Knowledge Structure.
evolve_knowledge Apply Genesis/Decay operators to evolve a structure.
verify_source Perform a real HTTP request to check a URL's availability and create a cryptographically signed VerificationRecord.
list_versions List all available versions of a session's history.
compare_versions Compute the structural difference between the current state of a session and a target version.
revert_version Revert a session's Knowledge Structure to a specific previous version.
merge_knowledge Three-way merge of knowledge structures with conflict detection.
create_branch Fork a new session from an existing one, optionally from a specific historical version.
merge_branch Session-aware three-way merge: merge a branch session into a target session, resolving the merge base automatically from the branch's recorded fork point.
close_session Close a session, releasing it from the runtime (e.g. a branch already merged in).
query_subgraph Extract a local k‑hop neighbourhood from a session's Knowledge Structure, with filters, optional budget, and compact mode.
search_semantic Real embedding-based semantic search. Uses HuggingFace models to find relevant objects by meaning. Query "virtual machines" returns EC2, not S3.
get_metrics Return runtime metrics: invocation counts and average execution times per operation type.
visualize_graph Export a session's Knowledge Structure or a subgraph as a Mermaid diagram for native rendering in Claude Desktop.
explain_diff Produce a natural-language explanation of changes between two versions, complementing compare_versions.
suggest_evolution Inspect the current state of a session and receive guidance for constructing valid evolution operations.

Usage Examples

Semantic search (no seed IDs required!)

{
  "method": "tools/call",
  "params": {
    "name": "search_semantic",
    "arguments": {
      "session_id": "...",
      "query": "virtual machines in the cloud"
    }
  }
}

Response:

{
  "status": "success",
  "matched_seeds": ["ec2", "compute-service", "aws"],
  "subgraph": "...",
  "meta": { ... }
}

Compact subgraph query

{
  "method": "tools/call",
  "params": {
    "name": "query_subgraph",
    "arguments": {
      "session_id": "...",
      "seed_ids": ["earth", "mars"],
      "depth": 2,
      "compact_mode": true
    }
  }
}

Response (compact, token-efficient):

{
  "nodes": [
    {"id": "earth", "type": "Planet", "name": "Earth", "props": {...}},
    {"id": "mars", "type": "Planet", "name": "Mars", "props": {...}}
  ],
  "edges": [
    {"source": "earth", "target": "sun", "type": "orbits"}
  ]
}

Validate a structure with citation-hallucination detection

Pass "extensions": ["embedding_projection"] to validate_knowledge. This activates an extra constraint that checks every EmbeddingProjection object for a valid represents relation to an existing source object. A projection that references a non‑existent source (a fabricated citation) is mechanically flagged.

Validate a structure with verification integrity

When you use verify_source to check a URL, the resulting VerificationRecord is cryptographically signed. Any VerificationRecord found in a structure without a valid signature is automatically rejected, even if the model does not explicitly request the verification extension. This prevents LLMs from bypassing the check by simply omitting a parameter.

Basic validation

{
  "method": "tools/call",
  "params": {
    "name": "validate_knowledge",
    "arguments": {
      "json_data": "{\"objects\":[{\"identity\":{\"id\":\"obj-1\",\"type\":\"Definition\",\"name\":\"Test\"},\"structure\":{}}]}"
    }
  }
}

Response (with version and session information):

{
  "result": {
    "content": [
      {
        "type": "text",
        "text": "{\"valid\": true, \"version_id\": \"...\", \"session_id\": \"...\", \"diagnostics\": [], ...}"
      }
    ]
  }
}

Compare two versions

{
  "method": "tools/call",
  "params": {
    "name": "compare_versions",
    "arguments": {
      "session_id": "...",
      "target_version_id": "..."
    }
  }
}

Response:

{
  "result": {
    "content": [
      {
        "type": "text",
        "text": "{\"session_id\": \"...\", \"target_version_id\": \"...\", \"changes\": [...]}"
      }
    ]
  }
}

Branch, evolve independently, and merge back

Fork a session, evolve the branch and its parent independently, then merge the branch back in:

{"method": "tools/call", "params": {"name": "create_branch",
  "arguments": {"session_id": "trunk-session-id"}}}
{"method": "tools/call", "params": {"name": "evolve_knowledge",
  "arguments": {"session_id": "branch-session-id", "operations": [...]}}}
{"method": "tools/call", "params": {"name": "merge_branch",
  "arguments": {"target_session_id": "trunk-session-id",
                "source_session_id": "branch-session-id"}}}

A successful merge commits a new version of the target session and returns its serialized structure and version_id. A conflicting merge instead returns "merged": false with a conflicts list (object_id, base_state, target_state, source_state) — resolve each one on the target session with evolve_knowledge, then close_session the branch once it's fully integrated.


Query a subgraph

{
  "method": "tools/call",
  "params": {
    "name": "query_subgraph",
    "arguments": {
      "session_id": "...",
      "seed_ids": ["obj-1"],
      "depth": 2,
      "max_objects": 10
    }
  }
}

Response (truncated example):

{
  "result": {
    "content": [
      {
        "type": "text",
        "text": "{\"subgraph\": \"...\", \"total_found_nodes\": 15, \"returned_nodes\": 10, \"is_truncated\": true, \"suggested_next_seed\": \"obj-7\"}"
      }
    ]
  }
}

Visualize a knowledge graph

{
  "method": "tools/call",
  "params": {
    "name": "visualize_graph",
    "arguments": {
      "session_id": "..."
    }
  }
}

Response (Mermaid diagram):

```mermaid
graph TD
    earth((Earth))
    sun((Sun))
    earth -->|orbits| sun
```

Explain the difference between two versions

{
  "method": "tools/call",
  "params": {
    "name": "explain_diff",
    "arguments": {
      "session_id": "...",
      "base_version_id": "...",
      "target_version_id": "..."
    }
  }
}

Response:

{
  "summary": "Added 2 objects and 1 relation. Modified 1 object.",
  "changes": [
    "Added object 'Pluto' (type: Planet)",
    "Added object 'Charon' (type: Moon)",
    "Added relation 'orbits' from 'Pluto' to 'Charon'",
    "Modified object 'Earth': changed 'status' from 'active' to 'inactive'"
  ]
}

Get AI assistance with evolution

{
  "method": "tools/call",
  "params": {
    "name": "suggest_evolution",
    "arguments": {
      "session_id": "...",
      "description": "Add a new planet Neptune that orbits the Sun"
    }
  }
}

Response:

{
  "current_objects": [
    {"id": "sun", "type": "Star", "name": "Sun"},
    {"id": "earth", "type": "Planet", "name": "Earth"},
    {"id": "moon", "type": "Moon", "name": "Moon"}
  ],
  "current_relations": [
    {"type": "orbits", "from": "earth", "to": "sun"},
    {"type": "orbits", "from": "moon", "to": "earth"}
  ],
  "guidance": "To add a new planet Neptune: use add_object with identity {id: 'neptune', type: 'Planet', name: 'Neptune'} and add_relation with participants ['neptune', 'sun'] and relation_type 'orbits'."
}

Security and Provenance

verify_source includes built-in protections:

  • SSRF prevention: URLs are validated against a strict allowlist; private, loopback, and cloud metadata IPs are blocked. DNS rebinding attacks are neutralised by pinning the connection to the IP address resolved during the safety check.
  • Cryptographic signing: every verification record is signed with a process-local HMAC. validate_knowledge unconditionally verifies this signature, so a hand‑written VerificationRecord can never pass as genuine.

Testing

python -m pytest -v

94+ tests, all passing.


License

MIT

Download files

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

Source Distribution

cks_mcp-1.9.3.tar.gz (58.3 kB view details)

Uploaded Source

Built Distribution

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

cks_mcp-1.9.3-py3-none-any.whl (48.9 kB view details)

Uploaded Python 3

File details

Details for the file cks_mcp-1.9.3.tar.gz.

File metadata

  • Download URL: cks_mcp-1.9.3.tar.gz
  • Upload date:
  • Size: 58.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.13

File hashes

Hashes for cks_mcp-1.9.3.tar.gz
Algorithm Hash digest
SHA256 64620bfe610bb26fd3c3d9608b75ea8a8a657145ed15f3461dd30ebede33eae5
MD5 7fcdb50d3a9aa96c72ad10d2625069b6
BLAKE2b-256 36ec245b88ae7dbd7d433e67ad931c94a9de5e810bfb6b596ab13be50c706e0a

See more details on using hashes here.

File details

Details for the file cks_mcp-1.9.3-py3-none-any.whl.

File metadata

  • Download URL: cks_mcp-1.9.3-py3-none-any.whl
  • Upload date:
  • Size: 48.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.13

File hashes

Hashes for cks_mcp-1.9.3-py3-none-any.whl
Algorithm Hash digest
SHA256 6616f7571d4dd664dfed085837d017bbc93c0ac95197374e9b3e7e6744a34111
MD5 3142b7623c4299c8cc42119764d67d61
BLAKE2b-256 57292369d0c4077f8ecda410c605a52e2dc4bbb49ac6d0a0bcd923a557530335

See more details on using hashes here.

Release history Release notifications | RSS feed

1.77.0

2 files

1.76.8

2 files

1.76.7

2 files

1.76.6

2 files

1.76.5

2 files

1.76.4

2 files

1.76.3

2 files

1.76.2

2 files

1.76.1

2 files

1.76.0

2 files

1.75.0

2 files

1.74.1

2 files

1.74.0

2 files

1.73.0

2 files

1.72.0

2 files

1.71.2

2 files

1.71.1

2 files

1.71.0

2 files

1.70.1

2 files

1.70.0

2 files

1.69.1

2 files

1.69.0

2 files

1.68.2

2 files

1.68.1

2 files

1.68.0

2 files

1.67.0

2 files

1.66.0

2 files

1.65.0

2 files

1.64.0

2 files

1.63.0

2 files

1.62.0

2 files

1.61.0

2 files

1.60.0

2 files

1.59.0

2 files

1.58.0

2 files

1.57.3

2 files

1.57.2

2 files

1.57.1

2 files

1.57.0

2 files

1.56.2

2 files

1.56.1

2 files

1.56.0

2 files

1.55.0

2 files

1.54.1

2 files

1.54.0

2 files

1.53.3

2 files

1.53.2

2 files

1.53.1

2 files

1.53.0

2 files

1.52.3

2 files

1.52.2

2 files

1.52.1

2 files

1.52.0

2 files

1.51.3

2 files

1.51.2

2 files

1.51.1

2 files

1.51.0

2 files

1.50.0

2 files

1.49.0

2 files

1.48.0

2 files

1.47.0

2 files

1.46.0

2 files

1.45.0

2 files

1.44.0

2 files

1.43.0

2 files

1.42.0

2 files

1.41.0

2 files

1.40.0

2 files

1.39.0

2 files

1.38.0

2 files

1.37.0

2 files

1.36.0

2 files

1.35.0

2 files

1.34.0

2 files

1.33.0

2 files

1.32.2

2 files

1.32.1

2 files

1.32.0

2 files

1.31.1

2 files

1.31.0

2 files

1.30.0

2 files

1.29.0

2 files

1.28.0

2 files

1.27.1

2 files

1.27.0

2 files

1.26.0

2 files

1.25.0

2 files

1.24.0

2 files

1.23.0

2 files

1.22.0

2 files

1.21.0

2 files

1.20.3

2 files

1.20.2

2 files

1.20.1

2 files

1.20.0

2 files

1.19.0

2 files

1.18.1

2 files

1.18.0

2 files

1.17.0

2 files

1.16.2

2 files

1.16.1

2 files

1.16.0

2 files

1.15.0

2 files

1.14.4

2 files

1.14.3

2 files

1.14.2

2 files

1.14.1

2 files

1.14.0

2 files

1.13.2

2 files

1.13.1

2 files

1.13.0

2 files

1.12.2

2 files

1.12.1

2 files

1.12.0

2 files

1.11.1

2 files

1.11.0

2 files

1.10.6

2 files

1.10.5

2 files

1.10.3

2 files

1.10.2

2 files

1.10.1

2 files

1.10.0

2 files

This release

1.9.3 This release

2 files

1.9.2

2 files

1.9.1

2 files

1.9.0

2 files

1.8.2

2 files

1.8.1

2 files

1.8.0

2 files

1.7.14

2 files

1.7.13

2 files

1.7.12

2 files

1.7.11

2 files

1.7.10

2 files

1.7.9

2 files

1.7.8

2 files

1.7.7

2 files

1.7.6

2 files

1.7.5

2 files

1.7.4

2 files

1.7.3

2 files

1.7.2

2 files

1.7.1

2 files

1.7.0

2 files

1.6.19

2 files

1.6.18

2 files

1.6.17

2 files

1.6.16

2 files

1.6.14

2 files

1.6.13

2 files

1.6.12

2 files

1.6.11

2 files

1.6.10

2 files

1.6.9

2 files

1.6.8

2 files

1.6.7

2 files

1.6.6

2 files

1.6.5

2 files

1.6.4

2 files

1.6.3

2 files

1.6.2

2 files

1.6.1

2 files

1.6.0

2 files

1.5.4

2 files

1.5.2

2 files

1.5.1

2 files

1.5.0

2 files

1.4.1

2 files

1.4.0

2 files

1.3.5

2 files

1.3.4

2 files

1.3.3

2 files

1.3.2

2 files

1.3.1

2 files

1.3.0

2 files

1.2.6

2 files

1.2.5

2 files

1.2.4

2 files

1.2.3

2 files

1.2.2

2 files

1.2.1

2 files

1.2.0

2 files

1.1.1

2 files

1.1.0

2 files

1.0.10

2 files

1.0.9

2 files

1.0.8

2 files

1.0.7

2 files

1.0.6

2 files

1.0.5

2 files

1.0.4

2 files

1.0.3

2 files

1.0.2

2 files

1.0.1

2 files

1.0.0

2 files

0.7.8

2 files

0.7.7

2 files

0.7.6

2 files

0.7.5

2 files

0.7.4

2 files

0.7.3

2 files

0.7.2

2 files

0.7.1

2 files

0.7.0

2 files

0.6.3

2 files

0.6.2

2 files

0.6.1

2 files

0.6.0

2 files

0.5.2

2 files

0.5.1

2 files

0.5.0

2 files

0.4.4

2 files

0.4.3

2 files

0.4.2

2 files

0.4.1

2 files

0.4.0

2 files

0.3.3

2 files

0.3.2

2 files

0.3.1

2 files

0.3.0

2 files

0.2.1

2 files

0.2.0

2 files

0.1.1

2 files

Supported by

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