text stringlengths 0 59.1k |
|---|
It all depends on your objectives, budget, and requirements. For simple interactions, a chatbot would be great. For complex automation, an AI agent built with tools like VoltAgent could transform your company. |
There is a place for each technology, and understanding the difference enables you to make the right choice for your use case. |
<|endoftext|> |
# source: VoltAgent__voltagent/website/blog/2025-07-25-mcp-tutorial/index.md type: docs |
--- |
title: MCP Tutorial - Connect Your AI Agent to Any External System |
description: Learn how to use Model Context Protocol (MCP) to give your VoltAgent access to external systems like GitHub, databases, and AI models with simple plug-and-play integration. |
slug: llm-mcp-tutorial |
image: https://cdn.voltagent.dev/2025-07-25-mcp-tutorial/social.png |
authors: omeraplak |
--- |
import ZoomableMermaid from '@site/src/components/blog-widgets/ZoomableMermaid'; |
# MCP Tutorial: Connect Your AI Agent to Any External System |
Building AI agents is exciting until you realize they're isolated from the real world. Most agents can process text and use basic tools, but they can't access files, databases, or external APIs that developers actually need. |
This tutorial will show you how Model Context Protocol (MCP) solves this problem by providing a universal standard for connecting AI agents to external systems. |
## The Isolation Problem in AI Development |
Standard AI agents face significant limitations when it comes to external system access. They can't: |
- Read or write files on your computer |
- Access GitHub repositories or databases |
- Query external APIs or services |
- Integrate with the tools developers use daily |
Traditional solutions require building custom integrations for each service - writing authentication logic, handling rate limits, and maintaining separate connections. This approach doesn't scale and creates maintenance overhead. |
MCP provides a standardized protocol that allows AI agents to connect to any external system through a unified interface. |
## Understanding MCP: The Universal Connector |
Model Context Protocol is just the USB protocol for AI agents. Just as USB makes it so you can stick any device into any computer, MCP makes it so that you can connect any agent to any external service through a standardized interface. |
The architecture is beautifully simple: |
- **MCP Servers** expose external services (files, databases, APIs) |
- **MCP Clients** (your VoltAgent) reach out to them |
- **Everything happens securely** with proper authentication |
Here's how the communication flows between all components: |
 |
This sequence shows how seamlessly MCP coordinates between different services - your agent can use local filesystem tools and remote AI models in a single workflow, all through the same standardized protocol. |
## Building an MCP-Enabled Agent |
Let's build a practical example by creating a weather agent with file system access through MCP. This demonstrates how to add external capabilities to any AI agent. |
```typescript |
import { VoltAgent, Agent, createTool, MCPConfiguration } from "@voltagent/core"; |
import { VercelAIProvider } from "@voltagent/vercel-ai"; |
import { openai } from "@ai-sdk/openai"; |
import { z } from "zod"; |
import path from "node:path"; |
// Simple weather functionality |
const weatherTool = createTool({ |
name: "get_weather", |
description: "Get current weather for any city", |
parameters: z.object({ |
location: z.string().describe("City and state, e.g. New York, NY"), |
}), |
execute: async ({ location }) => { |
console.log(`Fetching weather data for ${location}...`); |
if (location.toLowerCase().includes("new york")) { |
return { temperature: "18°C", condition: "Partly cloudy" }; |
} |
return { temperature: "24°C", condition: "Sunny" }; |
}, |
}); |
// Here's where MCP magic happens |
const mcpConfig = new MCPConfiguration({ |
servers: { |
filesystem: { |
type: "stdio", |
command: "npx", |
args: [ |
"-y", |
"@modelcontextprotocol/server-filesystem", |
path.join(process.env.HOME || "", "Desktop"), |
], |
cwd: process.env.HOME, |
timeout: 10000, |
}, |
}, |
}); |
(async () => { |
const mcpTools = await mcpConfig.getTools(); |
const agent = new Agent({ |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.