Skip to content
View umairakhtar3's full-sized avatar

Block or report umairakhtar3

Block user

Prevent this user from interacting with your repositories and sending you notifications. Learn more about blocking users.

You must be logged in to block users.

Maximum 250 characters. Please don't include any personal information such as legal names or email addresses. Markdown supported. This note will be visible to only you.
Report abuse

Contact GitHub support about this user’s behavior. Learn more about reporting abuse.

Report abuse
umairakhtar3/README.md

Manufacturing Analytics Agent

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.


Features

  • 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?

Requirements

  • Python ≥ 3.11
  • Azure APIM instance with the manufacturing APIs deployed
  • Anthropic API key

Installation

# 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_KEY

Configuration

All 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)

Usage

Interactive REPL (default)

manufacturing-agent

Start 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

Single question (non-interactive)

manufacturing-agent ask "Give me a full supplier PO report"

MCP server mode

Run the agent as a standalone MCP server (stdio transport) for integration with Claude Desktop or other MCP clients:

manufacturing-agent mcp

Add 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": "..."
      }
    }
  }
}

Available APIM Endpoints (Tools)

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.


Example Queries

Purchase Orders

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?

Batch & Material Origins

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?

Production Orders

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?

Suppliers & Products

List all active suppliers.
Show me the product catalogue.
Is there a supplier called Acme Steel in the system?

Development

Run tests

pip install -e ".[dev]"
pytest

Lint

ruff check src tests

Project structure

src/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

Security

  • 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).

Popular repositories Loading

  1. umairakhtar3 umairakhtar3 Public

    Config files for my GitHub profile.

    Python

  2. DataProjects DataProjects Public

    Mobile network and Economic Indicator Analysis

    Python

  3. Python-Basics Python-Basics Public

    Jupyter Notebook

  4. Data_Visualisation Data_Visualisation Public