Skip to content

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.

Terminal window
npm install ai @ai-sdk/anthropic @ai-sdk/mcp
pip install dinobase

Set up Dinobase with your data sources:

Terminal window
dinobase init
dinobase add stripe --api-key sk_test_...
dinobase sync

See Connecting Sources for the full list of 100+ supported sources, and Syncing & Scheduling for background sync options.

app/api/chat/route.ts
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.

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();

The MCP server exposes these tools to the AI model:

ToolDescription
queryExecute SQL queries (DuckDB dialect)
describeGet table schema, column types, and sample data
list_sourcesList all connected sources with row counts and freshness
refreshRe-sync a data source to get fresh data
confirmExecute a pending mutation (write-back to source API)
confirm_batchExecute multiple pending mutations
cancelCancel a pending mutation

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_StdioMCPTransport runs 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