
Connecting Local Databases with Vercel AI SDK v7 MCP Apps
Model Context Protocol is finally starting to feel accessible. Vercel AI SDK v7 integrates MCP out of the box, so I used it to connect an agent to a local SQLite file.
Building custom tools for AI agents is tedious. If you want an agent to read a database, you usually have to write the connection logic, define the Zod schema, handle the errors, and format the output manually.
Model Context Protocol (MCP) was designed to solve this by creating a standard interface between data sources and LLMs. Vercel AI SDK v7 supports MCP apps natively, meaning you can drop in existing servers without writing the glue code. I connected an agent to a local SQLite database to see how smooth the process is.
Skipping the Glue Code
Usually, I would write a runQuery tool. With v7, I just instantiated an MCP client and pointed it at a pre-built SQLite MCP server.
import { generateText } from 'ai';
import { anthropic } from '@ai-sdk/anthropic';
import { createMCPClient } from '@ai-sdk/mcp';
async function queryLocalDB() {
// Connect to a standard MCP server running locally
const dbClient = await createMCPClient({
url: 'http://localhost:3000/mcp',
});
const result = await generateText({
model: anthropic('claude-3-5-sonnet-20240620'),
prompt: 'Check the users table and tell me who has the most logins.',
// Inject the MCP tools directly
tools: dbClient.getTools(),
});
console.log(result.text);
}
queryLocalDB();
Why this is a big deal
The agent successfully queried the database, found the users table, wrote a SQL query to sort by logins, executed it, and returned the answer. I did not write a single line of SQL or any database connection code in my script.
The SDK seamlessly maps the MCP tool definitions into the format the language model expects. This means you can pull open-source MCP servers for Slack, GitHub, or Postgres off the internet and plug them directly into your Vercel AI SDK agents.
We are moving away from writing custom tools for every single data source. The ecosystem is standardizing around MCP, and the v7 update ensures Vercel developers can plug right into it.
Related reading
Our monthly client reports followed a 40-line prompt nobody dared touch. I moved the whole playbook into an uploaded skill using the new uploadSkill API in Vercel AI SDK v7.
Voice agents used to mean marrying one provider's WebSocket event format. I used the new experimental realtime API in Vercel AI SDK v7 to build an order-status voice agent I can move between providers.
Learn how to build your own AI software engineer. We use the new Model Context Protocol (MCP) to give the Vercel AI SDK agent access to read your local file system, write code, and execute bash commands safely.
Let's build something great.
Have a project in mind? We are an elite software and AI development studio ready to bring your ideas to production. Let's talk about your roadmap.