Skip to content

Instantly share code, notes, and snippets.

View samirsaci's full-sized avatar

Samir Saci samirsaci

View GitHub Profile
@samirsaci
samirsaci / df.csv
Created February 16, 2026 10:24
MCP Leadtime - Example of transational data
Test Order Time Transmission Transmission OnTime Start PickPack Pickpack Loading Loading OnTime Airport Arrival Airport OnTime Takeoff Landing Landing OnTime Start Clearance End Clearance Leaving Airport Store Arrival Delivery OnTime
1 2025-12-21 15:00:00 2025-12-21 16:45:53.536117218 True 2025-12-22 07:00:00 2025-12-22 15:20:26.554962864 2025-12-22 19:00:00 True 2025-12-22 23:14:02.912091230 True 2025-12-23 06:00:00 2025-12-23 19:29:35.948379338 True 2025-12-24 09:00:00 2025-12-24 11:16:12.544500039 2025-12-24 12:05:13.204603532 2025-12-24 16:16:37.481056630 True
@samirsaci
samirsaci / docstring_interprete_results.py
Created November 9, 2025 13:42
MCP Server Supply Chain Optimisation - Doc String Interprete Results
"""
HOW TO READ THIS RUN (based on the sample JSON)
-----------------------------------------------
- Objective = cost: the model opens 4 plants (INDIA-LOW, JAPAN-HIGH, BRAZIL-HIGH, INDIA-HIGH),
heavily exporting from INDIA and BRAZIL to the USA, while JAPAN supplies itself.
- Unit economics: unit_cost ≈ €116.10; total_costs ≈ €5.683M (divide by 1e6 for M€).
- Market economics: “JAPAN” is the most expensive market; “INDIA” the cheapest.
- Localization ratio: local_prod / total_prod = 18,050 / 48,950 ≈ 36.87% local, 63.13% export.
- Footprint per unit: e.g., unit_co2 ≈ 35.55 kgCO₂e/unit. To approximate total CO₂:
unit_co2 * total_units ≈ 35.55 * 48,950 ≈ 1,740,100 kgCO₂e (≈ 1,740 tCO₂e).QUICK SANITY CHECKS
@samirsaci
samirsaci / docstring_output.py
Created November 9, 2025 13:41
MCP Server Supply Chain Optimisation - Doc String Describe Output
"""
OUTPUT (matches your service schema)
------------------------------------
The service returns { "input_params": {...}, "output_results": {...} }.
Here’s what the fields mean, using your sample:input_params:
- objective: "Production Cost" # objective actually used
- max_energy: 780 # per-unit maximum energy usage (MJ/unit)
- max_water: 3500 # per-unit maximum water usage (L/unit)
- max_waste: 0.78 # per-unit maximum waste (kg/unit)
- max_co2prod: 41 # per-unit maximum CO₂ production (kgCO₂e/unit, production only)
@samirsaci
samirsaci / docstring_input.py
Created November 9, 2025 13:38
MCP Server Supply Chain Optimisation - Doc String Describe Input
"""
INPUT (LaunchParamsNetwork)
---------------------------
- objective: str (default "Production Cost")
One of {"Production Cost", "CO2 Emissions", "Water Usage", "Energy Usage"}.
Sets the optimization objective.
- max_energy, max_water, max_waste, max_co2prod: float | None
Per-unit caps (average across the whole plan). If omitted, service defaults
from your config are used. Internally the model enforces:
sum(impact_i * qty_i) <= total_demand * max_impact_per_unit
@samirsaci
samirsaci / context.py
Created November 9, 2025 13:37
MCP Server Supply Chain Optimisation - Doc String Context
"""
Run the LogiGreen Supply Chain Network Optimization.
WHAT IT SOLVES
--------------
A facility-location + flow assignment model. It decides:
1) which plants to open (LOW/HIGH capacity by country), and
2) how many units each plant ships to each market,
to either minimize total cost or an environmental footprint (CO₂, water, energy),
under capacity and optional per-unit footprint caps.
"""
@samirsaci
samirsaci / run_network.py
Created November 9, 2025 13:36
MCP Server Supply Chain Optimisation - Tool Run Network
@mcp.tool()
async def run_network(params: LaunchParamsNetwork,
session_id: str = "mcp_agent") -> dict:
"""
[DOC STRING TRUNCATED]
"""
payload = params.model_dump(exclude_none=True)
try:
async with httpx.AsyncClient(timeout=httpx.Timeout(5, read=60)) as c:
r = await c.post(LAUNCH, json=payload, headers={"session_id": session_id})
@samirsaci
samirsaci / endpoint_config.py
Created November 9, 2025 13:35
MCP Server Supply Chain Optimisation - Endpoint Config
# Endpoint config
API = os.getenv("NETWORK_API_URL")
LAUNCH = f"{API}/network/launch_network" # <- network route
last_run: Optional[Dict[str, Any]] = None
@samirsaci
samirsaci / a_b_too.py
Created November 9, 2025 13:34
MCP Server Supply Chain Optimisation - Example Tool
@mcp.tool()
def add(a: int, b: int) -> int:
"""Special addition only for Supply Chain Professionals: add two numbers.
Make sure that the person is a supply chain professional before using this tool.
"""
logging.info(f"Test Adding {a} and {b}")
return a - b
@samirsaci
samirsaci / config.json
Created November 9, 2025 13:33
MCP Server Supply Chain Optimisation - Config File Claude
{
"mcpServers": {
"Network": {
"command": "wsl",
"args": [
"-d",
"Ubuntu",
"bash",
"-lc",
"cd ~/mcp_tuto && uv run --with mcp[cli] mcp run network.py"
@samirsaci
samirsaci / network.py
Created November 9, 2025 13:32
MCP Server Supply Chain Optimisation - Network py
import logging
import httpx
from mcp.server.fastmcp import FastMCP
from models.network_models import LaunchParamsNetwork
import os
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s - %(message)s",
handlers=[
logging.FileHandler("app.log"),