- 🔌 Universal tool integration - Filesystem, GitHub, databases, and hundreds more
- ⚡ Zero code required - Configure once, tools auto-register
- 🌍 Industry standard - Built on Model Context Protocol
- 🔍 Auto-discovery - Tools document themselves to your agent
Examples:
examples/mcp_time_server_agent.py- Simple Python server exampleexamples/mcp_config_based_agent.py- Config file-based loadingexamples/mcp_windows_system_health_agent.py- System analysis with Windows-MCP
See Also:
- SDK Reference - Quick code snippets
- Full Specification - Complete API documentation and implementation details
What is MCP?
The Problem
Building AI agents that interact with external tools is hard. Every service has its own API, authentication method, and data format. Want your agent to read files, create GitHub issues, AND query a database? That’s three separate integrations to build and maintain.The Solution
MCP (Model Context Protocol) is like USB for AI - a universal connector that lets any AI application talk to any tool. Just as USB eliminated the need for custom cables, MCP eliminates the need for custom integrations.How GAIA Uses MCP
GAIA agents act as MCP clients that connect to MCP servers. Each server exposes tools (like “read_file” or “create_issue”) that your agent can call. The protocol handles all the communication details - you just connect and use the tools.See It In Action
Try it now - this connects to an MCP server and starts an interactive session:Quick Start
Add an MCP server
How It Works
- Your Agent inherits from
Agent+MCPClientMixin— the mixin adds MCP capabilities - MCPClientManager handles connections to multiple servers
- Transport Layer communicates via stdio (subprocess)
- MCP Servers expose tools that become available to your agent
Connecting to Servers
connect_mcp_server(name, config)
| Parameter | Type | Required | Description |
|---|---|---|---|
name | str | Yes | Friendly name for the server (used as tool prefix) |
config | dict | Yes | Server configuration (see fields below) |
config.command | str | Yes | Base command to run (e.g., "npx", "uvx") |
config.args | list[str] | No | Arguments for the command |
config.env | dict[str, str] | No | Environment variables for the server process |
bool — True if connection and tool registration succeeded.
- From Config File
- Programmatically
- Via CLI
Configuration
Config File Locations
GAIA looks formcp_servers.json in two locations (in order):
- Project directory -
./mcp_servers.jsonin current working directory - Global config -
~/.gaia/mcp_servers.jsonin user’s home directory
Config File Format
This format is compatible with Claude Desktop and other Anthropic tools. The
mcpServers key, separate command/args fields, and env support are standard across the ecosystem.Popular MCP Servers
- Filesystem
- GitHub
- Python Servers
Adding a New MCP Server
Find a server
Browse the MCP Server Hub on glama.ai or the official MCP servers list. Each listing includes the install command and available tools.
Security Considerations
Before adding an MCP server:- Review the source — Only use servers from trusted sources with public repositories
- Check permissions — Understand what system access the server requires (filesystem paths, API tokens, network access)
- Limit scope — When connecting filesystem servers, restrict to specific directories rather than
/ - Audit environment variables — Never pass secrets (API keys, tokens) to servers you haven’t reviewed
Complete Examples
Working examples are available in the GAIA repository:Time Server Agent
Simple example connecting to a Python MCP server via
uvxConfig-Based Agent
Load servers from
mcp_servers.json - recommended for productionUnder the Hood
CLI Commands
CLI Commands
GAIA provides CLI commands for managing MCP server configurations without writing code.Quick reference:For detailed usage, parameters, and output examples, see the CLI Reference.
MCP CLI Reference
Complete documentation of all MCP CLI commands:
add, list, tools, test-client, removeBest Practices
Best Practices
Error Handling
Always handle connection failures gracefully:
Resource Cleanup
Disconnect servers when done:
Tool Discovery
Cache tool lists instead of fetching repeatedly:
Debug Mode
Enable debug logging during development:
Prerequisites
Prerequisites
GAIA Installation
Initialize MCP configuration:For development with MCP extras:
Node.js (Optional)
Troubleshooting
Connection fails with 'command not found'
Connection fails with 'command not found'
Problem: The MCP server command (like
npx or uvx) isn’t in your PATH.Solution:Config file not found
Config file not found
Problem:
load_mcp_servers_from_config() returns 0 servers.Solution: GAIA looks for mcp_servers.json in:- Current working directory (
./mcp_servers.json) - Home directory (
~/.gaia/mcp_servers.json)
Tools not appearing in agent
Tools not appearing in agent
Problem: Connected to server but tools aren’t being used.Solution:
- Verify connection succeeded:
- List available tools:
- Enable debug mode to see tool registration:
Server process hangs or times out
Server process hangs or times out
Problem: Connection hangs during startup.Solution:
- Some servers need initialization time. Try increasing timeout:
- Test the server directly:
Next Steps
MCP Server Hub
Browse and discover MCP servers with install commands and tool listings
Official MCP Servers
Browse official MCP servers from Anthropic
Build a Custom Agent
Learn how to create agents that leverage MCP tools
Create MCP Server
Build your own MCP server to expose custom tools
API Reference
Detailed API documentation for MCP Client