Connect an AI assistant.
Goal: give an assistant one hour of read-only access to the twins of one project through MCP, ask it a question, then find its tool calls in the audit chain.
STEP 1 Issue a token for one project Beta#
With your console token (STARCO_CONSOLE in the shell, console and project in Python, all three from the quickstart, step 2), issue an MCP token for a synthetic project. It is read-only (mcp:read), valid for exactly one hour, revocable earlier with the project's keys, and limited to that project.
MCP=$(curl -s -X POST "$API/projects/$PROJECT/mcp-tokens" -H "Authorization: Bearer $STARCO_CONSOLE" \
-H "Content-Type: application/json" -d '{}' | jq -r .secret)mcp = requests.post(f"{API}/projects/{project['id']}/mcp-tokens", headers={"Authorization": f"Bearer {console}"}, json={}).json()["secret"]import { Client } from '@starco/sdk';
const base = "https://api.starco.dev/v1";
const account = new Client({ baseUrl: base, consoleToken: process.env.STARCO_CONSOLE });
const token = (await account.mcpTokens.create(process.env.PROJECT)).secret; // shown once, one hour, read-onlystarco mcp token --save # for the default project (starco projects use); kept as the CLI's MCP token (0600)STEP 2 Initialize Beta#
The server speaks JSON-RPC over HTTP POST to /v1/mcp (protocol 2025-06-18). Send Accept: application/json, text/event-stream; the answer is plain JSON.
H=(-H "Authorization: Bearer $MCP" -H "Content-Type: application/json" -H "Accept: application/json, text/event-stream")
curl -s "$API/mcp" "${H[@]}" -d '{"jsonrpc": "2.0", "id": 1, "method": "initialize", "params": {"protocolVersion": "2025-06-18", "capabilities": {}, "clientInfo": {"name": "tutorial", "version": "1"}}}'
curl -s "$API/mcp" "${H[@]}" -d '{"jsonrpc": "2.0", "method": "notifications/initialized"}'const m = new Client({ baseUrl: base, mcpToken: token });
console.log(await m.mcp.initialize("tutorial", "1")); // also sends notifications/initializedSTEP 3 List the tools Beta#
Six tools, all marked readOnlyHint: twins.list, twin.get, layer.get, series.range, history.get and audit.verify. There is no tool that writes.
curl -s "$API/mcp" "${H[@]}" -H "MCP-Protocol-Version: 2025-06-18" -d '{"jsonrpc": "2.0", "id": 2, "method": "tools/list"}' | jq -r '.result.tools[].name'for (const t of await m.mcp.tools()) console.log(t.name);starco mcp tools # the CLI does the handshake of step 2 itselfSTEP 4 Ask, the way an assistant would#
An assistant answers a question by calling a tool. Here, the steps of the last week:
curl -s "$API/mcp" "${H[@]}" -H "MCP-Protocol-Version: 2025-06-18" -d '{"jsonrpc": "2.0", "id": 3, "method": "tools/call", "params": {"name": "series.range", "arguments": {"twin_id": "'$TWIN'", "measure": "wellness.steps", "from": "2026-11-12T00:00:00Z", "to": "2026-11-19T00:00:00Z"}}}' \
| jq -r '.result.structuredContent.points[] | "\(.t[:10]) \(.v)"'const out = await m.mcp.call("series.range", {
twin_id: process.env.TWIN, measure: "wellness.steps", from: "2026-11-12T00:00:00Z", to: "2026-11-19T00:00:00Z" });
for (const p of out.structuredContent.points) console.log(p.t.slice(0, 10), p.v);starco mcp call series.range twin_id=<twin> measure=wellness.steps from=2026-11-12T00:00:00Z to=2026-11-19T00:00:00Zsteps on 7 of the last 7 days. The highest value was 10,240 steps, on 17 November. This describes synthetic data from STARCO and was written by an AI; it is not medical advice.Illustrative exchange over the synthetic twin of tutorials 01 to 04. Show the «AI» label next to every answer in your own interface. Questions such as «is that good?» get a description, not a judgement.
STEP 5 Find the assistant in the audit chain Beta#
Every MCP request is a row of the project's audit chain, with actor_type mcp, the method and the tool, never the arguments or values. Read and verify it with your project key exactly as in tutorial 05.
curl -s "$API/audit?limit=200" -H "Authorization: Bearer $STARCO_KEY" | jq -c '.data[] | select(.actor_type == "mcp") | {seq, action, detail}'const c = new Client({ baseUrl: base, apiKey: process.env.STARCO_KEY });
for await (const e of c.audit.iter()) {
if (e.actor_type === "mcp") console.log(e.seq, e.action, e.detail);
}starco --json audit list --limit 200 | jq -c '.data[] | select(.actor_type == "mcp") | {seq, action, detail}'Never give a project key to an assistant: the MCP token exists so that you do not have to. This is where the assistant stands among the other clients of the project:
A twin in the middle and five clients around it. Each request is a dot that travels towards the twin: it comes back from the twin when it is served, and it bounces before reaching it when it is refused. your app (project key, read + write): GET /v1/twins answers 200; POST /v1/twins/{twin}/observations answers 200. notebook (project key, read): GET /v1/twins answers 200; POST /v1/twins/{twin}/observations answers 403 insufficient_scope. AI assistant (MCP token, mcp:read): POST /v1/mcp tools/call layer.get answers 200; GET /v1/twins answers 401 invalid_key. importer (project key, write): POST /v1/twins/{twin}/observations answers 200; GET /v1/twins answers 403 insufficient_scope. unknown key (not a key of the project, no scope): GET /v1/twins answers 401 invalid_key. Every request answered 200 or 403 adds a row to the project's audit chain; a request with a credential that is not a key of the project does not.
The credential decides. 200: served. 403 insufficient_scope: a valid key without the scope the operation needs (write does not include read). 401 invalid_key: not a project key, whether an unknown secret or an MCP token used outside POST /v1/mcp. Simulated requests: nothing is sent.
What just happened
The assistant never saw your project key: it held a token that can only read one project for one hour. Every request it made is in your audit chain, and its answer said it came from an AI.