MCP (Model Context Protocol)
MCP lets you integrate an LLM (on the hospital side) directly with SauBit's tools via a single
standardized endpoint. Instead of the client implementing REST calls manually, it connects to the
MCP Server and the LLM calls tools like saubit.interactions_check.
Endpoint
- URL:
https://api.saubit.com.br/mcp - Authentication:
X-API-Keyheader
Configuration (copy & paste)
Example MCP client configuration (a common format in IDE/agent tools):
{
"mcpServers": {
"saubit": {
"type": "http",
"url": "https://api.saubit.com.br/mcp",
"headers": {
"X-API-Key": "YOUR_API_KEY"
},
"metadata": {
"name": "saubit-mcp",
"description": "SauBit MCP server for clinical tools (interactions, chat, analyses, billing/usage)."
}
}
}
}
Security
- Always use one API key per organization.
- If your API key has an IP allowlist enabled, MCP also respects that rule.
- For browser usage, the server applies CORS based on
MCP_ALLOWED_ORIGINSand validatesOriginwhen present. - The
saubit.interactions_checktool requires theinteractions:checkscope. - The
saubit.chat_messagetool also depends oninteractions:check. - The
saubit.analyses_listandsaubit.analyses_gettools requireanalyses:read. - The
saubit.usage_summaryandsaubit.billing_summarytools requireusage:readandbilling:read.
CORS (browser)
- If your panel runs on
http://localhost:3000, include that origin inMCP_ALLOWED_ORIGINS. - Example:
MCP_ALLOWED_ORIGINS=http://localhost:3000,https://your-domain.com
Self-onboarding for agents/AIs (start here)
The MCP server is self-documenting: an agent that just connected doesn't need to read this page
to discover the flow — it can call the saubit.getting_started tool (requires no scope beyond a
valid API key) and get, as structured JSON:
- authentication (header,
sm_test_vssm_live_prefixes, how to get a key); - the recommended call order (
tools/list→saubit.interactions_check→ optionalsaubit.chat_message→ optionalsaubit.analyses_get/saubit.usage_summary); - the scopes required per tool;
- a ready-to-copy
tools/callexample; - how to interpret error codes (HTTP and JSON-RPC).
curl -X POST "https://api.saubit.com.br/mcp" \
-H "Content-Type: application/json" \
-H "X-API-Key: <YOUR_API_KEY>" \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"saubit.getting_started","arguments":{}}}'
The same content is also available as an MCP resource, for clients that prefer
resources/read over tools/call:
curl -X POST "https://api.saubit.com.br/mcp" \
-H "Content-Type: application/json" \
-H "X-API-Key: <YOUR_API_KEY>" \
-d '{"jsonrpc":"2.0","id":1,"method":"resources/read","params":{"uri":"saubit://guide/getting-started"}}'
Available MCP resources (resources/list / resources/read)
| URI | Content |
|---|---|
saubit://guide/getting-started | The same integration guide returned by saubit.getting_started. |
saubit://openapi/hospital.json | Full OpenAPI 3 spec for every client route (X-API-Key) — request/response schema per endpoint, excludes admin routes. |
Available tools
saubit.getting_started— integration guide (start here; no scope required)saubit.interactions_checksaubit.chat_messagesaubit.analyses_listsaubit.analyses_getsaubit.usage_summarysaubit.billing_summary
Important notes
saubit.chat_messageaccepts an optionalanalysis_id(same behavior as REST), so the chat uses the analysis as context and filters mentions of unverified sources.saubit.analyses_getreturnsresponse_body(without echoing the fullpatient_record/request) to reduce data-exposure risk.- The
saubit.interactions_checkreturn uses the same contract as REST, includinganalysis_status,source_coverageandunverified_pairs.
Example (JSON-RPC)
List tools
curl -X POST "https://api.saubit.com.br/mcp" \
-H "Content-Type: application/json" \
-H "Accept: application/json, text/event-stream" \
-H "X-API-Key: <YOUR_API_KEY>" \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/list","params":{}}'
Run an interactions analysis
curl -X POST "https://api.saubit.com.br/mcp" \
-H "Content-Type: application/json" \
-H "Accept: application/json, text/event-stream" \
-H "X-API-Key: <YOUR_API_KEY>" \
-d '{
"jsonrpc":"2.0",
"id":2,
"method":"tools/call",
"params":{
"name":"saubit.interactions_check",
"arguments":{
"medications":[{"name":"Aspirin","dose_mg":100},{"name":"Ketorolac","dose_mg":10}],
"patient_record":{"conditions":["hypertension"],"current_medications":[]}
}
}
}'
MCP Client example (Node.js)
This example uses the MCP HTTP transport and injects X-API-Key on every call.
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
const transport = new StreamableHTTPClientTransport(new URL("https://api.saubit.com.br/mcp"), {
headers: {
"X-API-Key": process.env.SAUBIT_API_KEY!,
},
});
const client = new Client({ name: "hospital-client", version: "1.0.0" }, { capabilities: {} });
await client.connect(transport);
const tools = await client.listTools();
console.log(tools);
const resp = await client.callTool({
name: "saubit.interactions_check",
arguments: {
medications: [{ name: "Aspirin", dose_mg: 100 }, { name: "Ketorolac", dose_mg: 10 }],
patient_record: { conditions: ["hypertension"], current_medications: [] },
},
});
console.log(resp);
What MCP brings
- A standardized tool integration (the LLM calls tools, not endpoints).
- Less boilerplate on the client (hospital) side.
- The same authentication (
X-API-Key), rate limit and usage control already present in SauBit.