mimetic-graph
# mimetic-mcp-graph-starter
A small, runnable starter that shows how to put a **typed ontology** and a **knowledge graph** over ordinary business databases, sit **scoped OAuth / SSO** in front of it, and expose the graph to **Claude** through the Model Context Protocol.
The tools match the public explainer:
- `get_account_graph` — customer, invoices, tickets, follow-ups, edges, and a short summary (`role: ops`, `scope: graph:read`)
- `list_open_tickets` — open tickets with customer and invoice context (`role: ops`, `scope: graph:read`)
- `create_followup` — write a follow-up note and return the updated graph (`role: ops`, `scope: tickets:write`)
Sample data is 100% synthetic. There are no real customer names, no production secrets, and no live credentials in this repository.
## Architecture
```
Relational / CRM / Docs databases
│ (seeded local SQLite: customers, invoices, tickets, follow-ups)
▼
Ontology + Knowledge Graph layer
│ ontology.json + typed queries
▼
Scoped OAuth / SSO auth middleware
│ verifies a bearer JWT on every tool call
│ role: ops
│ scopes: graph:read | tickets:write
▼
MCP server
│ get_account_graph
│ list_open_tickets
│ create_followup
▼
Claude Desktop / Claude Code
```
```mermaid
flowchart TD
subgraph Sources["Relational / CRM / Docs data"]
CRM[Customers]
BILL[Invoices]
SUP[Tickets and follow-ups]
end
subgraph Graph["Ontology + knowledge graph"]
ONT["ontology.json"]
KG["SQLite graph layer"]
end
subgraph Auth["Scoped OAuth / SSO"]
MW["JWT middleware"]
ROLE["role: ops"]
SC["graph:read / tickets:write"]
end
subgraph MCP["MCP server"]
T1["get_account_graph"]
T2["list_open_tickets"]
T3["create_followup"]
end
Claude["Claude Desktop / Claude Code"]
CRM --> KG
BILL --> KG
SUP --> KG
ONT --> KG
KG --> MW
MW --> ROLE
MW --> SC
ROLE --> MCP
SC --> MCP
T1 --> Claude
T2 --> Claude
T3 --> Claude
```
## Requirements
- Node.js 22.5 or newer (this starter uses the built-in `node:sqlite` module, so there is no native add-on to compile)
- npm 10 or newer
## 5-minute quickstart
```bash
cp .env.example .env
npm install
npm run seed
npm run token -- --scopes graph:read,tickets:write
npm test
npm run build
```
`npm run seed` creates (or resets) `data/graph.db` with fictional customers such as Harbor & Pine Coffee Co. and Brightline Dental Group.
`npm run token` prints a **local-dev-only** access token. Paste it into the Claude config as `MCP_AUTH_TOKEN`. The token is signed with the placeholder secret in `.env.example` (`dev-only-local-secret-change-me-at-least-32-chars`). That value is not a real credential. Change it if you use this beyond a disposable demo, and never commit a minted token.
### Claude Desktop
1. Build the project with `npm run build`.
2. Open your Claude Desktop config (`claude_desktop_config.json`).
3. Merge the server block from [`examples/claude_desktop_config.json`](examples/claude_desktop_config.json).
4. Replace `/ABSOLUTE/PATH/TO/mimetic-mcp-graph-starter` with the real path on your machine.
5. Paste the token from `npm run token` into `MCP_AUTH_TOKEN`.
6. Restart Claude Desktop and ask: “Show me the account graph for Harbor & Pine Coffee Co.”
### Claude Code
1. Build the project with `npm run build`.
2. Copy [`examples/claude_code_mcp.json`](examples/claude_code_mcp.json) into your project's `.mcp.json`, or merge the `mimetic-graph` entry.
3. Replace the absolute path placeholders and paste `MCP_AUTH_TOKEN`.
4. Restart Claude Code (or run `claude mcp list` to confirm the server is registered).
Stdio is the supported path for both clients. An optional Streamable HTTP entry is available with `npm run start:http` and is documented below.
## What each tool returns
A `graph:read` token can call the first two tools. `create_followup` also needs `tickets:write`.
```json
{
"name": "get_account_graph",
"arguments": { "customerId": "cus_harbor_pine" }
}
```
```json
{
"customer": {
"id": "cus_harbor_pine",
"name": "Harbor & Pine Coffee Co.",
"accountStatus": "past_due"
},
"summary": {
"invoiceCount": 2,
"outstandingCents": 89000,
"overdueInvoiceCount": 1,
"openTicketCount": 1
},
"edges": [
{ "from": "cus_harbor_pine", "to": "inv_hp_1042", "type": "HAS_INVOICE" },
{ "from": "cus_harbor_pine", "to": "tkt_hp_88", "type": "HAS_TICKET" },
{ "from": "tkt_hp_88", "to": "inv_hp_1042", "type": "REFERENCES_INVOICE" }
]
}
```
```json
{
"name": "list_open_tickets",
"arguments": {}
}
```
Tickets are enriched with the customer and, when present, the referenced invoice. See [`examples/sample-outputs.md`](examples/sample-outputs.md) for more complete payloads.
A missing, invalid, expired, or under-scoped token is rejected **before** the tool body runs, with a structured error:
```json
{
"error": "forbidden",
"code": "INSUFFICIENT_SCOPE",
"message": "This tool requires scope(s): tickets:write.",
"required": { "role": "ops", "scopes": ["tickets:write"] },
"provided": { "role": "ops", "scopes": ["graph:read"] }
}
```
## Auth modes
| `AUTH_MODE` | Signing | When to use |
| --- | --- | --- |
| `local` (default) | HS256 with `JWT_SECRET` | Five-minute local demo |
| `local-rs256` | RS256 with a generated development JWKS | Practice JWKS verification without a vendor |
| `oidc` | Provider JWKS (`AUTH_JWKS_URI`, `AUTH_ISSUER`, `AUTH_AUDIENCE`) | Okta, Entra ID, Auth0, or Google Workspace |
Mint local tokens:
```bash
npm run token -- --scopes graph:read
npm run token -- --scopes graph:read,tickets:write
```
For production-style SSO, see [`docs/SSO_SETUP.md`](docs/SSO_SETUP.md).
### Optional HTTP entry
```bash
npm run start:http
```
This listens on `http://127.0.0.1:8787/mcp` and expects `Authorization: Bearer <token>` on every request. In `local-rs256` mode the development JWKS is served at `http://127.0.0.1:8787/.well-known/jwks.json`. Claude Desktop and Claude Code should keep using stdio.
## Project layout
```
ontology.json Typed entity and relationship schema
src/ontology/ TypeScript types and Zod validators
src/db/ SQLite schema, synthetic seed data, seed script
src/graph/ Knowledge-graph queries over the seeded tables
src/auth/ JWT verification, role/scope checks, token minting
src/mcp/ MCP server and the three tools
src/index.ts stdio entry for Claude
src/http.ts Optional Streamable HTTP entry
examples/ Ready-to-paste Claude Desktop and Claude Code configs
docs/SSO_SETUP.md Okta, Entra ID, Auth0, and Google Workspace notes
```
## Scripts
| Script | Purpose |
| --- | --- |
| `npm run seed` | Create or reset the SQLite database (idempotent) |
| `npm run token` | Mint a local-dev JWT |
| `npm test` | Ontology, graph, auth, and end-to-end MCP tests |
| `npm run typecheck` | `tsc --noEmit` |
| `npm run build` | Compile to `dist/` |
| `npm start` | Run the compiled stdio server |
| `npm run start:http` | Optional HTTP server |
## License
MIT © Mimetic Technology
---
## Mimetic Technology (110/20 Software)
Built as a public starter by [Mimetic Technology](https://mimetictech.ai).
<!-- CONTACT: keep or strip this block in one second if the published contact details change. -->
**Contact**
- Email: elowell@mimetictech.ai
- Phone: (332) 895-4782
- Web: [mimetictech.ai](https://mimetictech.ai)
<!-- /CONTACT -->
TDQS
Scored across 3 tools
Each tool performs a clearly different action on a different resource: reading a full account graph, listing tickets, and creating a follow-up note. An agent can select correctly without ambiguity, and the descriptions reinforce the boundaries (read vs. write scope).
All three tools follow a strict verb_noun pattern (get_account_graph, list_open_tickets, create_followup) in snake_case. No mixed conventions or vague verbs.
Three tools is slightly thin for a graph/support domain that spans customers, invoices, tickets, and follow-ups, but each tool is well-scoped and non-redundant. It sits at the low end rather than being mismatched.
Read paths for the account graph and open tickets plus follow-up creation are covered, but there is no way to create/close/update tickets, update or delete follow-ups, or search customers and invoices directly. These are notable gaps that would dead-end common support workflows.