Skip to main content

A Financial Analysis Team

This demo shows how to integrate external MCP (Model Context Protocol) servers to create a specialized financial research team.

Configurationโ€‹

Create a file named finance.yaml:

agents:
root:
model: openai/gpt-4o
description: Financial research and analysis coordinator
sub_agents: [finance_agent, web_search_agent]

finance_agent:
model: openai/gpt-4o
description: Analyze given stock
toolsets:
- type: mcp
command: uvx
args: ["yfmcp"] # Yahoo Finance MCP server

web_search_agent:
model: openai/gpt-4o
description: Search web for information
toolsets:
- type: mcp
command: uvx
args: ["duckduckgo-mcp-server"]

Prerequisitesโ€‹

  1. Install uv (Python package manager):
curl -LsSf https://astral.sh/uv/install.sh | sh
  1. Set API key:
export OPENAI_API_KEY=your_openai_key

Running the Agentโ€‹

./bin/cagent run finance.yaml

MCP Server Integrationโ€‹

MCP (Model Context Protocol) servers extend agent capabilities with external tools:

MCP ServerPurpose
yfmcpYahoo Finance data - stock prices, financials, history
duckduckgo-mcp-serverWeb search for news and information

MCP Toolset Configurationโ€‹

toolsets:
- type: mcp
command: uvx # Command to run the MCP server
args: ["yfmcp"] # Arguments passed to the command

Agent Workflowโ€‹

User Query: "Analyze Tesla stock"
โ†“
Root Agent (Coordinator)
โ†“
โ”Œโ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”
โ†“ โ†“
Web Search Finance Agent
(News) (Stock Data)
โ†“ โ†“
โ””โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”˜
โ†“
Combined Analysis

Example Interactionโ€‹

> What's the current state of Tesla stock and recent news?

--- Agent: root ---

I'll gather comprehensive information for you.

[Delegating to web_search_agent for news]
[Delegating to finance_agent for stock data]

--- Agent: web_search_agent ---

[Searching DuckDuckGo for Tesla news...]

Recent headlines:
- Tesla Q3 deliveries exceed expectations
- New Gigafactory expansion announced
- FSD v12 rolling out to more users

--- Agent: finance_agent ---

[Fetching Yahoo Finance data...]

TSLA Current Price: $248.50
52-Week Range: $152.37 - $299.29
Market Cap: $790B
P/E Ratio: 62.4

--- Agent: root ---

Based on the analysis:
- Tesla stock is trading at $248.50, well within its 52-week range
- Recent positive news about deliveries and FSD could support momentum
- The P/E ratio suggests growth expectations remain high

Key Takeawaysโ€‹

  • MCP servers provide specialized capabilities (finance, search, databases, etc.)
  • Tools run in isolated containers for security
  • Coordinator agents combine insights from multiple specialized agents
  • This pattern works for any domain requiring external data sources