Custom-Mcp-with-Agno

Ashrokss/Custom-Mcp-with-Agno

3.2

If you are the rightful owner of Custom-Mcp-with-Agno and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.

This repository demonstrates how to build a custom Model Context Protocol (MCP) server and client using the Agno agent framework.

Custom‑MCP with Agno

This repository demonstrates how to build a custom Model Context Protocol (MCP) server and client using the Agno agent framework. It features:

  • βœ… A working MCP server (custom tool implementations)
  • βœ… A Python MCP client powered by Agno / agno.tools
  • βœ… Example agent workflows, handling tool calls and async management
  • βœ… Clean sample architecture with minimal dependencies

πŸ“˜ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”           β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”           β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ MCP Server   β”‚<β€”β†’ SSE / HTTP β€”β€Ίβ”‚ Agno Agent  β”‚<β€” Tool Calls β€”β€Ίβ”‚ Tools / LLM    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜           β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜           β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
  1. MCP server (mcp_server.py): serves tool endpoints, e.g. web search.
  2. Client (mcp_client.py): agent-side runner using agno.tools.MCPTools
  3. Agent logic: handles queries, invokes tools, and processes results.

Features

  • Asynchronous context management via anyio and async with MCPTools(...).
  • Agent retries and error handling (including handling β€œno space left on device” issues).
  • Template for adding new tools or extending MCP interface.
  • Example agent running loop included in mcp_client.py.

πŸ“ Code Structure

FileDescription
mcp_server.pyPython MCP server with sample tool implementations
mcp_client.pyAgent client to issue queries and handle agent response
requirements.txtPython dependencies: agno, anyio, etc.
.venv/(Optional) Virtual environment directory
config/configEnvironment Variables such as SERPER_API_KEY & GROQ_API_KEY

πŸ”‘ Set Up Configuration

In config.py, define:

class Config:
    GROQ_API_KEY = "<your_groq_api_key>"
    SERPER_API_KEY = "<your_serper_api_key>"