CKS MCP Server
Model Context Protocol server for Canonical Knowledge Structure.
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
- Install and connect to Claude Desktop (see Installation).
- (Optional) For semantic search, set your Hugging Face token:
export HF_TOKEN=hf_... - In the chat, start your message with "Use cks-mcp to…".
- Claude automatically picks the right tool from the 15 available — validation, evolution, branching, merging, source verification, semantic search, subgraph queries, and more.
- 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!
In the video above, Claude creates a validated knowledge graph about the water cycle from a single sentence, using validate_knowledge and explain_knowledge. Fifteen 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_projectionmechanically detect references to non-existent sources. - Ensure verification integrity — the
verify_sourcetool performs a real HTTP check and cryptographically signs the result. AnyVerificationRecordwithout a valid signature is automatically rejected, even if the model fails to request the check. - Semantic search with real embeddings — the
search_semantictool 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_subgraphto 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 debugging —
list_versions,revert_version, andcompare_versionsgive 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
-
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
-
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 yourcks-mcpexecutable):{ "mcpServers": { "cks-mcp": { "command": "/absolute/path/to/cks-env/bin/cks-mcp" } } }
-
Save the file and fully restart Claude Desktop (Cmd+Q, then reopen). After restart, a connector icon will appear –
cks-mcpwith fifteen tools is ready to use.
Interactive LLM client (Groq / DeepSeek / local)
export GROQ_API_KEY=your_key_here
python llm_client/cks_llm_client.py --provider groq
You can then type natural language requests; the LLM will automatically call the appropriate CKS tool.
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. |
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\"}"
}
]
}
}
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_knowledgeunconditionally verifies this signature, so a hand‑writtenVerificationRecordcan never pass as genuine.
Testing
python -m pytest -v
64+ 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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cks_mcp-1.7.11.tar.gz.
File metadata
- Download URL: cks_mcp-1.7.11.tar.gz
- Upload date:
- Size: 48.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b561ed7d4b352e587954a2791de53f433f5dfcedd98f6dffa94399357e27e082
|
|
| MD5 |
d1cfed3ae3004028ca9dc2f6779b8133
|
|
| BLAKE2b-256 |
345cf8576be491a7b791a11e200e934b57f0cc4fcebc484deae125ae879afeca
|
File details
Details for the file cks_mcp-1.7.11-py3-none-any.whl.
File metadata
- Download URL: cks_mcp-1.7.11-py3-none-any.whl
- Upload date:
- Size: 41.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2e979cf72965f4e593c484fcafe76afd7bd44a4310107b09ce3aaac49fe64318
|
|
| MD5 |
c67d9ed71329daccc04e17c0f5afa4c3
|
|
| BLAKE2b-256 |
43d50b4c52d4d121a8a50f7aee1432e85e298ed5eda5da19dcd72382ebac2055
|