Foundation
MCP server for a self-hostable typed knowledge graph, giving AI agents durable structured memory with typed nodes, links, and flexible payloads. Enables agents to bootstrap, manage, and evolve their ontology via MCP tools.
README
Foundation
A personal ontology your agents can grow.
Foundation is a small, self-hostable typed knowledge graph + MCP server for AI agents (Cursor, Claude, and other MCP clients). It gives them durable structure — not just chat memory — and lets that structure evolve as your life does.
The name is a nod to Asimov: carry structured knowledge forward so you (and your agents) are not starting from zero every time.
Glossary (locked): Foundation = the product. A vault = one instance (FOUNDATION_DATA + Postgres). The graph = the knowledge in that vault. A blob = a file on a node. An agent = anything that can reach the vault MCP. The operator = the human who runs Compose. Do not call the graph “the Vault.” Short analog: app / folder / links → Foundation / vault / graph.
Do not commit personal life data, documents, or secrets to this repository. Those belong in the operator’s vault, not in git.
Docs
docs/SPEC.md— product contractdocs/ARCHITECTURE.md— living vault and graphdocs/MCP_TOOLS.md— 12-tool MCP surfacedocs/AGENTS.md— optional named-agent stand-updocs/VAULT_HEALTH.md— weekday instance checkupdocs/GRAPH_HYGIENE.md— weekly graph report
What it is
- Nodes with types (e.g. area → project → goal → habit/task, plus whatever emerges)
- Typed links between them
- Flexible payloads (markdown, HTML, JSON, files as blobs) so a trip itinerary can live in the graph as HTML and a PDF can live as
$FOUNDATION_DATA/blobs/<uuid> - MCP-first API so agents read and write the graph directly
- Agents may create and update types and relations as needed (activity log for undo); no approve/reject inbox required
What it is not
- Not a mobile app, billing system, or hosted SaaS you must buy
- Not a second brain you have to maintain by hand (agents are the primary users)
- Run Compose on a machine your agents can reach at localhost MCP
Install
Requires Docker Compose and a copy of this repo. Node 22 is only needed if you run the app on the host instead of in Compose.
-
Copy the env file and set an API key (do not commit
.env):cp .env.example .env # set FOUNDATION_API_KEY to a long random string -
Start Postgres and the Foundation server. Durable files go under
FOUNDATION_DATA(default./data):docker compose up --buildOptional stand-up. After Compose is up, see
docs/AGENTS.mdfor an optional named-agent recipe and three routines. What “healthy” means:docs/VAULT_HEALTH.md. Graph report:docs/GRAPH_HYGIENE.md. No new MCP tools. -
Point an MCP client at
http://127.0.0.1:8787/mcpwith:Authorization: ApiKey <FOUNDATION_API_KEY>Authorization: Bearer <FOUNDATION_API_KEY>is accepted as an equivalent.Cursor / Claude-style MCP config:
{ "mcpServers": { "foundation": { "url": "http://127.0.0.1:8787/mcp", "headers": { "Authorization": "ApiKey YOUR_KEY" } } } } -
Call
bootstrapfirst. It returns the starter spine (area → project → goal → habit | task), seeded types/relations, and how to extend the ontology.After bootstrap, an agent can
upsertanareaandproject,linkthem withchild_of, store an HTML itinerary on atripnode (payload.media_type = "text/html"),searchthat itinerary back, list open tasks withsearch{ type: "task", status: "active" }(no query), attach a PDF blob on anote(payload.storage = "blob"),manage_typea custom type,list_activityfor receipts, andundoa reversible mutation. Destructive tools (delete,unlink,undo) requireconfirm: true. If you already have a UUID, callget. An empty lexicalsearchis not a reason to upsert a duplicate.With Node 22 + pnpm (and Compose already up):
pnpm bootstrapOr with curl (SSE JSON-RPC; look for the
data:line):set -a && source .env && set +aHealth (no auth):
GET http://127.0.0.1:8787/health—{ ok, service, db }.Blobs: large files are
$FOUNDATION_DATA/blobs/<uuid>(not git, not agent-data). Ingest withupsert(payload.storage = "blob"plusbytes_base64, or drop a file in$FOUNDATION_DATA/uploadsand passsource_path). Cap 20MB. Fetch bytes:GET /blobs/:idwith the API key.getreturns blob metadata, not the file body.Bootstrap:
curl -sS http://127.0.0.1:8787/mcp \ -H "Authorization: ApiKey ${FOUNDATION_API_KEY}" \ -H "Content-Type: application/json" \ -H "Accept: application/json, text/event-stream" \ -d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"bootstrap","arguments":{}}}'Mutate → list_activity → search → undo (replace UUIDs from the upsert/
list_activityresponses):# upsert an HTML itinerary curl -sS http://127.0.0.1:8787/mcp \ -H "Authorization: ApiKey ${FOUNDATION_API_KEY}" \ -H "Content-Type: application/json" \ -H "Accept: application/json, text/event-stream" \ -d '{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"upsert","arguments":{"type":"trip","title":"Sample itinerary","payload":{"media_type":"text/html","storage":"inline","body":"<html><body><h1>Itinerary</h1><p>Day 1: arrive NRT</p></body></html>"}}}}' # search the itinerary back curl -sS http://127.0.0.1:8787/mcp \ -H "Authorization: ApiKey ${FOUNDATION_API_KEY}" \ -H "Content-Type: application/json" \ -H "Accept: application/json, text/event-stream" \ -d '{"jsonrpc":"2.0","id":3,"method":"tools/call","params":{"name":"search","arguments":{"query":"arrive NRT","type":"trip"}}}' # list receipts for that node curl -sS http://127.0.0.1:8787/mcp \ -H "Authorization: ApiKey ${FOUNDATION_API_KEY}" \ -H "Content-Type: application/json" \ -H "Accept: application/json, text/event-stream" \ -d '{"jsonrpc":"2.0","id":4,"method":"tools/call","params":{"name":"list_activity","arguments":{"action":"create","target":"<NODE_UUID>"}}}' # undo that create (soft-deletes; requires confirm) curl -sS http://127.0.0.1:8787/mcp \ -H "Authorization: ApiKey ${FOUNDATION_API_KEY}" \ -H "Content-Type: application/json" \ -H "Accept: application/json, text/event-stream" \ -d '{"jsonrpc":"2.0","id":5,"method":"tools/call","params":{"name":"undo","arguments":{"id":"<ACTIVITY_UUID>","confirm":true}}}'Store a small PDF as a blob (synthetic example;
getreturnsblob_id+ sha256, not the bytes). Fetch bytes withGET /blobs/<BLOB_ID>:PDF_B64="$(printf '%s' '%PDF-1.1
trailer<</Root 1 0 R>>
%%EOF' | base64 -w0)"
curl -sS http://127.0.0.1:8787/mcp
-H "Authorization: ApiKey ${FOUNDATION_API_KEY}"
-H "Content-Type: application/json"
-H "Accept: application/json, text/event-stream"
-d "{"jsonrpc":"2.0","id":6,"method":"tools/call","params":{"name":"upsert","arguments":{"type":"note","title":"Sample PDF","payload":{"media_type":"application/pdf","storage":"blob","bytes_base64":"${PDF_B64}"}}}}"
curl -sS "http://127.0.0.1:8787/blobs/<BLOB_ID>"
-H "Authorization: ApiKey ${FOUNDATION_API_KEY}"
-o /tmp/sample.pdf
Operator drop-box (no base64): copy a file into `$FOUNDATION_DATA/uploads/` then `upsert` with `payload.source_path` set to the filename. The server moves it to `blobs/<uuid>`. Compose `db-init` creates `uploads/` mode 1777 (sticky) so the host user can write on a bind mount; `blobs/` stays 0700.
If Postgres fails to start on a bind-mounted data dir, Compose already runs a `db-init` step that `chown`s `$FOUNDATION_DATA/postgres` to uid 999. Never `docker compose down -v` as a casual step; that is how you destroy a vault. Never delete `FOUNDATION_DATA`.
Never point `FOUNDATION_DATA` at an agent profile or memory directory.
## Intended use
1. Run Compose on a machine your agents can reach at localhost MCP
2. Point agents at the local MCP endpoint
3. Optionally stand up named agents and the three routines ([`docs/AGENTS.md`](docs/AGENTS.md))
## License
[MIT](LICENSE) © 2026 Danny Graziosi
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.