MCP Server¶
The knowledgespaces MCP server lets you use Knowledge Space Theory directly from Claude, ChatGPT, or any MCP-compatible AI assistant. No Python code needed — the LLM calls the tools for you.
What is MCP?
The Model Context Protocol (MCP) is an open standard that allows AI assistants to use external tools, read data sources, and follow guided workflows. Think of it as a plugin system for LLMs.
What the server provides¶
Tools (7)¶
The server exposes all core KST operations as callable tools:
Tool |
Description |
|---|---|
|
Build a knowledge structure from prerequisite pairs |
|
Derive structure from a skill map (CB-KST) |
|
Estimate BLIM parameters from response data via EM |
|
Assess a student’s knowledge state from responses |
|
Pick the next optimal question (EIG-based adaptive) |
|
Analyze structure: atoms, base, paths, properties |
|
Generate a Hasse diagram (PNG image) |
All tools are stateless: knowledge structures and fit results are passed as JSON between calls. The LLM orchestrates multi-step workflows by chaining tool calls.
Documentation Resources (13)¶
The server exposes the full library documentation as MCP resources.
The LLM can read any documentation page on demand using docs://{topic}:
docs://getting-started— Quick start guidedocs://guide-structures— Knowledge structuresdocs://guide-assessment— Student assessmentdocs://guide-estimation— Parameter estimationdocs://guide-derivation— CB-KST derivationdocs://guide-query— QUERY algorithmdocs://guide-io— CSV and JSON I/Odocs://guide-metrics— Comparison metricsdocs://guide-cli— Command-line interfacedocs://theory-foundations— KST foundationsdocs://theory-blim— BLIM theorydocs://theory-query-algorithm— QUERY algorithm theorydocs://api— API reference
This means the LLM always has access to up-to-date documentation, making it useful both for executing KST operations and for development assistance (writing code that uses the library).
Prompt Templates (4)¶
Pre-built workflows for common tasks:
Prompt |
Description |
|---|---|
|
Full step-by-step KST tutorial with a custom domain |
|
Guided student assessment pipeline |
|
Design a knowledge structure for a course |
|
Interactive adaptive assessment session |
Installation¶
1. Create a dedicated environment¶
python3 -m venv ~/.knowledgespaces-mcp
~/.knowledgespaces-mcp/bin/pip install fastmcp
2. Install knowledgespaces¶
From source (until published on PyPI):
~/.knowledgespaces-mcp/bin/pip install -e /path/to/knowledgespaces[viz]
From PyPI (when available):
~/.knowledgespaces-mcp/bin/pip install knowledgespaces[viz]
3. Verify¶
~/.knowledgespaces-mcp/bin/python3 -c "import knowledgespaces; from fastmcp import FastMCP; print('OK')"
Configuration¶
Claude Desktop¶
Open Settings > Developer > Edit Config and add:
{
"mcpServers": {
"knowledgespaces": {
"command": "~/.knowledgespaces-mcp/bin/python3",
"args": ["/path/to/knowledgespaces/mcp/server.py"]
}
}
}
Restart Claude Desktop. You should see the hammer icon with 7 tools.
Claude Code (CLI / VS Code)¶
Add to .mcp.json in your project root:
{
"mcpServers": {
"knowledgespaces": {
"command": "~/.knowledgespaces-mcp/bin/python3",
"args": ["/path/to/knowledgespaces/mcp/server.py"]
}
}
}
Testing with FastMCP Inspector¶
For development and debugging, use the interactive inspector:
fastmcp dev mcp/server.py
This opens a browser UI where you can call tools, read resources, and test prompts interactively.
Usage examples¶
Once configured, interact naturally with the LLM:
Build a structure:
“Build a knowledge structure for arithmetic with items: addition, subtraction, multiplication, division. Addition is prerequisite for subtraction, subtraction for multiplication, multiplication for division.”
Assess a student:
“Assess a student who got addition and subtraction correct but multiplication and division wrong.”
Adaptive assessment:
“Run an adaptive assessment — ask me one question at a time and converge on the student’s knowledge state.”
Consult documentation:
“Read the BLIM theory documentation and explain how slip and guess parameters work.”
Use a prompt template:
“Use the kst_tutorial prompt to walk me through KST with a programming skills example.”
Architecture¶
LLM <--> MCP Protocol <--> server.py <--> knowledgespaces
|
|-- Tools (7): execute KST operations
|-- Resources (13): library documentation
'-- Prompts (4): workflow templates
The server uses FastMCP and communicates via stdio transport. All tool inputs and outputs are JSON-serializable.
Knowledge structures are represented as:
{
"domain": ["add", "sub", "mul"],
"states": [[], ["add"], ["add", "sub"], ["add", "sub", "mul"]]
}
This JSON travels between tool calls, keeping the server completely stateless. The LLM manages the conversation state.