Agno Integration

async agentstr.mcp.agno.to_agno_tools(nostr_mcp_client: NostrMCPClient) list[Function][source]

Convert tools from the MCP client to Agno tools.

Parameters:

nostr_mcp_client – An instance of NostrMCPClient to fetch tools from.

Returns:

A list of Agno Function objects that wrap the MCP tools.

This module provides integration with Agno tools, allowing conversion between MCP tools and Agno’s function format.

Usage Example

 1from dotenv import load_dotenv
 2
 3load_dotenv()
 4
 5import os
 6
 7from agno.agent import Agent
 8from agno.models.openai import OpenAIChat
 9
10from agentstr import ChatInput, NostrAgentServer, NostrMCPClient
11from agentstr.mcp.agno import to_agno_tools
12
13# Create Nostr MCP client
14nostr_mcp_client = NostrMCPClient(relays=os.getenv("NOSTR_RELAYS").split(","),
15                                  private_key=os.getenv("EXAMPLE_AGNO_AGENT_NSEC"),
16                                  mcp_pubkey=os.getenv("EXAMPLE_MCP_SERVER_PUBKEY"),
17                                  nwc_str=os.getenv("MCP_CLIENT_NWC_CONN_STR"))
18
19async def agent_server():
20    # Define tools
21    agno_tools = await to_agno_tools(nostr_mcp_client)
22
23    for tool in agno_tools:
24        print(f'Found {tool.name}: {tool.description}')
25
26    # Define Agno agent
27    agent = Agent(
28        model=OpenAIChat(
29            temperature=0,
30            base_url=os.getenv("LLM_BASE_URL"),
31            api_key=os.getenv("LLM_API_KEY"),
32            id=os.getenv("LLM_MODEL_NAME"),
33        ),
34        tools=agno_tools,
35    )
36
37    # Define agent callable
38    async def agent_callable(input: ChatInput) -> str:
39        result = await agent.arun(message=input.messages[-1], session_id=input.thread_id)
40        return result.content
41
42    # Create Nostr Agent Server
43    server = NostrAgentServer(nostr_mcp_client=nostr_mcp_client,
44                              agent_callable=agent_callable)
45
46    # Start server
47    await server.start()
48
49
50if __name__ == "__main__":
51    import asyncio
52    asyncio.run(agent_server())