A demo of using TypeDB 3.x as a structured knowledge graph to track engineering analysis tasks, results, and dependencies. An AI agent (Claude Code) interacts with the database through the TypeDB MCP server, reading and writing state as analyses progress.
Instead of tracking analysis plans in spreadsheets or unstructured notes, this project stores them in a typed knowledge graph:
- Design variables with bounds and units (e.g.
wing_span: 28–42 m) - Objectives and constraints that define the optimisation problem
- Analysis tasks with status, priority, and dependency edges
- Results linked back to the tasks that produced them and the objectives/constraints they inform
The schema enforces structure — you can't insert a result without linking it to a task, and cardinality constraints prevent malformed relations. Claude Code queries and mutates this graph via MCP tools during a conversation, treating TypeDB as persistent state across sessions.
.
├── docker-compose.yml # TypeDB + MCP server
├── .mcp.json # MCP server endpoint config
├── schema/
│ └── wing-design-study.tql # TypeQL schema definition
├── typedb-mcp/ # TypeDB MCP server (git submodule / clone)
├── CLAUDE.md # Agent instructions and TypeQL reference
└── README.md
- Docker and Docker Compose
- Claude Code CLI (for the AI-agent workflow)
git clone <repo-url>
cd typedb-projectClone the MCP server into the typedb-mcp/ directory:
git clone https://github.com/typedb/typedb-mcp.git typedb-mcpThe upstream server.py passes timeout_graceful_shutdown=30 to mcp.run(), but this parameter isn't supported by the current FastMCP version and causes a startup crash. Remove it:
cd typedb-mcp
sed -i 's/mcp.run(transport="http", host="0.0.0.0", port=args.port, timeout_graceful_shutdown=30)/mcp.run(transport="http", host="0.0.0.0", port=args.port)/' server.py
cd ..Or manually edit typedb-mcp/server.py and remove the timeout_graceful_shutdown=30 argument from the mcp.run(...) call at the bottom of the file.
docker compose up -dThis starts:
- TypeDB on ports
1729(native) and8000(HTTP) - TypeDB MCP server on port
8001, connected to the TypeDB instance
Data is persisted in a Docker named volume (typedb-data), so it survives container restarts.
Default credentials:
- Username:
admin - Password:
password
Open Claude Code in this directory and ask it to set up the database:
claude
> Create a database called 'wing-design-study' and load the schema from schema/wing-design-study.tql
Or use the MCP tools directly — the schema file at schema/wing-design-study.tql contains the full define block.
Ask Claude Code to insert the design problem, variables, objectives, constraints, and analysis tasks. The CLAUDE.md file provides TypeQL syntax examples and domain context that guide the agent.
The .mcp.json file configures Claude Code to connect to the TypeDB MCP server:
{
"mcpServers": {
"typedb": {
"type": "http",
"url": "http://localhost:8001/mcp"
}
}
}This gives Claude Code tools like mcp__typedb__query, mcp__typedb__database_create, and mcp__typedb__database_schema — it reads and writes TypeDB directly during conversation.
The schema (schema/wing-design-study.tql) models three layers:
- Decision problem — design variables, objectives, constraints, and a
problem-scoperelation that ties them together - Analysis plan — tasks with status/priority,
task-dependencyedges for ordering, andtask-evaluatesrelations linking tasks to the variables/objectives/constraints they assess - Results —
analysis-resultentities with values and confidence, linked viaresult-linkto the producing task and the objectives/constraints they inform
A typical session looks like:
- Query the plan — "What tasks are planned and what are their dependencies?"
- Run an analysis — execute the analysis (via external tools or manually)
- Record results — insert
analysis-resultentities, update task status tocompleted - Adapt the plan — based on results (e.g. constraint has margin), add new tasks
- Query again — see the updated dependency graph with results
The knowledge graph acts as a shared, structured scratchpad between the human and the AI agent. The schema prevents drift — every result must reference a task, every task can declare dependencies, and types are validated on insert.
Get all tasks and their status:
match
$t isa analysis-task, has name $n, has status $s, has priority $p;
fetch { "name": $n, "status": $s, "priority": $p };
Get the dependency graph:
match
$dep isa task-dependency (dependent: $d, dependency: $p);
$d has name $dn;
$p has name $pn;
fetch { "task": $dn, "depends_on": $pn };
Get results linked to their tasks:
match
$rl isa result-link (result: $r, producing-task: $t);
$r has name $rn, has result-value $v, has unit $u;
$t has name $tn;
fetch { "result": $rn, "value": $v, "unit": $u, "task": $tn };
You can inspect the database visually using TypeDB Studio. Connect to your local instance at localhost:8000 with the default credentials (admin / password). Studio lets you browse the schema, run TypeQL queries interactively, and visualize the knowledge graph.
As an alternative to the MCP server, you can install the TypeDB Console CLI — a standalone client for managing and querying TypeDB from the command line.
Install (macOS / Linux):
curl -sSL https://typedb.com/install.sh | sh && export PATH="$HOME/.typedb:$PATH"Or via Homebrew on macOS: brew install typedb/tap/typedb
Connect to the local Docker instance:
typedb console --server=localhost:8000From the console you can open transactions and run TypeQL directly:
> transaction wing-design-study read
wing-design-study::read> match $t isa analysis-task, has name $n; fetch { "name": $n };
wing-design-study::read> close
The console is useful for ad-hoc debugging, schema inspection, and running queries outside of the Claude Code / MCP workflow. See the TypeDB Console docs for full usage.
docker compose down # stop containers (data persists in volume)
docker compose down -v # stop containers and delete data