MCP Integration (Model Context Protocol)
AgentiPy integrates with the Model Context Protocol (MCP) to standardize how AI agents interact with blockchain functionalities. MCP provides a structured way for AI models, like large language models (LLMs), to discover and utilize available tools, including those for on-chain actions.
What is MCP in AgentiPy?
In the context of AgentiPy, MCP serves as an interface that exposes various blockchain operations (like checking balances, transferring tokens, or interacting with DeFi protocols) as "tools" that AI agents can use. This allows developers to build AI-driven applications where the AI can understand a user's intent and then select and execute the appropriate blockchain actions through AgentiPy's MCP-enabled tools.
AgentiPy's MCP Features
AgentiPy offers robust MCP integration through the following:
Built-in MCP Module
AgentiPy includes a built-in MCP module (agentipy/mcp
) that allows you to easily expose on-chain actions. This module defines various actions related to core Solana operations, as well as integrations with protocols like Allora and Jupiter.
ALL_ACTIONS
: A dictionary that aggregates all available MCP actions from different modules.# agentipy/mcp/all_actions.py from agentipy.mcp.allora import ALLORA_ACTIONS from agentipy.mcp.core import SOLANA_ACTIONS from agentipy.mcp.jupiter import JUPITER_ACTIONS ALL_ACTIONS = { **SOLANA_ACTIONS, **ALLORA_ACTIONS, **JUPITER_ACTIONS, }
Core Solana Actions: Includes functionalities like
GET_BALANCE
,TRANSFER
, andDEPLOY_TOKEN
.Allora Actions: Provides tools for interacting with the Allora protocol, such as
GET_ALL_TOPICS
andGET_PRICE_PREDICTION
.Jupiter Actions: Offers actions for Jupiter exchange, like
STAKE_WITH_JUP
andTRADE_WITH_JUP
.
MCP Server
AgentiPy provides an MCP server (agentipy/mcp/mcp_server.py
) that can be run to expose these tools over a network interface. This server automatically registers the tools defined in ALL_ACTIONS
.
# agentipy/mcp/mcp_server.py
from mcp.server.fastmcp import FastMCP, Context
from mcp.types import Tool, TextContent
from agentipy.agent import SolanaAgentKit
from agentipy.mcp.all_actions import ALL_ACTIONS
# Initialize server with Solana tools
mcp = FastMCP(
"agentipy-mcp",
instructions="Solana tools: Get balance, transfer SOL, price prediction, etc.",
dependencies=["pydantic", "httpx", "solana"],
)
# ... server setup and run functions ...
You can start this server with your SolanaAgentKit
instance:
from agentipy.agent import SolanaAgentKit
from agentipy.mcp.mcp_server import start_mcp_server
# Ensure your SolanaAgentKit is initialized
# PRIVATE_KEY = "YOUR_SECURE_PRIVATE_KEY"
# RPC_URL = "YOUR_SOLANA_RPC_URL"
# agent = SolanaAgentKit(private_key=PRIVATE_KEY, rpc_url=RPC_URL)
# start_mcp_server(agent) # This would start the server
(Note: The above server start is commented out for documentation purposes.)
Agentipy MCP Server for Claude Desktop
For users of Claude AI, especially with Claude Desktop, AgentiPy offers a dedicated MCP server: Agentipy MCP Server for Claude Desktop.
This server is specifically designed to integrate with Claude Desktop, allowing Claude to leverage AgentiPy's blockchain tools through the MCP interface.
Example Claude Desktop Configuration:
// Claude Desktop Configuration
{
"mcpServers": {
"agentipy": {
"command": "./run_mcp.sh", // Script to run the AgentiPy MCP server
"autoApprove": ["GET_BALANCE", "PRICE_PREDICTION"] // Actions that can be auto-approved
}
}
}
This integration enables Claude to perform a variety of on-chain tasks, including:
Checking wallet balances
Executing cross-chain swaps (e.g., via deBridge)
Fetching real-time price feeds (e.g., from Pyth Network)
Accessing market analytics (e.g., from CoinGecko)
Performing AI-driven trading operations
By using MCP, AgentiPy makes complex blockchain interactions accessible to AI agents in a standardized and developer-friendly manner.