MCP Primitives
MCP (Model Context Protocol) primitives are standardized building blocks that enable agents to access structured data and functionality from MCP servers. This guide shows you how to use all MCP primitives: tools, resources, prompts, roots, and elicitation.What are MCP Primitives?
Tools
Functions that interact with external systems, such as querying databases, calling APIs, or performing computations
Resources
Data (files, database schemas, application-specific information) exposed by MCP servers, accessible via URIs
Prompts
Reusable messages and instructions that can be listed and invoked from MCP servers with parameters
Roots
File system paths that MCP servers make accessible for browsing and operations
Elicitation
Interactive input requests that allow servers to ask for structured user input during tool execution
Sampling
Server-side LLM invocation capability for specialized reasoning (coming soon)
Transport Types
mcp-agent supports all MCP transport types:STDIO (Standard Input/Output)
STDIO (Standard Input/Output)
Best for local development and subprocess-based servers:
Server-Sent Events (SSE)
Server-Sent Events (SSE)
Ideal for streaming responses and real-time data:
WebSocket
WebSocket
For bidirectional, persistent connections:
Streamable HTTP
Streamable HTTP
For HTTP-based servers with streaming support:
Creating an MCP Server
First, create an MCP server that exposes resources and prompts:Agent Configuration
Configure your agent to connect to the MCP server:Using MCP Primitives in Your Agent
Here’s how to use MCP primitives in your agent application:Key Methods
Listing Primitives
Using Prompts and Resources
Elicitation Support
Elicitation allows MCP servers to request additional structured input from users during tool execution:Roots Support
Roots define file system paths that MCP servers make accessible:Authentication Support
mcp-agent supports authentication for MCP servers:API Key Authentication
API Key Authentication
Custom Headers
Custom Headers
Primitive Support Matrix
Primitive | STDIO | SSE | WebSocket | HTTP | Status |
---|---|---|---|---|---|
Tools | ✅ | ✅ | ✅ | ✅ | Fully Supported |
Resources | ✅ | ✅ | ✅ | ✅ | Fully Supported |
Prompts | ✅ | ✅ | ✅ | ✅ | Fully Supported |
Roots | ✅ | ✅ | ✅ | ✅ | Fully Supported |
Elicitation | ✅ | ✅ | ✅ | ✅ | Fully Supported |
Sampling | 🚧 | 🚧 | 🚧 | 🚧 | Coming Soon |