Examples
Raw JSON-RPC exchanges with https://mcp-us.zoie.ai — initialize, tools/list, tools/call and the main error shapes — plus a TypeScript SDK client and ready-to-paste client configuration.
These examples talk to the MCP server directly, so you can see exactly what goes over the wire. Most clients do all of this for you; if you only need to connect one, jump to Client configuration.
Before you start
You need an access token from the OAuth flow described in Authentication. The examples read it from ZOIE_MCP_TOKEN:
export ZOIE_MCP_TOKEN='eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9…'
Every request is a POST to https://mcp-us.zoie.ai/ with the same three headers. The response is a short text/event-stream: one event: message line and one data: line holding the JSON-RPC response. See Transport for the details.
Initialize
curl -sN https://mcp-us.zoie.ai/ \
-H "Authorization: Bearer $ZOIE_MCP_TOKEN" \
-H 'Content-Type: application/json' \
-H 'Accept: application/json, text/event-stream' \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "initialize",
"params": {
"protocolVersion": "2025-06-18",
"capabilities": {},
"clientInfo": { "name": "acme-assistant", "version": "1.0.0" }
}
}'// Sends one JSON-RPC message and returns the parsed JSON-RPC response.
async function mcp(body) {
const res = await fetch('https://mcp-us.zoie.ai/', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.ZOIE_MCP_TOKEN}`,
'Content-Type': 'application/json',
Accept: 'application/json, text/event-stream',
},
body: JSON.stringify(body),
});
if (res.status === 202) return null; // notification accepted
const text = await res.text();
if (!res.ok) throw new Error(`HTTP ${res.status}: ${text}`);
const data = text.split('\n').find((line) => line.startsWith('data: '));
return JSON.parse(data.slice('data: '.length));
}
const init = await mcp({
jsonrpc: '2.0',
id: 1,
method: 'initialize',
params: {
protocolVersion: '2025-06-18',
capabilities: {},
clientInfo: { name: 'acme-assistant', version: '1.0.0' },
},
});event: message
data: {"result":{"protocolVersion":"2025-06-18","capabilities":{"tools":{"listChanged":true}},"serverInfo":{"name":"zoie-mcp","version":"0.1.0"}},"jsonrpc":"2.0","id":1}
Then send the initialized notification. Because it has no id, the server answers 202 Accepted with no body:
curl -s -o /dev/null -w '%{http_code}\n' https://mcp-us.zoie.ai/ \
-H "Authorization: Bearer $ZOIE_MCP_TOKEN" \
-H 'Content-Type: application/json' \
-H 'Accept: application/json, text/event-stream' \
-d '{"jsonrpc":"2.0","method":"notifications/initialized"}'
202
No Mcp-Session-Id comes back, and none is needed on later requests — the server is stateless.
List the tools
curl -sN https://mcp-us.zoie.ai/ \
-H "Authorization: Bearer $ZOIE_MCP_TOKEN" \
-H 'Content-Type: application/json' \
-H 'Accept: application/json, text/event-stream' \
-H 'MCP-Protocol-Version: 2025-06-18' \
-d '{"jsonrpc":"2.0","id":2,"method":"tools/list"}'
The data: line holds all 29 tools. One entry, formatted:
{
"name": "get_lead",
"title": "Get lead by id",
"description": "Fetch a single lead by its internal id.",
"inputSchema": {
"type": "object",
"properties": {
"lead_id": { "type": ["string", "number"] }
},
"required": ["lead_id"],
"additionalProperties": false,
"$schema": "http://json-schema.org/draft-07/schema#"
},
"annotations": {
"readOnlyHint": true,
"destructiveHint": false,
"idempotentHint": true,
"openWorldHint": false
},
"execution": { "taskSupport": "forbidden" }
}
Call a tool
list_my_businesses
A good first call: it needs no scope and tells you which business the connection is bound to.
curl -sN https://mcp-us.zoie.ai/ \
-H "Authorization: Bearer $ZOIE_MCP_TOKEN" \
-H 'Content-Type: application/json' \
-H 'Accept: application/json, text/event-stream' \
-H 'MCP-Protocol-Version: 2025-06-18' \
-d '{"jsonrpc":"2.0","id":3,"method":"tools/call","params":{"name":"list_my_businesses","arguments":{}}}'
event: message
data: {"result":{"content":[{"type":"text","text":"{\n \"user\": {\n \"id\": 1187,\n …"}]},"jsonrpc":"2.0","id":3}
Parse result.content[0].text as JSON:
{
"user": { "id": 1187, "email": "[email protected]" },
"memberships": [
{
"business_id": 214,
"business_name": "Bright Smiles Dental",
"business_industry": "HEALTHCARE",
"role_id": 3,
"role_name": "Admin",
"display_name": "Sam"
},
{
"business_id": 377,
"business_name": "Bright Smiles Ortho",
"business_industry": "HEALTHCARE",
"role_id": 9,
"role_name": "Sales",
"display_name": null
}
],
"active_business_id": 214,
"allowed_business_ids": null,
"note": "This token is bound to one business (`active_business_id`). To switch, ask the user to re-authorize the connector and pick a different business."
}
memberships lists every business the user belongs to. This connection covers only business 214, so tools ignore any business_id you pass. On a multi-business connection, active_business_id is null and allowed_business_ids lists the businesses to choose from.
preview_campaign_audience
A call with arguments. It reads data only, so it’s safe to try:
curl -sN https://mcp-us.zoie.ai/ \
-H "Authorization: Bearer $ZOIE_MCP_TOKEN" \
-H 'Content-Type: application/json' \
-H 'Accept: application/json, text/event-stream' \
-H 'MCP-Protocol-Version: 2025-06-18' \
-d '{
"jsonrpc": "2.0",
"id": 4,
"method": "tools/call",
"params": {
"name": "preview_campaign_audience",
"arguments": {
"channel": "sms",
"filters": [
{ "field": "status", "condition": "is", "value": "New" },
{ "field": "label", "condition": "contains", "value": "VIP" }
]
}
}
}'
The parsed text:
{ "channel": "sms", "count": 42, "max_recipients": 500 }
Errors
Missing scope
A connection approved with Leads & contacts on Read + Write, Conversations on Read only, and Appointments and Campaigns on Not allowed calls send_message. The call is refused before anything is sent:
{
"result": {
"isError": true,
"content": [
{
"type": "text",
"text": "Scope conversations:write is required for send_message; this connection was not granted it."
}
],
"_meta": {
"error": "insufficient_scope",
"required_scope": "conversations:write",
"granted_scopes": ["leads:read", "leads:write", "conversations:read", "notes:read", "notes:write", "team:read", "search:read"]
}
},
"jsonrpc": "2.0",
"id": 5
}
Invalid arguments
get_lead_by_phone with "phone": "555-0100":
{
"result": {
"isError": true,
"content": [
{
"type": "text",
"text": "MCP error -32602: Input validation error: Invalid arguments for tool get_lead_by_phone: [\n {\n \"validation\": \"regex\",\n \"code\": \"invalid_string\",\n \"message\": \"phone must be E.164 format (e.g. +15551234567)\",\n \"path\": [\n \"phone\"\n ]\n }\n]"
}
]
},
"jsonrpc": "2.0",
"id": 6
}
Like every tool failure, this is a normal result with isError: true, not a JSON-RPC error.
Unsupported method
resources/list isn’t implemented, so it fails at the JSON-RPC layer:
{ "jsonrpc": "2.0", "id": 7, "error": { "code": -32601, "message": "Method not found" } }
Expired token
After 8 hours the access token stops working at the HTTP layer:
HTTP/2 401
www-authenticate: Bearer realm="https://mcp-us.zoie.ai", resource_metadata="https://mcp-us.zoie.ai/.well-known/oauth-protected-resource", error="invalid_token", error_description="Token expired"
{"error":"unauthorized","message":"Token expired"}
Refresh the token and retry. If the description is MCP grant revoked, refreshing fails too and the user has to connect again — see The 401 challenge.
TypeScript SDK client
With the official MCP TypeScript SDK and a token you already hold:
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
import { StreamableHTTPClientTransport } from '@modelcontextprotocol/sdk/client/streamableHttp.js';
const transport = new StreamableHTTPClientTransport(new URL('https://mcp-us.zoie.ai'), {
requestInit: {
headers: { Authorization: `Bearer ${process.env.ZOIE_MCP_TOKEN}` },
},
});
const client = new Client({ name: 'acme-assistant', version: '1.0.0' });
await client.connect(transport); // sends initialize and notifications/initialized
const { tools } = await client.listTools();
console.log(tools.map((t) => t.name)); // 29 names
const result = await client.callTool({ name: 'list_my_businesses', arguments: {} });
if (result.isError) throw new Error(result.content[0].text);
const businesses = JSON.parse(result.content[0].text);
To let the SDK run the whole OAuth flow — discovery, registration, PKCE and refresh — pass an authProvider (an implementation of its OAuthClientProvider interface) instead of a fixed Authorization header.
Client configuration
Clients that support remote MCP servers with OAuth need only the URL. They discover the authorisation server, register and open Zoie’s consent screen themselves.
claude mcp add --transport http zoie https://mcp-us.zoie.aiThen run /mcp in Claude Code, choose zoie and authenticate in the browser. Add --scope project to save it in the project’s .mcp.json for your team.
{
"mcpServers": {
"zoie": {
"type": "http",
"url": "https://mcp-us.zoie.ai"
}
}
}{
"mcpServers": {
"zoie": {
"url": "https://mcp-us.zoie.ai"
}
}
}{
"servers": {
"zoie": {
"type": "http",
"url": "https://mcp-us.zoie.ai"
}
}
}Use the bare URL: no /mcp or /sse path and no static Authorization header, which would bypass the OAuth flow and stop working after 8 hours. Step-by-step guides for each client are in Connect Claude, Connect Cursor and Connect another MCP client.