Skip to main content
Import: from gaia.mcp import MCPClientMixin, MCPClient, MCPClientManager
See also: API Specification · Windows System Health Agent

What is MCP?

MCP (Model Context Protocol) is a universal connector that lets any AI application talk to any tool — a standard created by Anthropic. Instead of building custom integrations for each service, agents connect to MCP servers that expose tools like read_file, create_issue, or query_database.
GAIA agents act as MCP clients that connect to MCP servers. The MCPClientMixin adds this capability to any GAIA agent — mix it in, point it at a server, and that server’s tools become available automatically.
Learn More: Visit modelcontextprotocol.io for the full specification and ecosystem.

Architecture


Quick Start

1

Initialize MCP configuration

This creates ~/.gaia/mcp_servers.json with an empty configuration.
2

Add an MCP server

Add a server entry to ~/.gaia/mcp_servers.json:
gaia mcp add / gaia mcp remove were removed in #977 — MCP servers are now configured through the connectors framework (gaia connectors --help) or by editing mcp_servers.json directly.
3

Use in your agent

4

Test interactively


Connect Multiple Servers

Connect to as many servers as needed. GAIA prefixes each tool with the server name (e.g., mcp_filesystem_read_file, mcp_github_create_issue) so tools from different servers never collide.

Load from Config

A configuration file lets you manage MCP servers without changing agent code. On startup, GAIA automatically stacks two config files — one global default, one project-specific — so you never have to choose between them.

Config stacking

GAIA loads configs in order of increasing priority: Both files are merged at startup. Servers defined in the local file override same-named entries from the global file. Servers defined only in one file are always included.

Config file format

The config format follows the MCP client configuration standard. If you already have an MCP config from another client (e.g. Claude Desktop), you can copy it directly.

Using config in your agent

By default, MCPClientMixin.__init__() auto-loads both config files:
To load a specific config file instead (skips stacking):
When config_file is provided, only that file is loaded — global and local stacking are disabled. Loading is always triggered when config_file is set, regardless of the auto_load_config flag.
Finding servers: Browse the MCP Server Hub on glama.ai or the official MCP servers list.

Direct Client Usage

MCPClient is the lower-level building block for use outside of agents — in standalone scripts, test suites, or custom pipelines.
MCPClient only supports stdio transport (subprocess-based). HTTP and SSE transports are not supported at this time.

Error Handling

GAIA’s MCP client uses a return-value error model rather than raising exceptions for expected failures.

API Reference

MCPClientMixin

MCPClient


CLI Commands

gaia mcp add and gaia mcp remove were removed in #977. MCP servers are now managed through the connectors framework (gaia connectors --help) or by editing ~/.gaia/mcp_servers.json directly.

Security

Vet MCP servers before connecting. Each server runs as a subprocess with access to your system.
  1. Review the source — Only use servers from trusted sources with public repositories
  2. Check permissions — Understand what system access the server requires
  3. Limit scope — Restrict filesystem servers to specific directories rather than /
  4. Audit environment variables — Never pass secrets to servers you haven’t reviewed

Troubleshooting

The MCP server command (like npx or uvx) isn’t in your PATH.
load_mcp_servers_from_config() returns 0 servers. GAIA merges two config files at startup:
  1. ~/.gaia/mcp_servers.json — global config, always checked
  2. ./mcp_servers.json — local config, checked in the current working directory
Verify the files exist:
To use a specific config file instead, pass it explicitly — this loads only that file and skips the global and local configs entirely:
  1. Verify connection: print(agent.list_mcp_servers())
  2. List tools: gaia mcp tools <server-name>
  3. Enable debug: import logging; logging.basicConfig(level=logging.DEBUG)
Requests time out after 30s by default. For servers that need a longer timeout, use the lower-level MCPClient, which accepts timeout (seconds):
Test directly: gaia mcp test-client <server-name>