uAgents Adapters: Connecting AI Framework Ecosystems
uAgents Adapters provide a bridge between the uAgents ecosystem and various agentic frameworks, enabling seamless communication between different AI agent architectures.
Why Use Adapters?
Different frameworks and technologies have different strengths:
- LangChain: Powerful for composing LLMs with tools and chains
- LangGraph: Excellent for complex orchestration and stateful workflows
- CrewAI: Specialized for multi-agent collaborative systems
- MCP Server Adapter: Host MCP servers on Agentverse (or locally with mailbox) so ASI:One can discover and use them via the Chat Protocol
The uAgents Adapter package lets you use these specialized frameworks while still benefiting from the uAgents ecosystem for communication, discovery, and deployment.
Prerequisites
Before installing adapters, make sure your environment meets these requirements:
- Python 3.10+ (Python 3.8 and older uAgents releases are not supported for adapters)
uagents>=0.22.3(required byuagents-adapter; older pins such asuagents==0.10.0will fail)
python --version # should report 3.10 or newer
pip install "uagents>=0.22.3"
Installation
Install the base package:
pip install uagents-adapter
Install with specific framework support:
# Install with LangChain support
pip install "uagents-adapter[langchain]"
# Install with CrewAI support
pip install "uagents-adapter[crewai]"
# Install with MCP support
pip install "uagents-adapter[mcp]"
# Install with A2A Inbound support
pip install "uagents-adapter[a2a-inbound]"
# Install with A2A Outbound support
pip install "uagents-adapter[a2a-outbound]"
# Install with all extras
pip install "uagents-adapter[all]"
Available Adapters
The uAgents Adapter package currently supports several major AI frameworks.
These snippets assume you already have:
- An Agentverse API key set as
AGENTVERSE_API_KEY(see Agentverse API Key) - A framework agent/app object you created earlier (
langchain_agent,langgraph_app, ormy_crew)
For complete runnable apps, see the adapter examples.
1. LangChain Adapter
Connect LangChain agents, chains, and tools to the uAgents ecosystem.
Installation:
pip install "uagents-adapter[langchain]"
import os
from uagents_adapter import LangchainRegisterTool
# Assumes `langchain_agent` is your existing LangChain agent/runnable
AGENTVERSE_API_KEY = os.environ["AGENTVERSE_API_KEY"]
# Register a LangChain agent as a uAgent
tool = LangchainRegisterTool()
agent_info = tool.invoke({
"agent_obj": langchain_agent,
"name": "my_langchain_agent",
"port": 8000,
"description": "A LangChain agent powered by GPT-4",
"api_token": AGENTVERSE_API_KEY,
})
2. LangGraph Adapter
Integrate LangGraph's powerful orchestration with uAgents.
Installation:
pip install "uagents-adapter[langchain]"
import os
from uagents_adapter import LangchainRegisterTool
# Assumes `langgraph_app` is your compiled LangGraph app
AGENTVERSE_API_KEY = os.environ["AGENTVERSE_API_KEY"]
# Wrap LangGraph agent function for uAgent integration
def langgraph_agent_func(query):
# Process with LangGraph
result = langgraph_app.invoke(query)
return result
# Register the LangGraph function as a uAgent
tool = LangchainRegisterTool()
agent_info = tool.invoke({
"agent_obj": langgraph_agent_func,
"name": "my_langgraph_agent",
"port": 8080,
"description": "A LangGraph orchestration agent",
"api_token": AGENTVERSE_API_KEY,
})
See the full walkthrough: LangGraph Adapter Example.
3. CrewAI Adapter
Expose CrewAI's collaborative agent teams as uAgents.
Installation:
pip install "uagents-adapter[crewai]"
import os
from uagents_adapter import CrewaiRegisterTool
# Assumes `my_crew` is your existing CrewAI Crew instance
AGENTVERSE_API_KEY = os.environ["AGENTVERSE_API_KEY"]
# Create a function to handle CrewAI operations
def crew_handler(query):
# Process with CrewAI
result = my_crew.kickoff(inputs={"query": query})
return result
# Register the CrewAI function as a uAgent
tool = CrewaiRegisterTool()
agent_info = tool.invoke({
"agent_obj": crew_handler,
"name": "my_crew_agent",
"port": 8081,
"description": "A CrewAI team of specialized agents",
"api_token": AGENTVERSE_API_KEY,
})
See the full walkthrough: CrewAI Adapter Example.
Common Parameters
All adapters accept the following parameters:
| Parameter | Type | Description |
|---|---|---|
agent_obj | object | The framework-specific agent or function to wrap |
name | string | Name for your agent in the uAgents ecosystem |
port | int | Port for the agent's HTTP server |
description | string | Human-readable description of agent capabilities |
api_token | string | Your Agentverse API key for registration |
mailbox | bool | Whether to use Agentverse mailbox for persistence (optional) |
ai_agent_address | string | Optional uAgent address (agent1q...) of an AI agent that converts natural language into a structured query prompt. Leave unset to use the package default (or set AI_AGENT_ADDRESS in the environment). Example: "agent1qtlpfshtlcxekgrfcpmv7m9zpajuwu7d5jfyachvpa4u3dkt6k0uwwp2lct" |
Communication Protocol
Once registered, adapter agents communicate using the uAgents chat protocol. uagents_core is installed with uagents>=0.22.3.
The snippet below assumes you are inside an async uAgent handler where ctx is the Context argument, and adapter_agent_address is the address of the registered adapter agent (an agent1q... string returned at registration or copied from Agentverse).
from datetime import datetime, timezone
from uuid import uuid4
from uagents import Context
from uagents_core.contrib.protocols.chat import (
ChatMessage,
TextContent,
)
# Example: inside `@agent.on_message(...)` or another async handler
async def send_to_adapter(ctx: Context, adapter_agent_address: str) -> None:
message = ChatMessage(
timestamp=datetime.now(timezone.utc),
msg_id=uuid4(),
content=[TextContent(type="text", text="Your query here")],
)
await ctx.send(adapter_agent_address, message)
For a complete chat-protocol walkthrough, see Agent Chat Protocol.
Cleanup and Management
Always clean up your agents when shutting down to ensure proper deregistration.
Pass the same name you used when registering the agent (for example "my_langchain_agent"), not a display label or address.
import time
from uagents_adapter import cleanup_uagent
AGENT_NAME = "my_langchain_agent" # must match the `name` used in tool.invoke(...)
try:
# Your agent code here
while True:
time.sleep(1)
except KeyboardInterrupt:
# Clean up the agent
cleanup_uagent(AGENT_NAME)
print("Agent stopped.")
4. MCP Server Adapter
The MCP Server Adapter lets you host your FastMCP servers directly on Agentverse or run locally with a mailbox, making them discoverable by ASI:One through the Chat Protocol.
Installation:
pip install "uagents-adapter[mcp]"
First, create a FastMCP server implementation in a server.py file that exposes the required list_tools and call_tool async methods. Then, in the following agent.py, import the MCP server instance and use it with the MCPServerAdapter.
MCPServerAdapter needs an ASI:One API key for LLM-powered tool selection.
- Get a key: Getting Started with ASI:One (or Quickstart)
- Prefer an environment variable, e.g.
export ASI_ONE_API_KEY=..., instead of hardcoding - Choose a model based on your workload; start with
asi1, or useasi1-extended/asi1-fastwhen you need deeper reasoning or lower latency
Agentverse-only (direct) deployment
import os
from uagents import Agent
from uagents_adapter import MCPServerAdapter
from server import mcp # FastMCP instance from your server.py
# Create an MCP adapter
mcp_adapter = MCPServerAdapter(
mcp_server=mcp,
asi1_api_key=os.environ["ASI_ONE_API_KEY"],
model="asi1", # Options: asi1, asi1-extended, asi1-fast
)
# Create a direct uAgent for Agentverse
agent = Agent()
# Add the MCP adapter protocols to the agent
for protocol in mcp_adapter.protocols:
agent.include(protocol)
# Run the MCP adapter with the agent
mcp_adapter.run(agent)
See: Create MCP Server on Agentverse Example — how to deploy a FastMCP server as a uAgent using
MCPServerAdapter.
Local agent with mailbox connection
import os
from uagents import Agent
from uagents_adapter import MCPServerAdapter
from server import mcp # FastMCP instance from your server.py
# Create an MCP adapter
mcp_adapter = MCPServerAdapter(
mcp_server=mcp,
asi1_api_key=os.environ["ASI_ONE_API_KEY"],
model="asi1", # Options: asi1, asi1-extended, asi1-fast
)
# Create a local uAgent with mailbox
agent = Agent(
name="alice",
port=8000,
seed="put_your_seed_phrase_here",
mailbox=True,
)
# Add the MCP adapter protocols to the agent
for protocol in mcp_adapter.protocols:
agent.include(protocol)
# Run the MCP adapter with the agent
mcp_adapter.run(agent)
Important: When creating MCP tools, include detailed docstrings using triple quotes (""") describing what each tool does, when it should be used, and what parameters it expects. These descriptions help ASI:One decide when and how to use your tools.
A2A Adapters (Inbound & Outbound)
The A2A adapters bridge Fetch.ai's uAgents with the wider Agent-to-Agent (A2A) protocol ecosystem, letting any Agentverse agent collaborate with A2A agents (and vice-versa) without code changes.
| Adapter | Direction | Typical Use-Case |
|---|---|---|
| Inbound A2A Adapter | A2A → Agentverse | Expose an existing Agentverse agent as a standard A2A endpoint so external A2A clients can discover & invoke it. |
| Outbound A2A Adapter | Agentverse → A2A | Register one or more A2A agents as a single uAgent, so Agentverse workflows & ASI:One can leverage their capabilities. |
Installation:
# Install A2A Inbound adapter
pip install "uagents-adapter[a2a-inbound]"
# Install A2A Outbound adapter
pip install "uagents-adapter[a2a-outbound]"
For full tutorials see:
Next Steps
Pick one path and run a complete example:
- Framework adapters — start with CrewAI Adapter Example or LangGraph Adapter Example
- MCP on Agentverse — follow Create MCP Server on Agentverse
- A2A interoperability — try Inbound A2A or Outbound A2A
Before you run any example, confirm Python 3.10+, uagents>=0.22.3, and the relevant API keys (Agentverse, ASI:One).