Skip to main content
mcp-agent is built on top of the Model Context Protocol (MCP). Agents connect to MCP servers to gain tools, data, prompts, and filesystem-style access. If you are new to the protocol, start with the official MCP introduction; this page shows how MCP fits into mcp-agent.

MCP primitives at a glance

Tools

Functions exposed by MCP servers—use agent.call_tool or let an AugmentedLLM invoke them during generation.

Resources

Structured content retrievable via URIs (agent.list_resources, agent.read_resource).

Prompts

Parameterised templates listed with agent.list_prompts and fetched via agent.get_prompt.

Roots

Named filesystem locations agents can browse; list with agent.list_roots.

Elicitation

Servers can pause a tool to request structured user input; see the elicitation example under examples/mcp.

Sampling

Some servers provide LLM completion endpoints; try the sampling demo in examples/mcp.
Supported Capabilities → covers each primitive in depth.

Example-driven overview

The quickest way to learn is to run the projects in examples/mcp: Each example includes a minimal server configuration and client code that connects via gen_client.

Configuring servers

Add servers to mcp_agent.config.yaml:
Store secrets in mcp_agent.secrets.yaml, environment variables, or preload settings (see Specify Secrets).

Using MCP capabilities from an agent

Common API calls:
  • await agent.call_tool("tool_name", arguments={...})
  • await agent.read_resource(uri)
  • await agent.get_prompt(name, arguments)
  • await agent.list_roots()
AugmentedLLMs inherit these capabilities automatically.

Lightweight MCP client (gen_client)

For persistent connections or aggregators, see Connecting to MCP Servers.

Authentication

Detailed reference

Transport configurations

Best for local subprocess servers:
Ideal for streaming responses and near-real-time updates:
Bi-directional, persistent connections:
HTTP servers with streaming support:

Build a minimal MCP server

demo_server.py

Agent configuration for that server

mcp_agent.config.yaml

Using tools, resources, prompts, and roots

Elicitation example

Capability matrix

Prompts & Resources

Complete example with prompts and resources

MCP Server Examples

All MCP primitive examples

Agent Server

Agents as MCP servers with all primitives

MCP Specification

Official MCP specification