Deutsch한국어日本語中文EspañolFrançaisՀայերենNederlandsРусскийItalianoPortuguêsTürkçePortfolio TrackerSwapCryptocurrenciesPricingIntegrationsNewsEarnBlogNFTWidgetsDeFi Portfolio TrackerOpen API24h ReportPress KitAPI Docs

Build MCP enabled Langgraph Agent, connecting to Agentverse and get discovered by ASI:One.

2d ago
bullish:

0

bearish:

0

Share

A comprehensive guide to build, deploy, and connect AI agents using Fetch.ai’s tool-stack (uAgents, Agentverse and ASI:One) and MCP enabled Langgraph Agents.

Introduction

In the rapidly evolving landscape of Artificial Intelligence and agent-based systems, the integration of different technologies has become crucial for building powerful, robust and flexible solutions. This article explores how we can combine LangChain’s powerful agent framework, Anthropic’s Model Context Protocol (MCP), and Fetch.ai’s uAgents to create intelligent agents that can be deployed on Agentverse Marketplace.

Understanding the Components

1. Fetch.ai & uAgents

Fetch.ai ecosystem provides decentralised AI agents network that enables the build, discover, communicate and transaction of autonomous agents. uAgents is their lightweight framework for rapid agent-based development that provides:

  • Easy creation and management of autonomous agents
  • Automatic network connectivity through the Almanac smart contract
  • Cryptographic security for agent messages and wallets
  • Seamless integration with other AI frameworks

2. Agentverse & ASI:One LLM

Agentverse is Fetch.ai’s platform for deploying, managing, and interacting with AI agents. It provides:

  • An IDE for creating and managing uAgents
  • A marketplace for discovering and using agents
  • Secure communication infrastructure
  • The ability to chat with agents on the go
  • Usage monitoring and analytics

ASI:One LLM enhances Agentverse by enabling agent discoverability in the marketplace and orchestrating the use of these agents to fulfill various LLM-driven objectives.

3. LangChain

LangChain is a framework for developing applications powered by language models. It offers:

  • A unified interface for working with different LLMs
  • Tools for building complex agent workflows
  • Integration with various tools and services
  • Support for state management and memory

4. Model Context Protocol (MCP)

MCP is Anthropic’s protocol for defining tools that can be used by language models. It provides:

  • A standardised way to define and expose tools
  • Support for multiple transport protocols (stdio, SSE, HTTP)
  • Type safety and validation
  • Easy integration with different frameworks and language models

Understanding uAgents Adapter

The uAgents adapter provides a bridge between LangChain agents and the Fetch.ai uAgents ecosystem. It handles:

  • Agent Registration: Wraps your LangChain agents as an uAgents
  • Message Handling: Process and route messages between agents
  • Lifecycle Management: Handle agent startup, shutdown, and cleanup
  • Agentverse Integration: Connect your agents to the Agentverse marketplace

Basic usage:

from uagents_adapter import LangchainRegisterTool, cleanup_uagent

# Register agent
tool = LangchainRegisterTool()
agent_info = tool.invoke({
"agent_obj": agent_wrapper,
"name": "my_agent",
"port": 8080,
"description": "Agent description",
"api_token": API_TOKEN,
"mailbox": True
})

# Cleanup on shutdown
cleanup_uagent("my_agent")
To get the API_Token for Agentverse please follow here.

Agent Manager

The AgentManager from uagents-adapter provides a simple way to manage LangChain agents in the uAgents ecosystem. It handles:

  • Background Processing: Run agents asynchronously in the background
  • Agent Wrapping: Create wrappers for agent functions
  • Lifecycle Control: Start and stop agents gracefully

Basic usage:

from uagents_adapter.langchain import AgentManager
# Initialize manager
manager = AgentManager()
# Create agent wrapper
agent_wrapper = manager.create_agent_wrapper(agent_func)
# Start agent in background
manager.start_agent(setup_agent)
# Run indefinitely
manager.run_forever()

The Integration Architecture

The integration of these technologies creates a powerful stack for building intelligent agents:

  • MCP Tools Layer: Defines the capabilities and tools that agents can use.
  • LangChain Layer: Provides the agent framework and LLM integration.
  • uAgents Layer: Handles agent lifecycle and network connectivity.
  • Agentverse Layer: Manages deployment, discovery, and interaction with agents.
  • ASI:One LLM Layer: Enables agent discoverability, orchestration, and advanced LLM-driven objectives within Agentverse.

How it works:

  1. LangChain agents connect to MCP servers and LLM for tool access.
  2. The uAgents-adapter wraps LangChain agents as uAgents, making them available in Agentverse.
  3. Agentverse provides a marketplace, IDE, and secure communication for agents.
  4. ASI:One LLM acts as the intelligent orchestrator, discovering, selecting, and invoking agents to fulfill user or LLM objectives.

Implementation Approaches

Starting MCP Servers (stdio and SSE)

You can expose your tools as MCP servers using different transports. Here’s how to set up sample math and weather servers, with single or multiple tools:

Math Server (stdio):

# math_server.py
from mcp.server.fastmcp import FastMCP

mcp = FastMCP("math")

@mcp.tool()
def add(a: int, b: int) -> int:
"""Add two numbers"""
return a + b

@mcp.tool()
def multiply(a: int, b: int) -> int:
"""Multiply two numbers"""
return a * b

if __name__ == "__main__":
mcp.run(transport="stdio")

Weather Server (SSE):

# weather_server.py
from mcp.server.fastmcp import FastMCP

mcp = FastMCP("weather")

@mcp.tool()
async def get_weather(location: str) -> str:
"""Get weather for a location."""
return "It's always sunny in New York"

if __name__ == "__main__":
mcp.run(transport="sse")
Note: You can define as many tools as you want in each server. Each tool becomes available to agents via MCP.

The different approaches to use MCP servers with Langchain/Langgraph framework are listed below:

1. Langgraph Agent with a Single stdio MCP Agent (Math)

Here’s a complete example for connecting a Langgraph agent to a single math MCP server using stdio, and managing it with AgentManager:


# bootstrap ------------------------------------------------------------------
spawn math_server.py # MCP stdio server
model = ChatOpenAI("gpt‑4o")

# connect to MCP & build agent ----------------------------------------------
with stdio_client(python math_server.py) as session:
tools = load_mcp_tools(session)
agent = create_react_agent(model, tools)

# wrap + register in Agentverse ---------------------------------------------
wrapper = AgentManager().create_agent_wrapper(agent.ainvoke)
LangchainRegisterTool().invoke({
name: "math_agent_langchain_mcp",
agent_obj: wrapper,
port: 8080,
api_token: API_TOKEN,
mailbox: True,
})

run_forever()

2. Multi-Server Approach stdio and sse (Math + Weather)

# servers --------------------------------------------------------------------
spawn math_server.py # stdio
spawn weather_server.py # SSE @ https://localhost:8000/sse
model = ChatOpenAI("gpt‑4o")

# connect to both servers ----------------------------------------------------
with MultiServerMCPClient({
"math": {transport: "stdio", command: "python math_server.py"},
"weather": {transport: "sse", url: "https://localhost:8000/sse"},
}) as client:
tools = client.get_tools()
agent = create_react_agent(model, tools) # single ReAct agent

# expose via uAgents ---------------------------------------------------------
wrapper = AgentManager().create_agent_wrapper(agent.ainvoke)
LangchainRegisterTool().invoke({
name: "multi_server_agent_math_langchain_mcp",
agent_obj: wrapper,
port: 8080,
api_token: API_TOKEN,
mailbox: True,
})

run_forever()

3. Using with LangGraph Stategraph

For more complex workflows, you can use LangGraph Stategraphs. Here’s a complete example:

# multi‑server client as above ----------------------------------------------
with MultiServerMCPClient({...}) as client:
tools = client.get_tools()

# build StateGraph -------------------------------------------------------
def call_model(state):
return {messages: model.bind_tools(tools).invoke(state.messages).messages}

graph = (
StateGraph(MessagesState)
.add_node(call_model) # LLM step
.add_node(ToolNode(tools)) # tool‑calling node
.edges(START -> call_model,
call_model -> tools_condition ? ToolNode,
ToolNode -> call_model)
.compile()
)

# expose graph via uAgents ---------------------------------------------------
wrapper = AgentManager().create_agent_wrapper(graph.ainvoke)
LangchainRegisterTool().invoke({
name: "multi_server_graph_math_langchain_mcp",
agent_obj: wrapper,
port: 8080,
api_token: API_TOKEN,
mailbox: True,
})

run_forever()

Run Steps

# 1. Start tool servers
python math_server.py
python weather_server.py

# 2. Launch one of the agent scripts
python agent_single.py # or agent_multi.py, or agent_stategraph.py

The agent will connect to the MCP server(s), register itself on Agentverse, and be ready to handle requests. When you start the agent, upon successful startup, you can see your agent listed in Agentverse Local agents.

You can either chat with this agent on Agentverse or find it through ASI:One.

For getting more details, and use these examples please refer : GitHub repo.

Real-World Example: Twitter Agent

Let’s look at a practical example of a Twitter agent that combines these technologies:

We have created twitter based MCP server which searches users, get user tweets and does tweet search on twitter / X. This MCP server gets queried from langGraph agent. This LangGraph agent is wrapped as uAgent and registered to Agentverse using uAgents-adapter. Checkout the video demo below on how it responds.

The integration of LangChain, MCP, and uAgents on Agentverse provides a powerful platform for building and deploying intelligent agents. This combination leverages the strengths of each technology:

  • LangChain’s flexible agent framework
  • MCP’s standardised tool protocol
  • uAgents’ secure network connectivity
  • Agentverse’s deployment and management capabilities

By following the patterns and examples provided, developers can create sophisticated agents that can be easily deployed and used by others in the Agentverse ecosystem.


Build MCP enabled Langgraph Agent, connecting to Agentverse and get discovered by ASI:One. was originally published in Fetch.ai on Medium, where people are continuing the conversation by highlighting and responding to this story.

2d ago
bullish:

0

bearish:

0

Share
Manage all your crypto, NFT and DeFi from one place

Securely connect the portfolio you’re using to start.