# vslsoni/mcp-stock architecture

> Architecture diagram of the GitHub repository vslsoni/mcp-stock, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/vslsoni/mcp-stock
- Repository: https://github.com/vslsoni/mcp-stock

## Overview

This is a command-line stock-query system: a user submits a natural-language request, the client asks Gemini to choose a listed MCP tool, and an MCP server executes the stock lookup or comparison and returns text. The server uses Yahoo Finance in the sampled code; the README also describes local CSV fallback, though that behavior is not present in the server excerpt, so the fallback link is shown as unverified. The graph preserves both documented tools and the main client/server stages.

Main entry points: [`mcp_client.py`](https://github.com/vslsoni/mcp-stock/blob/main/mcp_client.py) (MCP session), [`mcp_server.py`](https://github.com/vslsoni/mcp-stock/blob/main/mcp_server.py) (MCP tool server), [`stocks_data.csv`](https://github.com/vslsoni/mcp-stock/blob/main/stocks_data.csv) (Fallback stock data)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Query client"]
  node_cli["Interactive CLI<br/>[mcp_client.py]"]
  node_gemini["Gemini tool selection<br/>[mcp_client.py]"]
  node_mcp_session["MCP session<br/>[mcp_client.py]"]
end

subgraph group_service["MCP stock service"]
  node_server["MCP tool server<br/>[mcp_server.py]"]
  node_single_price["Single price tool<br/>[mcp_server.py]"]
  node_comparison["Price comparison tool<br/>[mcp_server.py]"]
end

subgraph group_data["Market data"]
  node_yahoo["Yahoo Finance"]
  node_csv[("Fallback stock data<br/>[stocks_data.csv]")]
end

node_user(("Querying user"))

node_user -->|"submits query"| node_cli
node_cli -->|"starts session"| node_mcp_session
node_mcp_session -->|"lists tools"| node_server
node_mcp_session -->|"requests selection"| node_gemini
node_gemini -->|"returns tool choice"| node_mcp_session
node_mcp_session -->|"calls selected tool"| node_server
node_server -->|"registers tool"| node_single_price
node_server -->|"registers tool"| node_comparison
node_single_price -->|"fetches price"| node_yahoo
node_comparison -->|"fetches prices"| node_yahoo
node_single_price -.->|"falls back to"| node_csv
node_comparison -.->|"falls back to"| node_csv

click node_cli "https://github.com/vslsoni/mcp-stock/blob/main/mcp_client.py"
click node_gemini "https://github.com/vslsoni/mcp-stock/blob/main/mcp_client.py"
click node_mcp_session "https://github.com/vslsoni/mcp-stock/blob/main/mcp_client.py"
click node_server "https://github.com/vslsoni/mcp-stock/blob/main/mcp_server.py"
click node_single_price "https://github.com/vslsoni/mcp-stock/blob/main/mcp_server.py"
click node_comparison "https://github.com/vslsoni/mcp-stock/blob/main/mcp_server.py"
click node_csv "https://github.com/vslsoni/mcp-stock/blob/main/stocks_data.csv"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_cli,node_gemini,node_mcp_session,node_user toneBlue
class node_server,node_single_price,node_comparison toneAmber
class node_yahoo,node_csv toneMint
```

## Components

### Query client

- [Interactive CLI](https://github.com/vslsoni/mcp-stock/blob/main/mcp_client.py): `mcp_client.py`
- [Gemini tool selection](https://github.com/vslsoni/mcp-stock/blob/main/mcp_client.py): `mcp_client.py`
- [MCP session](https://github.com/vslsoni/mcp-stock/blob/main/mcp_client.py): `mcp_client.py`

### MCP stock service

- [MCP tool server](https://github.com/vslsoni/mcp-stock/blob/main/mcp_server.py): `mcp_server.py`
- [Single price tool](https://github.com/vslsoni/mcp-stock/blob/main/mcp_server.py): `mcp_server.py`
- [Price comparison tool](https://github.com/vslsoni/mcp-stock/blob/main/mcp_server.py): `mcp_server.py`

### Market data

- **Yahoo Finance**
- [Fallback stock data](https://github.com/vslsoni/mcp-stock/blob/main/stocks_data.csv): `stocks_data.csv`

### Other components

- **Querying user**

## Connections

- Querying user → Interactive CLI: submits query (evidence: `mcp_client.py`)
- Interactive CLI → MCP session: starts session (evidence: `mcp_client.py`)
- MCP session → MCP tool server: lists tools (evidence: `mcp_client.py`)
- MCP session → Gemini tool selection: requests selection (evidence: `mcp_client.py`)
- Gemini tool selection → MCP session: returns tool choice (evidence: `mcp_client.py`)
- MCP session → MCP tool server: calls selected tool (evidence: `mcp_client.py`)
- MCP tool server → Single price tool: registers tool (evidence: `mcp_server.py`)
- MCP tool server → Price comparison tool: registers tool (evidence: `mcp_server.py`)
- Single price tool → Yahoo Finance: fetches price (evidence: `mcp_server.py`)
- Price comparison tool → Yahoo Finance: fetches prices (evidence: `mcp_server.py`)
- Single price tool → Fallback stock data: falls back to (evidence: `README.md`)
- Price comparison tool → Fallback stock data: falls back to (evidence: `README.md`)
