Agents build on the MCP Tools specification—each agent is automatically exposed as an
invoke_<agent-id> tool that any MCP client can call.Why Agents?
In the Model Context Protocol, agents serve a distinct purpose from tools, resources, and prompts:| Aspect | Agent | Tool | Resource | Prompt |
|---|---|---|---|---|
| Purpose | Autonomous AI execution | Execute actions | Provide data | Provide templated instructions |
| Has LLM | Yes (own LLM provider) | No | No | No |
| Direction | Model or user triggers execution | Model triggers execution | Model pulls data | Model uses messages |
| Side effects | Yes (LLM calls, tool execution) | Yes (mutations, API calls) | No (read-only) | No (message generation) |
| Use case | Complex reasoning, multi-step tasks | Actions, integrations | Context loading | Conversation templates |
- Complex reasoning — tasks requiring multiple LLM calls and tool use
- Specialized expertise — domain-specific agents (research, writing, coding)
- Orchestration — coordinating multiple sub-agents for complex workflows
- Isolation — agents with their own tools, resources, and providers
Creating Agents
Class Style (Default Behavior)
The simplest agent requires noexecute() method. The default behavior automatically:
- Runs the execution loop with the LLM
- Connects tools and executes them as needed
- Sends notifications on tool calls and output
Class Style (Custom Behavior)
Overrideexecute() only when you need custom pre/post processing:
Function Style
For simpler agents, use the functional builder:Registering Agents
Add agents to your app via theagents array:
invoke_research-agentinvoke_calculator-agentinvoke_writer-agent
Loading from npm or Remote Servers
Mix local agents with those loaded from npm or proxied from remote servers:Agent.esm() and Agent.remote() load individual agents. For loading entire apps, use App.esm() or App.remote().Environment Availability
Restrict when an agent is discoverable and invocable usingavailableWhen:
LLM Configuration
Agents require an LLM configuration. FrontMCP provides native adapters for OpenAI and Anthropic SDKs with built-in retry logic, streaming support, and token tracking.Built-in Providers (Shorthand)
The simplest way to configure an LLM — the SDK auto-creates the appropriate adapter:OpenAI Adapter (Direct)
For full control, useOpenAIAdapter directly. Supports the Chat Completions API (default) and the Responses API:
OpenAI-Compatible Providers
UsebaseUrl to connect to any OpenAI-compatible API (OpenRouter, Azure, Groq, Mistral, etc.):
Anthropic Adapter (Direct)
Custom Adapter
ImplementAgentLlmAdapter for any other provider:
Agent-Scoped Components
Agents can have their own isolated tools, resources, prompts, and providers:Swarm Configuration
Control agent visibility for multi-agent coordination:Visibility Patterns
Orchestrator Pattern — A central agent coordinates specialized workers:Execution Configuration
Control agent execution behavior:Tool Execution Mode
By default, agents execute tools through the fullcall-tool flow, which includes:
- Plugin hooks (caching, rate limiting, audit logging)
- Authorization checks
- Tool middleware and transformations
Overriding Behavior
Customize agent behavior by overriding methods inAgentContext:
Progress Notifications
Keep users informed during long operations using manual or automatic notifications.Manual Notifications
Usethis.notify() to send custom messages at specific points:
this.progress() for progress bars when the client provides a progressToken:
Automatic Progress (Opt-in)
EnableenableAutoProgress to automatically send progress notifications during the agent execution loop:
| Event | Progress % | Message Example |
|---|---|---|
| LLM call start | 0-80% | “Starting LLM call (iteration 1/10)“ |
| LLM response received | varies | ”LLM response received (500P + 200C tokens)“ |
| Tools identified | - | ”Identified 2 tool call(s): search, calculate” |
| Tool execution | varies | ”Executing tool 1/2: search” |
| Completion | 100% | “Agent completed” |
Auto progress requires both
enableAutoProgress: true and enableNotifications: true (the default).
Progress notifications are only sent if the client includes a progressToken in the request’s _meta field.