Examples
See It in Action
Practical examples for connecting to and using the OpenAgent Core — from initial setup to real conversations with financial data.
Connecting to the MCP Server
Three ways to connect — pick the one that fits your stack.
Claude Desktop
mcpServers config
{
"mcpServers": {
"basiq-financial": {
"url": "https://your-mcp-server.workers.dev/mcp",
"headers": {
"Authorization": "Bearer sk_live_your_tenant_api_key"
}
}
}
}Python
PydanticAI / MCP client
import httpx
MCP_URL = "https://your-mcp-server.workers.dev/mcp"
HEADERS = {
"Authorization": "Bearer sk_live_your_tenant_api_key",
"Content-Type": "application/json"
}
async with httpx.AsyncClient() as client:
# Initialize
await client.post(MCP_URL, headers=HEADERS, json={
"jsonrpc": "2.0", "id": 1,
"method": "initialize",
"params": {
"protocolVersion": "2024-11-05",
"capabilities": {}
}
})
# List tools
response = await client.post(MCP_URL, headers=HEADERS, json={
"jsonrpc": "2.0", "id": 2,
"method": "tools/list"
})cURL
Single tool call
curl -X POST https://your-mcp-server.workers.dev/mcp \
-H "Authorization: Bearer sk_live_your_tenant_api_key" \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "create_user",
"arguments": {
"email": "user@example.com"
}
}
}'Code Execution Connection
Present the MCP server as a code API. The agent loads tools on-demand and processes data in the execution environment — dramatically reducing token usage.
const MCP_URL = process.env.MCP_SERVER_URL || "https://your-mcp-server.workers.dev/mcp";
const TENANT_API_KEY = process.env.TENANT_API_KEY;
export async function callMCPTool<T>(
toolName: string,
args: Record<string, unknown>
): Promise<T> {
const response = await fetch(MCP_URL, {
method: "POST",
headers: {
"Authorization": `Bearer ${TENANT_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
jsonrpc: "2.0",
id: crypto.randomUUID(),
method: "tools/call",
params: { name: toolName, arguments: args },
}),
});
const result = await response.json();
if (result.error) throw new Error(result.error.message);
return JSON.parse(result.result?.content?.[0]?.text || "{}");
}Usage Examples
The most frequently used tools — ready to copy and adapt.
create_user
Register a new user
{
"method": "tools/call",
"params": {
"name": "create_user",
"arguments": {
"email": "jane@example.com",
"mobile": "+61412345678"
}
}
}generate_consent_url
Get bank authorization URL
{
"method": "tools/call",
"params": {
"name": "generate_consent_url",
"arguments": {
"userId": "usr_abc123xyz",
"callbackUrl": "https://myapp.com/callback"
}
}
}get_transactions
Fetch transactions with filters
{
"method": "tools/call",
"params": {
"name": "get_transactions",
"arguments": {
"userId": "usr_abc123xyz",
"from": "2025-01-01",
"to": "2025-01-31",
"limit": 50
}
}
}get_financial_health_score
Get user's health score
{
"method": "tools/call",
"params": {
"name": "get_financial_health_score",
"arguments": {
"userId": "usr_abc123xyz"
}
}
}End-to-End Onboarding Flow
From user creation to connected bank accounts — the complete sequence.
| Step | Tool | Purpose |
|---|---|---|
| 1 | create_user | Register user, get userId |
| 2 | generate_consent_url | Get URL for user to authorize bank |
| 3 | Out of band | User completes consent in browser |
| 4 | check_consent_status | Poll until job completes |
| 5 | get_accounts | Verify connections, list accounts |
| 6 | get_transactions | Fetch transaction history |
TypeScript Example
import * as users from "./servers/basiq-financial/users";
import * as consent from "./servers/basiq-financial/consent";
import * as accounts from "./servers/basiq-financial/accounts";
async function onboardNewUser(email: string) {
// 1. Create user
const user = await users.createUser({ email });
console.log(`User created: ${user.userId}`);
// 2. Generate consent URL
const { consentUrl } = await consent.generateConsentUrl({
userId: user.userId,
callbackUrl: "https://myapp.com/callback"
});
console.log(`Send user to: ${consentUrl}`);
// 3. (User authorizes in browser — use webhooks or polling)
// 4. After consent: fetch accounts
const accountsList = await accounts.getAccounts({
userId: user.userId
});
console.log(`Connected ${accountsList.length} accounts`);
return {
userId: user.userId,
consentUrl,
accounts: accountsList
};
}Conversations in Action
How end users interact with an AI assistant backed by the OpenAgent Core. The AI uses tools under the hood — users see natural conversation.
Personal Finance Assistant
What did I spend on groceries last month?
You spent $342.50 on groceries last month across 8 transactions. Your largest purchase was $89 at Woolworths on the 15th.
How's my financial health?
Your financial health score is 78/100. You're saving 22% of your income, which is strong. One area to watch: dining out spending is up 15% compared to last month.
Break down my spending by category for January
January Spending
First-Time Bank Setup
I want to connect my bank so you can help me track my spending.
I'll help you connect your bank. This takes about 2–3 minutes and is secure — your credentials never pass through our systems.
First, I need your email to create your account.
jane@example.com
Done. Next, please open this link to authorize access to your bank accounts. You'll sign in with your bank's credentials on their secure page. When you're finished, come back here and tell me.
[User completes consent in browser]
I've finished connecting my bank.
Your accounts are connected. I can see your everyday and savings accounts. Would you like a spending summary for this month, or help with something else?
More Scenarios
Show me all expenses over $500 this quarter
Expenses over $500
My bank connection isn't showing my latest transactions
I've triggered a sync for your bank connection. It usually takes 30–60 seconds. I'll check the status and let you know when it's done.
Continue Learning
Dig deeper into each area of the OpenAgent Core.
AI Client Quick Start
Compare standard vs code execution approaches and choose the right one.
Read guideCode Execution Guide
Full setup, file structure, and best practices for production integrations.
Read guideBasiq Consent Flow
CDR consent process, callbacks, and error recovery detailed walkthrough.
Coming soonMCP Protocol Reference
JSON-RPC protocol details, tool schemas, and error codes for AI clients.
Coming soon