An intelligent CLI agent for a stainless steel manufacturing company, powered by Claude (Anthropic) and connected to operational data via Azure API Management (APIM). The agent understands natural-language queries and returns structured analytics across Purchase Orders, Suppliers, Batch Numbers, Production Orders, and Products.
- Natural-language analytics — ask questions in plain English; Claude maps intent to the right API automatically
- Full agentic loop — multi-step reasoning with tool use (Claude calls APIM endpoints as needed)
- Rich terminal output — colour-coded tables, trend rows, percentage bars, and follow-up suggestions
- MCP server mode — expose all manufacturing tools via the Model Context Protocol for use with Claude Desktop or other MCP clients
- Comprehensive analytics:
- Purchase Orders: totals, per-supplier breakdown, % share, top/bottom 5, monthly trend
- Batch origins: domestic vs overseas ratios, quantity breakdowns, monthly trend
- Production orders: planned vs actual efficiency, per-product and per-status breakdown
- Cross-referencing: which production orders used overseas batches?
- Python ≥ 3.11
- Azure APIM instance with the manufacturing APIs deployed
- Anthropic API key
# Clone the repository
git clone <repo-url>
cd manufacturing-analytics-agent
# Create and activate a virtual environment
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
# Install the package and its dependencies
pip install -e .
# Copy and fill in the configuration
cp .env.example .env
# Edit .env with your APIM_BASE_URL, APIM_SUBSCRIPTION_KEY, ANTHROPIC_API_KEYAll configuration is done via environment variables (or a .env file):
| Variable | Required | Description |
|---|---|---|
APIM_BASE_URL |
Yes | Azure APIM base URL, e.g. https://my-apim.azure-api.net |
APIM_SUBSCRIPTION_KEY |
Yes | APIM subscription key |
ANTHROPIC_API_KEY |
Yes | Anthropic API key |
CLAUDE_MODEL |
No | Claude model ID (default: claude-sonnet-4-6) |
DEFAULT_DATE_RANGE_DAYS |
No | Default lookback in days (default: 365) |
MAX_RECORDS_BEFORE_PAGINATION |
No | Records before truncation warning (default: 500) |
LOG_LEVEL |
No | Python log level (default: WARNING) |
manufacturing-agentStart a conversational session. Type your question and press Enter:
You > How many purchase orders were raised for Supplier A last year?
You > Give me a full supplier PO report with percentages
You > Analyse batch material origins — how much came from different regions?
You > Which production orders used batches from overseas origin?
Special commands in the REPL:
| Command | Action |
|---|---|
help |
Show example queries |
reset |
Clear conversation history and start fresh |
exit / quit |
Exit the agent |
manufacturing-agent ask "Give me a full supplier PO report"Run the agent as a standalone MCP server (stdio transport) for integration with Claude Desktop or other MCP clients:
manufacturing-agent mcpAdd to Claude Desktop's claude_desktop_config.json:
{
"mcpServers": {
"manufacturing": {
"command": "manufacturing-agent",
"args": ["mcp"],
"env": {
"APIM_BASE_URL": "https://my-apim.azure-api.net",
"APIM_SUBSCRIPTION_KEY": "...",
"ANTHROPIC_API_KEY": "..."
}
}
}
}| Tool name | APIM endpoint | Purpose |
|---|---|---|
get_purchase_orders |
/manufacturing/purchase-orders |
PO headers + line items, aggregated by supplier |
get_suppliers |
/manufacturing/suppliers |
Supplier master catalogue |
get_batch_origins |
/manufacturing/batch-numbers |
Batch records aggregated by material origin |
get_production_orders |
/manufacturing/production-orders |
Production orders aggregated by product/status |
get_products |
/manufacturing/products |
Product catalogue |
find_overseas_batch_production_orders |
(cross-reference) | Production orders that used overseas batches |
All date-filtered tools accept from_date / to_date (YYYY-MM-DD) and a use_previous_full_year flag.
How many purchase orders were raised for Supplier A last year?
Give me a full supplier PO report with percentages.
Show me monthly PO trends for the last 12 months.
What was our total procurement spend last year?
Analyse batch material origins — how much came from different regions?
What percentage of our raw material came from overseas suppliers?
Show me batch origin trends by month.
Which countries do we import stainless steel from?
Which production orders used batches from overseas origin?
Give me a production efficiency report by product.
How many production orders are still in progress?
What is our average planned vs actual output for 304SS?
List all active suppliers.
Show me the product catalogue.
Is there a supplier called Acme Steel in the system?
pip install -e ".[dev]"
pytestruff check src testssrc/manufacturing_agent/
├── __init__.py # Package metadata
├── api_client.py # Azure APIM HTTP client (async, httpx)
├── analytics.py # Pure-Python aggregation & analytics functions
├── formatters.py # Rich terminal output formatters
├── mcp_server.py # MCP server exposing tools via stdio transport
├── agent.py # Claude agentic loop (tool-use with Anthropic SDK)
└── cli.py # Click CLI entry point (repl / ask / mcp)
tests/
├── test_analytics.py # Unit tests for aggregation logic
├── test_api_client.py # Unit tests for APIM client (mocked HTTP)
└── test_mcp_server.py # Unit tests for MCP tool dispatch
- API keys and subscription keys are never logged or exposed in output.
- The agent explicitly refuses to reveal internal APIM URLs or credentials.
- Individual-level cost data respects auth context from the APIM layer.
- All HTTP calls use HTTPS (enforced by the APIM base URL pattern).