text stringlengths 0 59.1k |
|---|
name: "weather-file-agent", |
instructions: `You're a weather assistant with file management capabilities. |
You can check weather conditions and save reports to files for future reference. |
When users ask for weather, consider offering to save the information.`, |
llm: new VercelAIProvider(), |
model: openai("gpt-4o-mini"), |
tools: [weatherTool, ...mcpTools], |
}); |
new VoltAgent({ agents: { agent } }); |
})(); |
``` |
Let me break down what's happening in this code: |
**The Weather Tool**: This is our basic function that simulates getting weather data. It's a simple tool that returns temperature and conditions based on the location. |
**MCP Configuration**: The real magic happens here. We're telling VoltAgent to connect to a filesystem MCP server via `stdio` (standard input/output). The server runs through `npx` and gives our agent access to file operations on the Desktop directory. |
**Tool Integration**: The `mcpConfig.getTools()` call discovers all available MCP tools (like `read_file`, `write_file`, `list_directory`) and we combine them with our weather tool using the spread operator `...mcpTools`. |
**Agent Setup**: Finally, we create an agent that understands it can both check weather AND manage files. The instructions tell it to offer file saving when appropriate. |
With minimal configuration, the agent now has file system capabilities in addition to weather functionality. The MCP integration automatically provides tools like `read_file`, `write_file`, and `list_directory`. |
## MCP in Action |
Here's how the agent uses MCP filesystem tools in a real interaction: |
 |
_Agent seamlessly combining weather data with file operations_ |
The key advantage is how naturally the agent integrates multiple capabilities. It doesn't just have file access - it intelligently uses these tools to enhance weather reporting, save data, and organize information without requiring explicit instructions for each operation. |
## Scaling Up: Remote AI Models over HTTP MCP |
Beyond local file access, MCP also supports HTTP connections to remote services. This opens up access to cloud-based AI models and external APIs. Let's add Hugging Face's AI model ecosystem to our agent. |
First, obtain a free API token from [Hugging Face](https://huggingface.co/settings/tokens) and add it to your environment: |
```bash |
HUGGING_FACE_TOKEN=hf_your_token_here |
``` |
Next, configure the enhanced MCP setup with both local and remote capabilities: |
```typescript |
const enhancedMCPConfig = new MCPConfiguration({ |
servers: { |
// Keep the filesystem access |
filesystem: { |
type: "stdio", |
command: "npx", |
args: [ |
"-y", |
"@modelcontextprotocol/server-filesystem", |
path.join(process.env.HOME || "", "Desktop"), |
], |
cwd: process.env.HOME, |
timeout: 10000, |
}, |
// Add remote AI capabilities |
huggingface: { |
url: "https://huggingface.co/mcp", |
requestInit: { |
headers: { |
Authorization: `Bearer ${process.env.HUGGING_FACE_TOKEN}`, |
}, |
}, |
type: "http", |
timeout: 30000, |
}, |
}, |
}); |
(async () => { |
const allTools = await enhancedMCPConfig.getTools(); |
const superAgent = new Agent({ |
name: "multi-capability-agent", |
instructions: `You're an advanced assistant with multiple capabilities: |
🌤️ Weather: Get current conditions for any location |
📁 Files: Read, write, and organize documents |
🎨 AI Models: Generate images, translate text, analyze content |
You can combine these abilities creatively. For example: |
- Generate weather-themed images |
- Translate weather reports to different languages |
- Create illustrated weather summaries |
Always explain what you're doing and suggest creative combinations.`, |
llm: new VercelAIProvider(), |
model: openai("gpt-4o-mini"), |
tools: [weatherTool, ...allTools], |
}); |
new VoltAgent({ agents: { superAgent } }); |
})(); |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.