Skip to main content

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:
Best for local development and subprocess-based servers:
Ideal for streaming responses and real-time data:
For bidirectional, persistent connections:
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:

Primitive Support Matrix

Complete Examples

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