Skip to main content
Glama
Supply Chain Disruption Monitor

Supply Chain Disruption Monitor

by trevorquinn

Supply Chain Disruption Monitor

An MCP server exposing supply chain intelligence tools, with a PydanticAI agent that synthesizes them to answer disruption questions.

Demo scenario: "What disruptions could affect shipments from Shanghai to Rotterdam right now?"

The agent calls multiple tools, synthesizes the results, and produces a structured risk assessment — demonstrating that the value is in the reasoning across sources, not any single data lookup.

Built as a self-training project and portfolio artifact.


Tech stack

Layer

Choice

Notes

MCP server

Python MCP SDK (mcp)

FastMCP decorator API, stdio transport

Agent framework

PydanticAI

MCPToolset + StdioTransport to wire agent → server

LLM

qwen2.5:7b via Ollama

Local, reliable tool calling

Vessel data

AISStream.io

Free WebSocket AIS feed

Weather

Open-Meteo

Free, no API key

News

NewsAPI

Free tier (100 req/day)

Port congestion

Mocked

Realistic synthetic data


Related MCP server: ShippingRates

Setup

1. Prerequisites

  • Python 3.11+

  • uv — pip install uv or brew install uv

  • Ollama — for the local LLM

2. Install dependencies

cd supply-chain-disruption-monitor
uv sync

3. Pull the model

ollama pull qwen2.5:7b

4. Configure API keys

cp .env.example .env

Edit .env and fill in:

  • AISSTREAM_API_KEY — Free at aisstream.io. Provides real-time vessel positions via WebSocket AIS feed.

  • NEWS_API_KEY — Free at newsapi.org. 100 requests/day on the free tier.

The weather tool (Open-Meteo) needs no key.


Running

MCP server (standalone — for development / MCP Inspector)

uv run mcp dev server.py

This opens the MCP Inspector in your browser so you can call tools interactively.

Agent only

Note: agent.py is a sample MCP client, not part of the server itself. It plays the same role Claude Desktop, Codex, or any other MCP client would — it launches server.py over stdio, runs the agent loop against a local model (Ollama), and synthesizes the tool results. The server is the deliverable; the agent is just one interchangeable consumer of it. It imports nothing from server.py and talks to it purely over the MCP protocol, so you can swap in any other MCP client without touching the server.

# Default query: Shanghai to Rotterdam risk assessment
uv run agent.py

# Custom query
uv run agent.py "What risks affect container ships transiting the Red Sea?"

Full demo (tool outputs + agent synthesis)

uv run demo.py              # tools + agent
uv run demo.py --tools-only # just raw tool outputs
uv run demo.py --agent-only # just the agent synthesis

MCP tools

Tool

Source

Returns

list_major_ports(region)

Static

Major ports by region — use this first to identify route waypoints

get_port_weather(port_name)

Open-Meteo

Current conditions + 24h forecast, wind speed in knots, operational impact

get_vessel_positions(region)

AISStream.io

Live vessel snapshot: MMSI, name, position, speed, nav status

search_disruption_news(query, days)

NewsAPI

Recent headlines + high-signal flag (strikes, attacks, blockages)

get_port_congestion(port_name)

Mocked

Utilization %, queue depth, wait hours, trend, advisory

The agent synthesizes across all five — there is no single assess_route_risk tool. The multi-tool reasoning is the point.


Add this server to Claude Desktop

Add to your Claude Desktop claude_desktop_config.json:

{
  "mcpServers": {
    "supply-chain-monitor": {
      "command": "uv",
      "args": ["run", "--directory", "/path/to/supply-chain-disruption-monitor", "python", "server.py"],
      "env": {
        "AISSTREAM_API_KEY": "your_key_here",
        "NEWS_API_KEY": "your_key_here"
      }
    }
  }
}

Project structure

supply-chain-disruption-monitor/
├── server.py           # FastMCP server — all 5 tools
├── agent.py            # Sample MCP client (PydanticAI) — interchangeable with Claude Desktop, Codex, etc.
├── demo.py             # Demo script (tool outputs + agent synthesis)
├── tools/
│   ├── ports.py        # Static port data + coordinates (27 major ports)
│   ├── weather.py      # Open-Meteo integration
│   ├── vessels.py      # AISStream.io WebSocket integration
│   ├── news.py         # NewsAPI integration
│   └── congestion.py   # Mocked port congestion (realistic synthetic data)
├── pyproject.toml
├── .env.example
└── README.md

Design notes

Why mock port congestion? Live data (MarineTraffic, FreightWaves) requires enterprise subscriptions (£100+/month). Mocking gives full demo control — a "Shanghai congestion spike" can be shown without paywall friction. The tool interface is identical to what a real API would return.

Why AISStream.io? It's a free, real-time WebSocket AIS feed. A vessel actually moving through the South China Sea is a better demo moment than a static mock.

Why qwen2.5:7b? Reliable tool-calling behavior at a size that runs well on consumer hardware (16 GB RAM). Swap in any model with Ollama support by changing OLLAMA_MODEL in .env.

Why PydanticAI? PydanticAI co-maintains the official Python MCP SDK, so using their stack is thematically coherent. MCPServerStdio is the native path for agent → MCP server wiring.

Available Tools

5 tools
get_port_congestionA

Get current congestion metrics for a port: vessel queue, wait times, capacity utilization, trend, and operational advisory.

Data is realistically mocked (live data requires MarineTraffic or FreightWaves enterprise subscription). The interface mirrors what a production integration would return.

Args: port_name: Port common name or UN/LOCODE

Returns: dict with capacity_utilization_pct, vessels_queued, estimated_wait_hours, trend_vs_yesterday, severity, and advisory

Inputs: port_name (required).

get_port_weatherA

Get current weather conditions and 24-hour forecast for a port.

Weather is sourced from Open-Meteo (free, no API key required). Pay attention to wind speed in knots — values above 25 kn affect large vessel operations; above 40 kn typically suspends port activity.

Args: port_name: Port common name (e.g. "Rotterdam") or UN/LOCODE (e.g. "NLRTM")

Returns: dict with current conditions, wind speed, operational impact assessment, and hourly 24h forecast

Inputs: port_name (required).

get_vessel_positionsA

Get live vessel positions from AIS transponder data for a shipping region.

Uses AISStream.io free WebSocket feed (requires AISSTREAM_API_KEY in .env). Listens for ~8 seconds and returns a snapshot of vessels in the region.

Named regions this tool recognizes (not specific to any one route — use whichever apply to the route you're assessing): "South China Sea", "East China Sea", "Strait of Malacca", "Indian Ocean", "Red Sea", "Suez Canal", "Persian Gulf", "Mediterranean", "English Channel", "North Sea", "Taiwan Strait", "East Asia", "Northwest Europe", "North America West", "North America East"

Args: region: Named region — see list above, or call list_major_ports() for context max_vessels: Maximum vessels to return (default 20)

Returns: dict with vessel_count, underway/anchored breakdown, and per-vessel details (MMSI, name, position, speed, course, nav status)

Inputs: region (required), max_vessels.

list_major_portsA

List major container ports, optionally filtered by region.

This is the grounding tool — call it first when you need to know which ports are relevant to a route or region before calling other tools.

Args: region: Optional region filter. Available regions: East Asia, Southeast Asia, South Asia, Middle East, Red Sea, Northwest Europe, Mediterranean, North America West, North America East. Leave empty to list all ports.

Returns: dict with 'region', 'port_count', and 'ports' list

Inputs: region.

search_disruption_newsA

Search recent news for supply chain disruption signals.

Uses NewsAPI (free tier, 100 req/day — requires NEWS_API_KEY in .env). Returns articles with a 'flagged_high_signal' list highlighting those mentioning strikes, storms, blockages, attacks, or sanctions.

If the query names a known port or shipping region, results are filtered to articles that actually mention that place — this prevents e.g. a Red Sea query returning unrelated Strait of Hormuz coverage just because both mention "attack". Check the 'location_filter' and 'filtered_out' fields in the response to see if/how this applied. Lead each query with the exact place name for the filter to engage.

Example query shapes — lead with the place actually relevant to your route, not necessarily these:

  • " port delay" (e.g. "Rotterdam port delay")

  • " attack blockage" (e.g. "Red Sea attack blockage")

  • " disruption" (e.g. "Suez Canal disruption")

  • "container shipping freight rates" (no location — not filtered)

Args: query: Search query string, ideally leading with a specific place name days: Days back to search (default 7, max 30 on free tier)

Returns: dict with articles list, flagged_high_signal subset, and location_filter/filtered_out showing whether results were filtered

Inputs: query (required), days.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.6/5.0

    Scored across 5 tools

    Disambiguation5/5

    Each tool targets a distinct data source or aspect: port catalog, weather, vessel positions, news, and congestion. There is no overlap in purpose, and the descriptions clarify when to use each.

    Naming Consistency5/5

    All tool names use a consistent verb_noun pattern in snake_case: list_major_ports, get_port_weather, get_vessel_positions, search_disruption_news, get_port_congestion. The verbs are appropriate for each action, and the naming is predictable.

    Tool Count5/5

    Five tools is a well-scoped count for a supply chain disruption monitor. Each tool covers a distinct capability without redundancy, and the set is neither too thin nor too heavy.

    Completeness4/5

    The tool set covers the core workflow: grounding via port list, then checking weather, vessel positions, news, and congestion. Minor gaps like historical trends or a combined risk assessment exist, but agents can work around them.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers