What is MCP?
The Model Context Protocol (MCP) is an open standard for exposing tools, data, prompts, and other capabilities to AI applications. If you are new to the protocol, start with:- Official MCP introduction
- FastMCP documentation for a deeper dive into server/client behavior
Learn by example
Theexamples/mcp directory contains runnable demonstrations for the major MCP capabilities:
| Example | What it shows | Transport | 
|---|---|---|
| mcp/mcp_streamable_http | Connecting to a remote HTTP MCP server with streaming responses | streamable_http | 
| mcp/mcp_sse | Subscribing to an SSE MCP server | sse | 
| mcp/mcp_websockets | Bi-directional communication over WebSockets | websocket | 
| mcp/mcp_elicitation | Using elicitation (interactive prompts) | stdio + elicitation | 
| mcp/mcp_prompts_and_resources | Listing and consuming prompts/resources | stdio | 
| mcp/mcp_roots | Browsing server roots (filesystem-style access) | stdio | 
gen_client, making them ideal templates when wiring new transports or capabilities into your own project.
Configuring MCP servers in mcp-agent
Add MCP servers tomcp_agent.config.yaml. mcp-agent will automatically launch stdio servers, or connect to remote ones via SSE, WebSocket, or streamable HTTP.
mcp_agent.secrets.yaml or environment variables (see Specify Secrets) and mcp-agent will merge them automatically at startup.
Using MCP capabilities from an Agent
Once a server is configured, every attached agent and AugmentedLLM can access its tools, resources, prompts, and roots:- Tools: await agent.call_tool("tool_name", arguments={...})
- Resources: await agent.list_resources()/await agent.read_resource(uri)
- Prompts: await agent.list_prompts()/await agent.get_prompt(name, arguments)
- Roots: await agent.list_roots()for filesystem-style exploration
- Sampling: Some servers expose samplingendpoints; seeexamples/mcp/mcp_sampling
Connecting programmatically (gen_client)
Use gen_client for a lightweight MCP client in Python. The examples above rely on it; here is the minimal template:
"filesystem" for any server defined in your config. For more advanced patterns (persistent connections, aggregators) see Connecting to MCP Servers.
Authentication & security
Many MCP servers require authentication—API tokens, OAuth flows, or custom headers. mcp-agent supports:- Secrets from mcp_agent.secrets.yamlor environment variables
- Header-based tokens for remote transports
- Full OAuth flows (loopback, pre-authorised tokens, Redis-backed token storage)
examples/basic/oauth_basic_agent and examples/oauth.
Additional resources
- Official MCP documentation
- FastMCP docs for implementation details
- mcp-agent MCP examples for runnable code
