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.Example-driven overview
The quickest way to learn is to run the projects inexamples/mcp:
| Example | Focus | Transport |
|---|---|---|
mcp_streamable_http | Connect to a remote HTTP MCP server with streaming responses | streamable_http |
mcp_sse | Subscribe to an SSE MCP server | sse |
mcp_websockets | Bi-directional WebSocket communication | websocket |
mcp_prompts_and_resources | List and consume prompts/resources | stdio |
mcp_roots | Browse server roots (filesystem access) | stdio |
mcp_elicitation | Handle elicitation (interactive prompts) | stdio |
gen_client.
Configuring servers
Add servers tomcp_agent.config.yaml:
mcp_agent.secrets.yaml, environment variables, or preload settings (see Specify Secrets).
Using MCP capabilities from an agent
await agent.call_tool("tool_name", arguments={...})await agent.read_resource(uri)await agent.get_prompt(name, arguments)await agent.list_roots()
Lightweight MCP client (gen_client)
Authentication
- Static headers/API keys go in
headersand pull values from secrets or env variables. - OAuth flows (loopback, interactive tool flow, pre-authorised tokens) are fully supported; see Server Authentication.
- Examples under
examples/basic/oauth_basic_agentandexamples/oauthdemonstrate each pattern.
Related documentation
Detailed reference
Transport configurations
STDIO (Standard Input/Output)
STDIO (Standard Input/Output)
Best for local subprocess servers:
Server-Sent Events (SSE)
Server-Sent Events (SSE)
Ideal for streaming responses and near-real-time updates:
WebSocket
WebSocket
Bi-directional, persistent connections:
Streamable HTTP
Streamable HTTP
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
| Primitive | STDIO | SSE | WebSocket | HTTP | Status |
|---|---|---|---|---|---|
| Tools | ✅ | ✅ | ✅ | ✅ | Fully supported |
| Resources | ✅ | ✅ | ✅ | ✅ | Fully supported |
| Prompts | ✅ | ✅ | ✅ | ✅ | Fully supported |
| Roots | ✅ | ✅ | ✅ | ✅ | Fully supported |
| Elicitation | ✅ | ✅ | ✅ | ✅ | Fully supported |
| Sampling | ✅ | ✅ | ✅ | ✅ | Supported via examples |
Example gallery
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
