The official Python SDK and packaged MCP client are coming soon. This tutorial uses the documented HTTP API available today.
This example records a support observation and retrieves governed context from the same ticket scope. It deliberately stops at the memory boundary: pass the returned context to your model or orchestration framework only after applying your application’s own authorization and response policies.
Prerequisites
You need a running MemHouse server, an API key, and curl. Set the endpoint and key without putting either value into the script:
export MEMHOUSE_URL="http://localhost:4000"
export MEMHOUSE_API_KEY="replace-with-your-api-key"
1. Ingest a Support Observation
Use one stable scope_path for the ticket and a stable session_id for its conversation. The account is derived from the authenticated identity; do not use a caller-supplied account selector as an isolation boundary.
curl --fail-with-body \
-X POST "$MEMHOUSE_URL/api/v1/ingest" \
-H "Authorization: Bearer $MEMHOUSE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"session_id": "support-INV-9042",
"scope_path": "/support/tickets/INV-9042",
"content": "Customer prefers invoices by email rather than postal mail."
}'
--fail-with-body makes the command return a non-zero status for HTTP errors while preserving the response body for diagnosis. A successful response means the observation was accepted by the HTTP endpoint; it does not imply that every extracted fact is immediately active, because governance may hold or reject facts.
2. Retrieve Context for the Same Ticket
curl --fail-with-body \
-X POST "$MEMHOUSE_URL/api/v1/context" \
-H "Authorization: Bearer $MEMHOUSE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"scope_path": "/support/tickets/INV-9042",
"session_id": "support-INV-9042",
"budget_chars": 4000
}'
The response contains projection-backed context visible to the authenticated caller for that scope. Treat an empty result as a valid outcome: the observation may not have produced a fact, or a fact may not yet be visible under its lifecycle state.
3. Put It Behind Your Copilot
In a LangGraph, Claude, or other support workflow, make the two HTTP calls at explicit boundaries:
- Before generating a reply, call
/api/v1/contextwith the current ticket scope and add only the returned context to the model input. - After the customer or agent sends a new turn, call
/api/v1/ingestwith that turn ascontent. - Keep ticket identifiers server-side and derive authorization from the signed-in support user. Never accept an arbitrary
scope_pathfrom an untrusted browser and forward it without an access check.
This is the complete MemHouse integration loop: ingest observations, retrieve governed context, and let your existing application own model invocation and customer-facing responses.