What is an Agent?
In themcp-agent
framework, an Agent is your primary interface for building intelligent applications. An agent combines a Large Language Model (LLM) with specialized capabilities, allowing it to use tools, access data, and interact with external systems to accomplish tasks.
Think of an agent as an intelligent assistant that can:
- Understand natural language requests
- Make decisions about which tools to use
- Execute complex multi-step workflows
- Maintain conversation history and context
- Request human input when needed
Core Concept: An Agent is a configured LLM enhanced with tools, memory,
and the ability to take actions in your environment.
Agent Components
An agent inmcp-agent
consists of several key components working together:
- Agent Core: Manages the overall workflow and orchestrates interactions
- LLM Integration: Connects to various language model providers (OpenAI, Anthropic, etc.)
- Tool Access: Provides the LLM with capabilities through MCP servers
- Memory System: Maintains conversation history and context
- Human Input: Allows for interactive workflows requiring user input
Creating Your First Agent
The simplest way to create an agent is through theAgent
class. Here’s a basic example:
Tool Integration
Agents automatically discover and use tools from connected MCP servers,
giving your LLM powerful capabilities.
Multi-Provider Support
Switch between different LLM providers (OpenAI, Anthropic, etc.) without
changing your agent logic.
Agent Configuration
Agents can be configured either programmatically or through configuration files. The framework supports both approaches:Configuration File Approach
Create amcp_agent.config.yaml
file to define your agent’s environment:
Programmatic Configuration
You can also configure agents directly in code:Agent Capabilities
Agents inmcp-agent
come with several powerful built-in capabilities:
Multi-LLM Provider Support
Switch between different LLM providers seamlessly:Advanced Model Selection
Control model selection with preferences:Human Input Integration
Agents can request human input during execution:Memory and Context Management
Agents maintain conversation history automatically:Agent Lifecycle Management
Agents follow a predictable lifecycle:1. Initialization
When you create an agent, it:- Loads configuration from files or code
- Connects to specified MCP servers
- Discovers available tools and capabilities
2. Usage
During operation, the agent:- Processes user requests through the LLM
- Orchestrates tool calls as needed
- Maintains conversation history
- Handles errors and retries
3. Cleanup
When finished, the agent:- Closes connections to MCP servers
- Releases resources
- Saves any persistent state
Common Usage Patterns
Application Integration
Use theMCPApp
class for full application setup: