Mastra
Dinobase integrates with Mastra via MCP. Mastra has first-class MCP support, so Dinobase’s MCP server works with zero adapter code.
Install
Section titled “Install”npm install @mastra/core @mastra/mcp @ai-sdk/anthropic zodpip install dinobaseSet up your data sources:
dinobase initdinobase add stripe --api-key sk_test_...dinobase add hubspot --api-key pat-...dinobase syncSee Connecting Sources for the full list of 100+ supported sources, and Syncing & Scheduling for background sync options.
Quick Start
Section titled “Quick Start”import { Agent } from "@mastra/core";import { MCPClient } from "@mastra/mcp";import { anthropic } from "@ai-sdk/anthropic";
// Connect to Dinobase MCP serverconst mcp = new MCPClient({ id: "dinobase-mcp", servers: { dinobase: { command: "dinobase", args: ["serve"], }, },});
// All 7 Dinobase tools discovered automaticallyconst agent = new Agent({ id: "data-analyst", name: "Data Analyst", instructions: "You are a data analyst. Query business data via SQL.", model: anthropic("claude-sonnet-4-6"), tools: await mcp.listTools(),});
const response = await agent.generate( "Which customers have overdue invoices?");console.log(response.text);
await mcp.disconnect();How It Works
Section titled “How It Works”Mastra’s MCPClient spawns the Dinobase MCP server as a subprocess (dinobase serve) and communicates via stdio. All 7 Dinobase MCP tools are discovered automatically and made available to the agent.
This is the same MCP server used by Claude Desktop and Vercel AI SDK — same tools, same data, different framework.
Available Tools
Section titled “Available Tools”Via MCP, the agent gets access to:
| Tool | Description |
|---|---|
query | Execute SQL queries (DuckDB dialect) |
describe | Get table schema, types, and sample data |
list_sources | List connected sources with freshness status |
refresh | Re-sync a stale data source |
confirm | Execute a pending mutation (write-back) |
confirm_batch | Execute multiple pending mutations |
cancel | Cancel a pending mutation |
Custom Tools (Alternative)
Section titled “Custom Tools (Alternative)”If you want more control over tool behavior, you can wrap the Dinobase CLI using createTool():
import { createTool } from "@mastra/core/tools";import { z } from "zod";import { execSync } from "child_process";
export const dinobaseQuery = createTool({ id: "dinobase-query", description: "Execute SQL against Dinobase", inputSchema: z.object({ sql: z.string().describe("SQL query to execute"), }), outputSchema: z.object({ result: z.string() }), execute: async ({ sql }) => ({ result: execSync(`dinobase query ${JSON.stringify(sql)}`, { encoding: "utf-8", }), }),});See examples/tools.ts for all four tool wrappers.
Background Sync
Section titled “Background Sync”Keep data fresh while the MCP server runs:
const mcp = new MCPClient({ id: "dinobase-mcp", servers: { dinobase: { command: "dinobase", args: ["serve", "--sync", "--sync-interval", "30m"], }, },});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