Vercel AI SDK
Dinobase integrates with the Vercel AI SDK via MCP. No adapter code needed — the AI SDK’s MCP client connects directly to Dinobase’s MCP server.
Install
Section titled “Install”npm install ai @ai-sdk/anthropic @ai-sdk/mcppip install dinobaseSet up Dinobase with your data sources:
dinobase initdinobase add stripe --api-key sk_test_...dinobase syncSee Connecting Sources for the full list of 100+ supported sources, and Syncing & Scheduling for background sync options.
Next.js API Route
Section titled “Next.js API Route”import { streamText } from 'ai';import { anthropic } from '@ai-sdk/anthropic';import { createMCPClient } from '@ai-sdk/mcp';import { Experimental_StdioMCPTransport } from '@ai-sdk/mcp/mcp-stdio';
export async function POST(req: Request) { const { messages } = await req.json();
const dinobase = await createMCPClient({ transport: new Experimental_StdioMCPTransport({ command: 'dinobase', args: ['serve'], }), });
const tools = await dinobase.tools();
const result = streamText({ model: anthropic('claude-sonnet-4-6'), messages, tools, });
result.onFinish(() => dinobase.close());
return result.toDataStreamResponse();}The AI SDK automatically discovers all 7 Dinobase MCP tools.
Node.js Script
Section titled “Node.js Script”For scripts and CLI tools, use generateText():
import { generateText } from 'ai';import { anthropic } from '@ai-sdk/anthropic';import { createMCPClient } from '@ai-sdk/mcp';import { Experimental_StdioMCPTransport } from '@ai-sdk/mcp/mcp-stdio';
const dinobase = await createMCPClient({ transport: new Experimental_StdioMCPTransport({ command: 'dinobase', args: ['serve'], }),});
const tools = await dinobase.tools();
const { text } = await generateText({ model: anthropic('claude-sonnet-4-6'), prompt: 'Which customers have overdue invoices?', tools, maxSteps: 5,});
console.log(text);await dinobase.close();Available Tools
Section titled “Available Tools”The MCP server exposes these tools to the AI model:
| Tool | Description |
|---|---|
query | Execute SQL queries (DuckDB dialect) |
describe | Get table schema, column types, and sample data |
list_sources | List all connected sources with row counts and freshness |
refresh | Re-sync a data source to get fresh data |
confirm | Execute a pending mutation (write-back to source API) |
confirm_batch | Execute multiple pending mutations |
cancel | Cancel a pending mutation |
Background Sync
Section titled “Background Sync”To keep data fresh while the MCP server runs:
const dinobase = await createMCPClient({ transport: new Experimental_StdioMCPTransport({ command: 'dinobase', args: ['serve', '--sync', '--sync-interval', '30m'], }),});Experimental_StdioMCPTransportruns in Node.js only (not edge runtime or browser)- Always close the MCP client when done to clean up the subprocess
- The model sees dynamic instructions computed from your actual database state — it knows what sources and tables are available
Next steps
Section titled “Next steps”- Getting Started — Full setup walkthrough
- Connecting Sources — Add your business data
- Querying Data — SQL patterns and cross-source joins
- Syncing & Scheduling — Keep data fresh
- Schema Annotations — Add context for AI agents
- MCP Integration — How the MCP server works
- MCP Tools Reference — Detailed tool schemas
- Example code