Python and TypeScript SDKs

Estimated reading time: 7 minutes

Official SDKs wrap the JSON-RPC transport with typed tool methods. Both packages are codegen-driven from the live tool catalog, so calling client.list_dashboards() always matches what the server exposes.

Python (claribi-mcp)

Install

pip install claribi-mcp

Quick start

from claribi_mcp import Client

with Client(api_key="claribi_mcp_...") as client:
    client.initialize()
    dashboards = client.list_dashboards(limit=5)
    print(dashboards.structured["items"])

    result = client.run_analysis(question="What was revenue last quarter?")
    print(result.text)

OAuth bearer with refresh

from claribi_mcp import Client, BearerTokenAuth

def refresh():
    new_token, new_expires_at = your_oauth_refresh_flow()
    return new_token, new_expires_at

client = Client(
    auth=BearerTokenAuth(
        access_token=initial_token,
        expires_at=initial_expires_at,
        refresh_callable=refresh,
    ),
)

Sign up via the SDK

client = Client()  # anonymous; only public tools available

pending = client.register_account(
    email="me@example.com",
    organization_name="My Team",
    accept_terms=True,
)
pending_id = pending.structured["pending_id"]

code = input("Enter the 6-digit code from your email: ")
verified = client.verify_email(
    pending_id=pending_id,
    code=code,
    password="a-strong-password",
)
api_key = verified.structured["mcp_api_key"]
print(f"Save this key: {api_key}")

Errors

The SDK raises ToolError when the server returns a JSON-RPC error (unauthorized, forbidden, rate-limited, tier not available, etc.):

from claribi_mcp import Client, ToolError

with Client(api_key="claribi_mcp_...") as client:
    try:
        client.run_analysis(question="anything")
    except ToolError as exc:
        print(exc.code, exc.message)  # -32007 "Feature not available"

Generate typed methods against your server

python scripts/codegen.py \
  --catalog https://claribi.com/api/mcp-server/tool-catalog/ \
  --output claribi_mcp/generated

Re-run codegen after the server adds new tools. The shipped wheel already includes a snapshot, so most users never need to run this.

TypeScript (@claribi/mcp)

Install

npm install @claribi/mcp

Quick start

import { Client } from '@claribi/mcp';

const client = new Client({ apiKey: 'claribi_mcp_...' });
await client.initialize();

const dashboards = await client.callTool('list_dashboards', { limit: 5 });
console.log(dashboards.structured);

const result = await client.callTool('run_analysis', {
  question: 'What was revenue last quarter?',
});
console.log(result.text());

OAuth bearer with refresh

import { Client, BearerTokenAuth } from '@claribi/mcp';

const client = new Client({
  auth: new BearerTokenAuth(
    initialAccessToken,
    initialExpiresAtEpochSeconds,
    async () => {
      const refreshed = await yourOAuthRefreshFlow();
      return refreshed;  // { accessToken, expiresAt }
    },
  ),
});

Generate typed methods

npm run codegen -- \
  --catalog https://claribi.com/api/mcp-server/tool-catalog/ \
  --output src/generated

Errors

import { Client, ToolError } from '@claribi/mcp';

const client = new Client();  // anonymous
try {
  await client.callTool('list_dashboards');
} catch (err) {
  if (err instanceof ToolError) {
    console.error(err.code, err.message);  // -32001 "Authentication required"
  }
}

How codegen works

Both SDKs ship a generator script that pulls /api/mcp-server/tool-catalog/ and writes one method per registered tool. The output is committed to source control so PRs review the diff when new tools land, and so the wheel or npm tarball published from CI is hermetic.

PropertyPythonTypeScript
Package nameclaribi-mcp@claribi/mcp
RegistryPyPInpm
Min runtimePython 3.10Node 18
HTTP clienthttpxglobal fetch
Codegen entryscripts/codegen.pyscripts/codegen.mjs
LicenseMITMIT

Building your own SDK?

The wire protocol is plain JSON-RPC 2.0 over HTTP. Read Authentication for header shape and Tool reference for tool names, then post to /mcp/v1/.