-
Notifications
You must be signed in to change notification settings - Fork 4
CSDb Data Model 26 MCP Tools
The following files were used as context for generating this wiki page:
This page provides a detailed technical reference for the Claude Sleuth Database (CSDb), the persistent intelligence layer for the DI Claudian toolkit. CSDb is implemented as a Cloudflare Workers MCP server backed by a D1 SQLite database, providing cross-session persistence and referential integrity for all investigative data.
The CSDb schema is designed to support the POLE (Persons, Objects, Locations, Events) data model and the Admiralty 6x6 source grading framework. All data is strictly scoped to an investigation_id to ensure multi-tenant isolation.
The following diagram illustrates the primary tables and their foreign key relationships within the D1 instance (sleuth-db).
Diagram: CSDb Relational Schema
erDiagram
investigations ||--o{ entities : "contains"
investigations ||--o{ relationships : "contains"
investigations ||--o{ source_grades : "contains"
investigations ||--o{ timeline_events : "contains"
investigations ||--o{ locations : "contains"
investigations ||--o{ evidence_register : "contains"
investigations ||--|| progress : "tracks"
investigations ||--|| notebook : "persists"
investigations {
text id PK
text name
text status "active|paused|closed|archived"
text created_utc
}
entities {
text id PK
text investigation_id FK
text type "person|org|location|etc"
text name
text aliases "JSON array"
text identifiers "JSON object"
text attributes "JSON object"
text source_grade "Admiralty 6x6"
}
relationships {
text id PK
text investigation_id FK
text source_entity
text target_entity
text type
real weight
real confidence
}
timeline_events {
text id PK
text investigation_id FK
text utc_datetime
text description
text category "comm|mov|fin|etc"
}
Sources: server/schema.sql:5-139
-
investigations: The root container for all case data server/schema.sql:5-12. -
entities: Stores POLE entities with support for aliases and structured identifiers (e.g., Passport, LEI) server/schema.sql:14-30. -
relationships: Directed or undirected links between entities, including confidence weights and temporal bounds server/schema.sql:32-50. -
source_grades: Implementation of the Admiralty 6x6 system (Reliability A-F, Credibility 1-6) server/schema.sql:52-66. -
timeline_events: Normalized chronological data for matrix construction server/schema.sql:68-85. -
locations: Geospatial data points linked to entities or events server/schema.sql:87-108. -
evidence_register: Metadata for preserved artefacts, including SHA-256 hashes for chain of custody server/schema.sql:110-124. -
progress¬ebook: Persistence for thetask_runner.pystate and the analyst's working notes server/schema.sql:126-139.
The CSDb MCP server exposes 26 tools to the Claude interface, categorized by their functional domain. These tools allow the LLM to perform CRUD operations on the underlying D1 database.
| Tool | Purpose | Key Inputs |
|---|---|---|
create_investigation |
Initializes a new case |
name, description
|
list_investigations |
Returns all cases | - |
load_investigation |
Full state dump for analysis | investigation_id |
update_investigation |
Modify status or metadata |
updates (object) |
close_investigation |
Marks case as finished | investigation_id |
delete_investigation |
Permanent removal |
confirm (boolean) |
Sources: server/worker.js:2-2
-
add_entity: Supports types such asperson,organisation,domain,email, andvehicleserver/worker.js:2-2. -
search_entities: Fuzzy search across names and aliases server/worker.js:2-2. -
add_relationship: Links two entities with a specifictype(e.g.,shareholder_of) andweightserver/worker.js:2-2. -
get_neighbors: Graph traversal tool to find entities within 1-3 hops of a starting node server/worker.js:2-2.
-
record_grade: Enforces Admiralty 6x6 grading on specific claims server/worker.js:2-2. -
add_timeline_event: Categories includecommunication,movement,financial, andincidentserver/worker.js:2-2. -
add_location: Records coordinates, labels, and observation timestamps server/worker.js:2-2. -
register_evidence: Logs SHA-256 hashes and storage locations for preserved files server/worker.js:2-2.
-
save_progress/load_progress: Synchronizes the local.sleuth-progress.jsonwith the remote DB server/worker.js:2-2. -
save_notebook/load_notebook: Persists the analyst's markdown-formatted investigation notebook server/worker.js:2-2. -
get_statistics: Returns counts of entities, relationships, and events for dashboarding server/worker.js:2-2.
CSDb acts as the "Single Source of Truth." Data flows from the analyst (Natural Language) through the MCP tools into the structured Code Entity Space.
Diagram: Data Flow from Natural Language to D1
graph TD
subgraph "Natural Language Space"
NL["Analyst: 'Subject X is a director of Company Y'"]
end
subgraph "Claude MCP Interface"
T1["tool: add_entity (Subject X)"]
T2["tool: add_entity (Company Y)"]
T3["tool: add_relationship (X -> Y)"]
end
subgraph "Code Entity Space (server/worker.js)"
W["worker.js: handleCallTool()"]
Q["SQL: INSERT INTO entities/relationships"]
end
subgraph "Persistence (Cloudflare D1)"
D1[("sleuth-db")]
end
NL --> T1
NL --> T2
NL --> T3
T1 & T2 & T3 --> W
W --> Q
Q --> D1
Sources: skills/claude-sleuth/assets/database-usage.md:3-9, server/worker.js:1-2
-
Start: The session begins by calling
list_investigationsto find the active ID, followed byload_progressandload_notebookto restore context skills/claude-sleuth/assets/database-usage.md:81-86. -
Execution: As findings are made, tools like
add_entityandrecord_gradeare called immediately. IDs returned by the database must be used for all subsequent relationship linking skills/claude-sleuth/assets/database-usage.md:70-75. -
Analysis: Complex analytical scripts (e.g.,
network_graph.py) ingest data by callingload_investigationto get the full JSON state skills/claude-sleuth/assets/database-usage.md:104-105.
CSDb uses a prefixed ID system to ensure type clarity during link analysis:
-
P-: Person -
O-: Organisation -
L-: Location -
E-: Event Sources: server/worker.js:4-4
The database enforces foreign key constraints. An entity cannot be deleted if it is a participant in an existing relationship unless a cascade is triggered. The delete_entity tool is explicitly designed to cascade-remove associated relationships to prevent orphaned links server/worker.js:2-2.
-
Provenance: Every entity and relationship record includes a
sourceandsource_gradefield. No data should enter the database without an Admiralty 6x6 assessment skills/claude-sleuth/assets/database-usage.md:72-72. -
UTC Normalization: All timestamps (
created_utc,modified_utc,utc_datetime) are stored in ISO 8601 UTC format to facilitate chronological matrix construction server/schema.sql:10-11, server/schema.sql:72-72.
Sources: server/schema.sql:1-140, server/worker.js:1-10, skills/claude-sleuth/assets/database-usage.md:1-123