Quick-start examples, full endpoint reference for LLM, MCP, and public APIs, plus live tenant info.
curl -X POST http://localhost:8080/v1/chat/completions \
-H "X-Tenant-ID: tenant_ecommerce" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4o",
"messages": [{"role":"user","content":"Show me recent invoices"}],
"stream": true
}'
const res = await fetch("http://localhost:8080/v1/chat/completions", {
method: "POST",
headers: {
"X-Tenant-ID": "tenant_ecommerce",
"Content-Type": "application/json",
},
body: JSON.stringify({
model: "gpt-4o",
messages: [{ role: "user", content: "Show me recent invoices" }],
stream: true,
}),
});
// consume SSE stream
const reader = res.body.getReader();
// ...
import openai
client = openai.OpenAI(
base_url="http://localhost:8080",
api_key="placeholder",
default_headers={"X-Tenant-ID": "tenant_ecommerce"},
)
for chunk in client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": "Show me recent invoices"}],
stream=True,
):
print(chunk.choices[0].delta.content or "", end="")
import anthropic
client = anthropic.Anthropic(
base_url="http://localhost:8080",
api_key="placeholder",
default_headers={"X-Tenant-ID": "tenant_ecommerce"},
)
with client.messages.stream(
model="claude-opus-4-5",
max_tokens=1024,
messages=[{"role": "user", "content": "Show me recent invoices"}],
) as stream:
for text in stream.text_stream:
print(text, end="", flush=True)
# List tools
curl -X POST http://localhost:8080/mcp/message \
-H "X-Tenant-ID: tenant_ecommerce" \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/list","params":{}}'
# Call a tool
curl -X POST http://localhost:8080/mcp/message \
-H "X-Tenant-ID: tenant_ecommerce" \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"get_invoice_ledger"}}'
# SSE transport (legacy 2024-11-05 spec)
curl -N http://localhost:8080/mcp/sse \
-H "X-Tenant-ID: tenant_ecommerce" \
-H "Accept: text/event-stream"
Requires X-Tenant-ID header.
/v1/chat/completions
OpenAI-compatible chat. Pass stream: true to receive token-by-token SSE, or stream: false for a single JSON response.
/v1/messages
Anthropic Messages API. Accepts model, messages, max_tokens. Pass stream: true for SSE with content_block_delta events, or stream: false for a single JSON response.
Requires X-Tenant-ID header. Implements JSON-RPC 2.0 over HTTP.
/mcp/message
MCP JSON-RPC endpoint. Pass Accept: text/event-stream to wrap the response as an SSE event (spec 2025-03-26).
/mcp/sse
Legacy HTTP+SSE transport (spec 2024-11-05). Emits an endpoint event with the POST URL, then pings every 15 s.
Supported methods
tools/list
Returns all tools defined in the tenant's scenarios.
tools/call
Calls a named tool. Returns mock JSON from the matching tenant scenario.
resources/list
Returns an empty resource list (stub).
prompts/list
Returns an empty prompt list (stub).
initialize
Returns server info and capability advertisement for the 2025-03-26 protocol version.
Quick start
curl -s -X POST http://localhost:8080/mcp/message \
-H "X-Tenant-ID: tenant_saas_growth" \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/list","params":{}}'
# Returns all tools defined in this tenant's scenarios:
# get_growth_metrics, get_churn_report, get_feature_adoption
curl -s -X POST http://localhost:8080/mcp/message \
-H "X-Tenant-ID: tenant_saas_growth" \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":2,"method":"tools/call",
"params":{"name":"get_growth_metrics"}}'
# Returns the tenant scenario's tool_data:
# { "mrr_usd": 128400, "churn_rate_pct": 2.1, "nrr_pct": 118 }
Reads are public (global tenants open to all, private tenants require ownership). Writes require login. No X-Tenant-ID required.
Tenants
/public/tenants
List tenants. Unauthenticated returns global tenants only; logged-in users also see their private tenants.
/public/tenants
Create a tenant. Body: {"tenant_id":"…","state":{}}
auth
/public/tenants/{id}
Get tenant state. Global tenants open; private tenants require ownership.
/public/tenants/{id}/state
Replace tenant state. Body: {"state":{}}
auth
/public/tenants/{id}/settings
Get tenant settings. Same visibility rules as state.
/public/tenants/{id}/settings
Merge-patch tenant settings. Body: any JSON object.
auth
/public/tenants/{id}
Delete tenant and all its scenarios.
auth
Scenarios
/public/tenants/{id}/scenarios
List scenarios. Same visibility rules as state.
/public/tenants/{id}/scenarios
Add a scenario or MCP tool. Body: {"keywords":["…"],"response":"…","tool_name":"…","tool_data":{}}
auth
/public/tenants/{id}/scenarios/{sid}
Delete a scenario by ID.
auth
Chaos
/public/tenants/{id}/chaos
Get current chaos profile. Same visibility rules as state.
/public/tenants/{id}/chaos
Set profile: none rate_limit server_error latency
auth
Running on this server right now. Each tenant has its own mock state, scenarios, and MCP tools.