Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add CSV MCP agent builders #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 19, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions csv_mcp/agents.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
from __future__ import annotations

from typing import Optional

from agents import Agent


def build_analysis_agent(model_name: str = "o3") -> Agent:
"""Return an agent that analyzes CSV data."""
return Agent(
name="analysis_agent",
instructions="Analyze the provided CSV data for insights and anomalies.",
model=model_name,
)


def build_transform_agent(model_name: str = "o3") -> Agent:
"""Return an agent that transforms CSV data."""
return Agent(
name="transform_agent",
instructions="Transform raw CSV data into a normalized format.",
model=model_name,
)


def build_qna_agent(primary: str = "gpt-4.1", fallbacks: Optional[list[str]] = None) -> Agent:
"""Return a question answering agent for the CSV data."""
_ = fallbacks # Placeholder for future fallback support.
return Agent(
name="qna_agent",
instructions="Answer questions about the CSV data.",
model=primary,
)


def build_aggregator_agent(model_name: str = "gpt-4.1") -> Agent:
"""Return an agent that aggregates outputs from other agents."""
return Agent(
name="aggregator_agent",
instructions="Aggregate analysis and transformations into a single output.",
model=model_name,
)


def build_coordinator(
analysis: Agent,
transform: Agent,
qna: Agent,
aggregator: Agent,
) -> Agent:
"""Return a coordinator agent that delegates tasks to sub agents."""
return Agent(
name="coordinator_agent",
instructions=(
"Route the request to the appropriate sub agent. Use analysis for CSV"
" review, transform for data conversion, qna for answering questions,"
" and aggregator to combine results."
),
handoffs=[analysis, transform, qna, aggregator],
)