mcpField
A
agno

agno

github.com/agno-agiエージェントワークフロー26387 回インストール36 週間前に更新
リポジトリ

agno について

Agno Skillは、単一のAIエージェントからチームやワークフローまで、Agnoで構築する開発者向けのガイドです。ツール、メモリ、永続化、MCPサーバー連携を扱います。

主な機能

  1. 01ツール付きエージェントの設定
  2. 02マルチエージェントチームの構築
  3. 03ワークフロー手順の編成
  4. 04セッション永続化とメモリの追加
  5. 05複数のMCPサーバーとの連携

活用シーン

  1. 01構造化出力を使うエージェントの構築
  2. 02役割に基づくタスク委任
  3. 03エージェントAPIのデプロイ
  4. 04stdio、SSE、HTTPのMCPサーバーへの接続

MCP 対応

stdio、SSE、Streamable HTTPを介したMCPサーバー連携を説明し、MCPToolsとMultiMCPToolsの使い方を示します。エージェントにMCPツールを渡す例も含みます。

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/agno-agi/agno-skills --skill agno

インストール後、Claude Code で/agnoを入力して読み込まれたか確認します。

同梱ファイル

SKILL.md と一緒にインストールされる参考資料やスクリプト。

references/
agents.md
learning.md
mcp.md
models.md
teams.md
tools.md
workflows.md

詳細

Agno スキル

Agno で本番環境に対応した AI エージェントを構築しましょう。Agno は、エージェント、チーム、ワークフロー、MCP 統合のための軽量でモデルに依存しないフレームワークです。

このスキルを使用する場面

このスキルは、次のような場合に起動する必要があります:

  • ツール、メモリ、構造化出力、ナレッジを備えた AI エージェントを構築する場合
  • 役割ベースの委任を伴うマルチエージェントチームを作成する場合
  • 逐次、並列、条件分岐、ルーティングの各ステップを含むワークフローを実装する場合
  • MCP サーバー(stdio、SSE、または Streamable HTTP)を統合する場合
  • AgentOS(FastAPI ベースのランタイム)でエージェントをデプロイする場合
  • LearningMachine(ユーザープロファイル、エンティティメモリ、セッションコンテキスト)を扱う場合
  • エージェントの動作をデバッグしたり、パフォーマンスを最適化したりする場合

アーキテクチャの概要

Agent          - Single autonomous AI unit (model + tools + instructions)
Team           - Multiple agents coordinated by a leader (route/broadcast/tasks modes)
Workflow       - Pipeline-based execution (Step, Parallel, Condition, Loop, Router)
AgentOS        - FastAPI runtime for deploying agents as production APIs
LearningMachine - Persistent learning across sessions (profiles, memory, knowledge)

クイックリファレンス

1. ツールを備えた基本的なエージェント
from agno.agent import Agent
from agno.models.google import Gemini
from agno.tools.yfinance import YFinanceTools

agent = Agent(
    name="Finance Agent",
    model=Gemini(id="gemini-3-flash-preview"),
    tools=[YFinanceTools()],
    add_datetime_to_context=True,
    markdown=True,
)

agent.print_response("Give me a quick brief on NVIDIA", stream=True)
2. Pydantic による構造化出力
from typing import List, Optional
from agno.agent import Agent
from agno.models.google import Gemini
from agno.tools.yfinance import YFinanceTools
from pydantic import BaseModel, Field

class StockAnalysis(BaseModel):
    ticker: str = Field(..., description="Stock ticker symbol")
    company_name: str = Field(..., description="Full company name")
    current_price: float = Field(..., description="Current price in USD")
    summary: str = Field(..., description="One-line summary")
    key_drivers: List[str] = Field(..., description="2-3 key growth drivers")
    recommendation: str = Field(..., description="Buy, Hold, or Sell")

agent = Agent(
    model=Gemini(id="gemini-3-flash-preview"),
    tools=[YFinanceTools()],
    output_schema=StockAnalysis,
)

response = agent.run("Analyze NVIDIA")
analysis: StockAnalysis = response.content
print(f"{analysis.company_name}: {analysis.recommendation}")
3. ストレージを備えたエージェント(セッションの永続化)
from agno.agent import Agent
from agno.db.sqlite import SqliteDb
from agno.models.google import Gemini

agent = Agent(
    model=Gemini(id="gemini-3-flash-preview"),
    db=SqliteDb(db_file="tmp/agents.db"),
    add_history_to_context=True,
    num_history_runs=5,
    markdown=True,
)

# Same session_id = continuous conversation across runs
agent.print_response("Analyze NVDA", session_id="my-session", stream=True)
agent.print_response("Compare that to Tesla", session_id="my-session", stream=True)
4. メモリを備えたエージェント(ユーザー設定)
from agno.agent import Agent
from agno.db.sqlite import SqliteDb
from agno.memory import MemoryManager
from agno.models.google import Gemini

db = SqliteDb(db_file="tmp/agents.db")

agent = Agent(
    model=Gemini(id="gemini-3-flash-preview"),
    db=db,
    memory_manager=MemoryManager(
        model=Gemini(id="gemini-3-flash-preview"),
        db=db,
    ),
    enable_agentic_memory=True,  # Agent decides when to store/recall
    markdown=True,
)

# Agent remembers user preferences across sessions
agent.print_response(
    "I'm interested in AI stocks. My risk tolerance is moderate.",
    user_id="[email protected]",
    stream=True,
)
5. マルチエージェントチーム
from agno.agent import Agent
from agno.models.google import Gemini
from agno.team.team import Team
from agno.tools.yfinance import YFinanceTools

bull = Agent(
    name="Bull Analyst",
    role="Make the investment case FOR a stock",
    model=Gemini(id="gemini-3-flash-preview"),
    tools=[YFinanceTools()],
)

bear = Agent(
    name="Bear Analyst",
    role="Make the investment case AGAINST a stock",
    model=Gemini(id="gemini-3-flash-preview"),
    tools=[YFinanceTools()],
)

team = Team(
    name="Investment Research",
    model=Gemini(id="gemini-3-flash-preview"),
    members=[bull, bear],
    instructions=["Get both perspectives, then synthesize a balanced recommendation"],
    show_members_responses=True,
    markdown=True,
)

team.print_response("Should I invest in NVIDIA?", stream=True)
6. 逐次ワークフロー
from agno.agent import Agent
from agno.models.google import Gemini
from agno.tools.yfinance import YFinanceTools
from agno.workflow import Step, Workflow

data_agent = Agent(name="Data Gatherer", model=Gemini(id="gemini-3-flash-preview"), tools=[YFinanceTools()])
analyst = Agent(name="Analyst", model=Gemini(id="gemini-3-flash-preview"))
writer = Agent(name="Report Writer", model=Gemini(id="gemini-3-flash-preview"), markdown=True)

workflow = Workflow(
    name="Research Pipeline",
    steps=[
        Step(name="Gather Data", agent=data_agent),
        Step(name="Analyze", agent=analyst),
        Step(name="Write Report", agent=writer),
    ],
)

workflow.print_response("Analyze NVIDIA for investment", stream=True)
7. MCP サーバー統合(stdio)
import asyncio
from agno.agent import Agent
from agno.models.anthropic import Claude
from agno.tools.mcp import MCPTools

async def run_agent(message: str) -> None:
    async with MCPTools(command="uvx mcp-server-git") as mcp_tools:
        agent = Agent(model=Claude(id="claude-sonnet-4-5-20250929"), tools=[mcp_tools])
        await agent.aprint_response(message, stream=True)

asyncio.run(run_agent("What is the license for this project?"))
8. MCP サーバー(Streamable HTTP)
import asyncio
from agno.agent import Agent
from agno.models.anthropic import Claude
from agno.tools.mcp import MCPTools

async def run_agent(message: str) -> None:
    async with MCPTools(
        transport="streamable-http",
        url="https://docs.agno.com/mcp",
    ) as mcp_tools:
        agent = Agent(model=Claude(id="claude-sonnet-4-5-20250929"), tools=[mcp_tools], markdown=True)
        await agent.aprint_response(message, stream=True)

asyncio.run(run_agent("What is Agno?"))
9. 複数の MCP サーバー
import asyncio
from os import getenv
from agno.agent import Agent
from agno.tools.mcp import MultiMCPTools

async def run_agent(message: str) -> None:
    mcp_tools = MultiMCPTools(
        commands=["npx -y @openbnb/mcp-server-airbnb --ignore-robots-txt"],
        urls=["http://localhost:8000/mcp"],
        urls_transports=["streamable-http"],
        timeout_seconds=30,
    )
    await mcp_tools.connect()
    agent = Agent(tools=[mcp_tools], markdown=True)
    await agent.aprint_response(message, stream=True)
    await mcp_tools.close()

asyncio.run(run_agent("Find listings in Barcelona"))
10. LearningMachine(永続的な学習)
from agno.agent import Agent
from agno.db.postgres import PostgresDb
from agno.learn import LearningMachine, LearningMode, UserProfileConfig
from agno.models.openai import OpenAIResponses

db = PostgresDb(db_url="postgresql+psycopg://ai:ai@localhost:5532/ai")

agent = Agent(
    model=OpenAIResponses(id="gpt-5.2"),
    db=db,
    learning=LearningMachine(
        user_profile=UserProfileConfig(mode=LearningMode.ALWAYS),
    ),
    markdown=True,
)

agent.print_response("Hi! I'm Alice, call me Ali.", user_id="[email protected]", stream=True)
# Profile fields (name, preferred_name) captured automatically

主要なパターン

パターン: MCP 接続のライフサイクル

MCP 接続は必ずクローズしてください。非同期コンテキストマネージャーまたは try/finally を使用します:

# Preferred: context manager
async with MCPTools(command="uvx mcp-server-git") as tools:
    agent = Agent(tools=[tools])
    await agent.aprint_response("query")

# Alternative: manual lifecycle
tools = MCPTools(command="uvx mcp-server-git")
await tools.connect()
try:
    agent = Agent(tools=[tools])
    await agent.aprint_response("query")
finally:
    await tools.close()
パターン: 本番環境向けデータベース(PostgreSQL)
from agno.db.postgres import PostgresDb
db = PostgresDb(db_url="postgresql+psycopg://user:pass@localhost:5432/agno")
agent = Agent(db=db, add_history_to_context=True)
パターン: デバッグモード
agent = Agent(debug_mode=True)  # Detailed logs of messages, tools, tokens
パターン: カスタムツール
from agno.tools.decorator import tool

@tool
def get_weather(city: str) -> str:
    """Get current weather for a city."""
    return f"Weather in {city}: 72F, sunny"

agent = Agent(tools=[get_weather])

重要なルール

  • ループ内でエージェントを作成しないでください - パフォーマンスのためにエージェントを再利用します
  • output_schema を使用してください - 構造化レスポンスの場合(自由形式のパースではなく)
  • 本番環境には PostgreSQL、SQLite は開発時のみ
  • 同期と非同期の両方 - すべての公開メソッドには非同期版があります(a を先頭に付けます)
  • MCP 接続は必ずクローズしてください - try/finally または非同期コンテキストマネージャーを使用します
  • トラブルシューティング時は debug_mode=True を有効にしてください

リファレンスファイル

詳細なドキュメントは references/ で参照できます:

  • agents.md - エージェントのパラメーター、設定、ツール、メモリ、ナレッジ、ガードレール
  • teams.md - チームモード(route/broadcast/tasks)、メンバーの連携
  • workflows.md - ステップの種類(Step、Parallel、Condition、Loop、Router)
  • mcp.md - MCP 統合(stdio、SSE、Streamable HTTP)、MultiMCPTools
  • tools.md - 組み込みツールの一覧、カスタムツールの作成、ツールフック
  • learning.md - LearningMachine ストア(profile、memory、session、knowledge、entity)
  • models.md - サポートされているモデルプロバイダーと設定

リソース

コメント