Phase 11, part 5: the JSON API
/api/v1 offers the MCP tools as plain HTTP for scripts: GET /api/v1/tools lists what a key may call, POST /api/v1/<tool> calls one with JSON. Each call goes through /mcp internally, so keys, scopes, limits, logging and approvals are the same. /api/v1/docs documents every tool. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
{{define "content"}}{{with .Data}}
|
||||
<h1>Supermarket's JSON API</h1>
|
||||
<p class="lede">For scripts that aren't MCP clients. It's the same tools agents use over MCP (<code>{{.MCP}}</code>), as plain HTTP, with the same keys, scopes, limits and approvals.</p>
|
||||
|
||||
<section class="card">
|
||||
<h2>Using it</h2>
|
||||
<p>Every call needs an agent's key, made under Settings → Agents: <code>Authorization: Bearer sm_…</code>. A key is given modules, each to read or to read and act; it can call only the tools those allow.</p>
|
||||
<ul>
|
||||
<li><code>GET {{.Base}}/tools</code>: what your key may call, with each tool's input schema.</li>
|
||||
<li><code>POST {{.Base}}/<tool></code>: call a tool. The body is a JSON object of its arguments (or empty); the answer is JSON.</li>
|
||||
</ul>
|
||||
<pre>curl -s -X POST {{.Base}}/content_drafts \
|
||||
-H "Authorization: Bearer $SUPERMARKET_KEY" \
|
||||
-H "Content-Type: application/json" -d '{"status": "waiting"}'</pre>
|
||||
<p><strong>Errors</strong> are <code>{"error": "…"}</code>: 401 for a wrong key, 403 for a paused agent, 404 for a tool your key isn't given, 400 for arguments that don't fit, 422 when the tool says no (a draft that's too long), 429 over the agent's calls a minute.</p>
|
||||
<p><strong>Sending things out</strong> (<code>content_publish</code>, <code>outreach_send</code>, <code>mailing_list_add</code>, <code>seo_apply_change</code>) waits for a person's approval in Supermarket, unless that kind was allowed on its own; the answer says which, and <code>approvals_status</code> says what was decided.</p>
|
||||
</section>
|
||||
|
||||
{{range .Docs}}
|
||||
<section class="card api-tool" id="{{.Name}}">
|
||||
<h2><code>POST /api/v1/{{.Name}}</code> <span class="pill">{{.Scope}}</span></h2>
|
||||
<p>{{.Description}}</p>
|
||||
<details><summary class="small">Arguments (JSON Schema)</summary><pre>{{.Schema}}</pre></details>
|
||||
</section>
|
||||
{{end}}
|
||||
{{end}}{{end}}
|
||||
Reference in New Issue
Block a user