How I Deployed an AI Agent for Sustainable Supply Chain Optimisation

Use Claude with an MCP Server to help companies design cost-efficient and sustainable supply chain networks.

Need Help?
Subscribed! Error
How I Deployed an AI Agent for Sustainable Supply Chain Optimisation

Could you imagine an AI agent replacing an army of consultants to help a company redesign its entire supply chain for more cost-efficient and sustainable operations?

Spoiler Alert: We are not yet here!

But for the first time since I discovered LLMs, I have been amazed (and worried at the same time) by the capacity of an AI agent that I deployed.

Supply Chain Network Optimisation determines where goods are produced to serve markets at the lowest cost in an environmentally friendly way.

Three grey world maps side by side, each with factory and warehouse icons and coloured flow lines, one per optimisatio…
Examples of network design with different objectives — (Image by Samir Saci)

For this difficult exercise, we must consider real-world constraints (capacity, demand) to find the optimal set of factories that will minimise the objective function.

Two side by side bar charts of the environmental ceiling the network design has to respect, energy on the left in blue a
Example of environmental constraints of maximum impact per unit produced — (Image by Samir Saci)

As a Supply Chain Solution Manager and founder of the startup Logigreen, I have led multiple network design studies that typically took 10–12 weeks.

The final deliverable was usually a deck of slides presenting multiple scenarios, allowing supply chain directors to weigh the trade-offs.

Three network designs run side by side, each a world map with the chosen plants and lanes above and a Sankey of producti
Example of Network Designs with different constraints — (Image by Samir Saci)

But decision-makers were often frustrated during the presentations of the study results:

Supply Chain Director: “What if we increase the factory capacity by 25%?”

They wanted to challenge assumptions and re-run scenarios live, while all we had were the slides we had taken hours to prepare.

My co-founder asked me: “What if we could improve this user experience using conversational agents?”

In this article, I will share with you an initial experiment I conducted a few days after the MCP servers were available for Claude Desktop.

I will demonstrate how to connect an MCP server to a FastAPI microservice utilising a Supply Chain Network Optimisation algorithm.

The user prompt sent to the agent, shown as a Claude conversation bubble on cream, asking for a dashboard comparing four
Example of a request to Claude Desktop connected to an MCP Server calling our FastAPI microservice — Image by Samir Saci

The result is a conversational agent that can run one or multiple scenarios and provide a detailed analysis with smart visuals.

We will even ask this agent to advise us on the best decision to take, considering our goals and the constraints.

The Strategic Recommendations section of the agent's report, three bolded recommendations over three boxed figures. It i
Example of strategic recommendations provided by the agent — (Image by Samir Saci)

For this experiment, I used:

  • Claude Desktop as the conversational interface
  • MCP Server to expose typed tools to the agent
  • FastAPI microservice with the network optimisation endpoint

In the first section, I will introduce the problem of Supply Chain Network design with a concrete example.

You can skip it if you are not interested in the topic.

Then, I will show multiple deep analyses performed by the conversational agent to support strategic decision-making.

Two modern chart cards showing what optimising for different objectives actually buys. The scatter on the left is the tr
Example of advanced visuals generated by the agent to answer an open question — (Image by Samir Saci)

For the first time, I have been impressed by AI when the agent selected the correct visuals to answer an open question without any guidance!

My objective is to inspire you to experiment with the connection between MCP servers and advanced analytics products.

I am genuinely excited by the capabilities of this technology.

Supply Chain Network Optimisation with Python

Problem Statement: Supply Chain Network Design

For the context, let us put ourselves in the shoes of a Supply Chain solution manager.

We are supporting the Supply Chain Director of an international manufacturing company that aims to redefine its network as part of a long-term transformation plan.

Two-panel setup for a network design problem, demand on the left as store icons across a world map with three input tile
Supply Chain Network Design Problem — (Image by Samir Saci)

This multinational company has operations in 5 different markets: Brazil, the USA, Germany, India and Japan.

Donut of monthly demand split across the five markets, used to set up the network design problem: the USA and Japan are
Example of demand per market — (Image by Samir Saci)

To meet this demand, we can open low or high-capacity factories in each of the markets.

Grouped bar chart of the two plant sizes the optimiser is allowed to open in each country, blue for LOW and red for HIGH
Capacities per factory type and location — (Image by Samir Saci)

If you open a facility, you must consider the fixed costs (associated with electricity, Real Estate, and CAPEX) and the variable costs per unit produced.

The cost side of the network model in two panels: fixed cost per month for a low and a high capacity plant on the left,
Example of fixed and variable costs per production country — (Image by Samir Saci)

In this example, high-capacity plants in India have lower fixed costs than those in the USA with lower capacity.

Plain origin by destination matrix of freight cost per container, rows the producing country and columns the receiving m
Example of freight costs per container — (Image by Samir Saci)

Additionally, there are the costs associated with shipping a container from Country XXX to Country YYY.

Everything summed up will define the total cost of producing and delivering products from a manufacturing site to the different markets.

What about sustainability?

In addition to these parameters, we consider the amount of resources consumed per unit produced.

Two side by side bar charts of the environmental ceiling the network design has to respect, energy on the left in blue a
Example of energy and water usage per unit produced in each country — (Image by Samir Saci)

For instance, we consume 780 MJ/Unit of energy and 3,500 litres of water to produce a single unit in Indian factories.

You start to understand the complexity of the exercise.

For the environmental impacts, we also consider the pollution resulting from CO2 emissions and waste generation.

The second half of the environmental input set, CO2 emissions in green and waste generation in purple, each with a dashe
Environmental impact per unit produced for each country — (Image by Samir Saci)

In the example above, Japan is the cleanest production country.

Where should we produce to minimize water usage?

The idea is to select a metric to minimise, which could be costs, water usage, CO2 emissions or energy usage.

Sankey of the cost-minimising solution, three producing countries on the left flowing to five markets on the right, show
Example of the output in the LogiGreen App — (Image by Samir Saci)

The model will indicate where to locate factories and outline the flows from these factories to the various markets.

This solution has been packaged as a web application (FastAPI backend, Streamlit front-end) used as a demo to showcase the capabilities of our startup LogiGreen.

Full window of the LogiGreen App, sidebar of applications and module selector on the left, Production Costs tab open on
User interface of the LogiGreen App (Sustainability Module) — Image by Samir Saci

The idea of today’s experiment is to connect the backend with Claude Desktop using a local MCP server built with Python.

FastAPI Microservice: 0–1 Mixed-Integer Optimiser for Supply Chain Network Design

This tool is an optimisation model packaged in a FastAPI microservice.

What are the input data for this problem?

As inputs, we should provide the objective function (mandatory) and constraints of maximum environmental impact per unit produced (optional).

The default values for the thresholds are stored in a config file.

We send these parameters to a specific endpoint launch_network that will run the optimisation algorithm.

The API returns the JSON outputs in two parts.

In the section input_params, you can find

  • The objective function selected
  • All the maximum limits per environmental impact

I also added information to bring context to the agent:

  • plant_name is a list of all the potential manufacturing locations we can open by location and type
  • prod_name is the list of all the potential production flows we can have (production, market)
  • total_demand of all the markets

We don’t return the demand per market as it is loaded on the backend side.

And you have the results of the analysis.

They include:

  • plant_opening: a list of boolean values set to 1 if a site is open
    Three sites open for this scenario: 1 low-capacity plant in India and three high-capacity plants in India, Japan, and Brazil.
  • flow_volumes: mapping of the flow between countries
    Brazil will produce 12,500 units for the USA
  • Overall volumes with local_prod, export_prod and the total_prod
  • A cost breakdown with total_fixedcosts, total_varcosts and total_costs along with an analysis of the COGS
  • Environmental impacts per unit delivered with resource usage (Energy, Water) and pollution (CO2, waste).

This network design can be visually represented with this Sankey chart.

The Production Flows tab of the LogiGreen App: three headline tiles above the same Sankey shown in a15-13. The tiles are
Sankey Chart generated by the LogiGreen App for the scenario ‘Production Cost’ — (Image by Samir Saci)

Let us see what our conversational agent can do with that!

For a detailed demo, you can have a look at the YouTube version:

Building a local MCP Server to connect Claude Desktop to a FastAPI Microservice

This follows a series of articles in which I experimented with connecting FastAPI microservices to AI agents for a Production Planning tool and a Budget Optimiser.

For this time, I wanted to replicate the experiment with Anthropic’s Claude Desktop.

Set up a local MCP Server in WSL

I will run everything inside WSL (Ubuntu) and let the Claude Desktop (Windows) communicate with my MCP server via a small JSON configuration.

The first step was to install uv package manager:

uv (Python package manager) inside WSL

We can now use it to initiate a project with a local environment:

This will be used by our `network.py` file that will contain our server setup:

This will ensure that the agent sends the correct queries to the FastAPI microservice.

Before starting to build the functionalities of our MCP Server, we need to ensure that the Claude Desktop (Windows) can find network.py.

Claude Desktop Settings on the Developer tab, showing four local MCP servers registered and the Demo one running, with i
Add functions among others that we are going to build together — (Image by Samir Saci)

As I am using WSL, I could only do it manually using the Claude Desktop config JSON file:

  1. Open Claude Desktop → Settings → Developer → Edit Config (or open the config file directly).
  2. Add an entry that starts your MCP server in WSL

With this config file, we instruct Claude Desktop to run WSL in the folder mcp_tuto and use uv to run mpc[cli] launching budget.py.

If you are in this special case of building your MCP server in a Windows machine using WSL, you can follow this approach.

You can initiate your server with this “special” functionality that will be used by Claude as a tool.

We inform Claude (in the docstring) that this addition is intended for Supply Chain Professionals only.

If you restart Claude Desktop, you should be able to see this functionality under Network.

The composer attachment menu in Claude Desktop with the registered MCP servers appearing as sources alongside file uploa
Tab with tools available — (Image by Samir Saci)

You can find our “special addition”, called Add, which is now waiting for us to be used!

The tool list exposed by the Network MCP server, three toggles all switched on, above the greeting screen. It is the mom
Add functions among others that we are going to build together — (Image by Samir Saci)

Let’s test now with a simple question.

The deliberate trap of the tutorial: a request to add 5 boxes to 7 boxes, routed to the custom Add scm tool, which retur
Example of request expecting an output using the special function — (Image by Samir Saci)

We can see that the conversational agent is calling the correct function based on the context provided in the question.

The model's reaction to the minus 2 it was handed, repeating the tool block and then reasoning that the answer is unexpe
Comment of the output — (Image by Samir Saci)

It even provides a nice comment interrogating the validity of the results.

What if we complexify a bit the exercise?

I will create a hypothetical scenario to determine if the conversational agent can associate a context with the use of a tool.

A two line setup message that gives the model two personas, Samir an inventory manager and James a book editor, and noth
Context with two characters / Samir is a Supply Chain Professional — (Image by Samir Saci)

Let us see what happens when we ask a question requiring the use of addition.

The experiment that the two personas were built for: two arithmetic questions in one message, and the model routes only
Example of a tool calling based on a “complex” context — (Image by Samir Saci)

Even if it was reluctantly, the agent had the reflex of using the special add tool for Samir, as he is a supply chain professional.

Now that we are familiar with our new MCP server, we can start adding tools for Supply Chain Network Optimisation.

Build a Supply Chain Optimisation MCP Server connected to a FastAPI Microservice

We can get rid of the special add tool and start introducing key parameters to connect to the FastAPI microservice.

The variable last_run will be used to store the results of the last run.

We need to create a tool that can connect to the FastAPI microservice.

For that, we introduced the function below.

This function takes parameters following the Pydantic model LaunchParamsNetwork, sending a clean JSON payload with None fields dropped.

It calls the FastAPI endpoint asynchronously and collects the results that are cached in last_run.

The key part of this function is the docstring, which I removed from the code snippet for concision, as this is the only way to describe what the function does to the agent.

Section 1: Context

The first section is only to introduce the context in which the tool is used.

Section 2: Describe Input Data

This brief description is crucial if we want to be sure that the agent adheres to the Pydantic schema of input parameters imposed by our FastAPI microservice.

Section 3: Description of output results

This part describes to the agent the outputs it will receive.

I did not want to only count on “self-explicit” naming of variables in the JSON.

I want to ensure that it understands the data it has on hand and can provide summaries in accordance with the guidelines listed below.

I share a list of potential scenarios and explanations of the type of analysis I expect using an actual example.

This is far from being concise, but my objective here is to ensure that the agent is equipped to use the tool at its highest potential.

Experiment with the tool: from simple to complex instructions

To test the workflow, I ask the agent to run the simulation with default parameters.

The first real run: one sentence of instruction, a Run network tool call, and a structured report back with the objectiv
Sample of analysis provided by the conversation agent — (Image by Samir Saci)

As expected, the agent calls the FastAPI microservice, collects the results, and concisely summarises them.

This is cool, but I already had that with my Production Planning Optimisation Agent built with LangGraph and FastAPI.

A production planning result delivered as an ordinary Gmail message from the LogiGreen bot, with demand, the months chos
Example of output analysis of the Production Planning Optimisation Agent — (Image by Samir Saci)

I wanted to explore MCP Servers with Claude Desktop for a more advanced usage.

Supply Chain Director: “I want to have a comparative study of multiple scenario.”

If we come back to the original plan, the idea was to equip our decision-makers (customers who pay us) with a conversational agent that would assist them in their decision-making process.

Let us try a more advanced question:

The user prompt sent to the agent, shown as a Claude conversation bubble on cream, asking for a dashboard comparing four
Here we provide more open questions that reflect the needs of our customers — (Image by Samir Saci)

We explicitly request a comparative study while allowing Claude Sonnet 4 to be creative in terms of visual rendering.

The agent's plan and execution for the four scenario dashboard: it states it will run the model once per objective funct
Claude Agent sharing its plan — (Image by Samir Saci)

To be honest, I was impressed by the dashboard that was generated by Claude, which you can access via this link.

At the top, you can find an executive summary listing what can be considered the most important indicators of this problem.

Header and executive summary of the four scenario dashboard the agent generated, a violet gradient panel over four white
Executive Summary generated by Claude — (Image by Samir Saci)

The model understood, without being explicitly asked in the prompt, that these four indicators were key to the decision-making process resulting from this study.

At this stage, in my opinion, we already get the added value of incorporating an LLM into the loop.

The following outputs are more conventional and could have been generated with deterministic code.

The two metric tables behind the dashboard, financial above and environmental below, one column per objective function w
Financial and Environmental Metrics Summary Table — (Image by Samir Saci)

However, I admit that the creativity of Claude outperformed my own web application with this smart visual showing the plant openings per scenario.

Which facilities each objective opens, countries down the side and objectives across the top, with LOW and HIGH capacity
Plant open per scenario — (Image by Samir Saci)

While I was starting to worry about getting replaced by AI, I had a look at the strategic analysis generated by the agent.

Light panel of Claude's cost versus sustainability trade-off write-up, with three cost-premium cards along the bottom
Example of trade-off analysis — (Image by Samir Saci)

The approach of comparing each scenario vs a baseline of cost optimisation has never been explicitly requested.

The agent took the initiative to bring up this angle when presenting results.

This demonstrated the ability to select the appropriate indicators to convey a message effectively using data.

Can we ask open questions?

Let me explore that in the next section.

A Conversation Agent capable of decision-making?

To further explore the capabilities of our new tool and test its potential, I will pose open-ended questions.

Question 1: Trade-off between cost and sustainability

The open-ended second question, phrased the way a director would ask it rather than as an optimisation problem: what is
Question 1 — (Image by Samir Saci)

This is the type of question I got when I was in charge of network studies.

The agent's answer to the compromise question, three bordered statements on a violet gradient: water optimisation is the
Executive Summary — Image by Samir Saci

This appeared to be a recommendation to adopt the Water-optimised strategy to find the perfect balance.

Two modern chart cards showing what optimising for different objectives actually buys. The scatter on the left is the tr
Visuals — (Image by Samir Saci)

It used compelling visuals to support its idea.

I really like the cost vs. environmental impact scatter plot!

The implementation plan that follows the compromise recommendation, five numbered green panels moving from the strategy
Implementation Plan — (Image by Samir Saci)

Unlike some strategy consulting firms, it did not forget the implementation part.

For more details, you can access the complete dashboard at this link.

Let’s try another tricky question.

Question 2: Best CO2 Emissions Performance

The third question, and the hardest one for a solver: given the water optimum of 2,632 litres a unit, how low can water
What is the best performance for indicator XXX under budget limits — (Image by Samir Saci)

This is a challenging question that required seven runs to answer.

Seven consecutive Run network calls stacked in one block, the agent walking the water constraint down step by step until
7 runs to answer the question — (Image by Samir Saci)

This was enough to provide the question with the correct solution.

The answer to the budget question in five checkable lines: 2,900 litres a unit at 6.75 million euros, 96.4 per cent of t
Optimal Solution — (Image by Samir Saci)

What I appreciate the most is the quality of the visuals used to support its reasoning.

The trade-off curve behind the answer: cost against water consumption, water falling left to right, with the 7 million e
Example of visual used — (Image by Samir Saci)

In the visual above, we can see the different scenarios simulated by the tool.

Although we could question the wrong orientation of the (x-axis), the visual remains self-explicit.

The recommendation panel for the budget-constrained water question, four green cards and a key insight that prices the n
Strategic Recommendation — (Image by Samir Saci)

Where I feel beaten by the LLM is when we look at the quality and concision of the strategic recommendations.

Considering that these recommendations serve as the primary point of contact with decision-makers, who often lack the time to delve into details, this remains a strong argument in favour of using this agent.

Conclusion

💡
If you have any question, feel free to ask it here: Ask a Question

This experiment is a success!

There is no doubt about the added value of MCP Servers compared to the simple AI workflows introduced in the previous articles.

When you have an optimisation module with multiple scenarios (depending on objective functions and constraints), you can leverage MCP servers to enable agents to make decisions based on data.

I would apply this solution to algorithms like

These are opportunities to equip your entire supply chain with conversation agents (connected to optimisation tools) that can support decision-making.

Can we go beyond operational topics?

The reasoning capacity that Claude showcased in this experiment also inspired me to explore business topics.

A solution presented in one of my YouTube tutorials could be a good candidate for our next MCP integration.

Five-stage value chain drawn as a single boxed strip, supplier to customer, with the product itself circled above the mi
Value chain of the example used in the video — (Image by Samir Saci)

The goal was to support a friend who runs a business in the food and beverage industry.

They sell renewable cups produced in China to coffee shops and bars in Paris.

The same chain with a cost unit written under every stage and three management levers hung off it, the service agreement
Value Chain of this business — (Image by Samir Saci)

I wanted to use Python to simulate its entire value chain to identify optimisation levers to maximise its profitability.

Cash flow of a small business drawn as two halves meeting at a central liquidity icon, revenue coming in green from the
Business Planning with Python — Inventory and Cash Flow Management (Image by Samir Saci)

This algorithm, also packaged in a FastAPI microservice, can become your next data-driven business strategy consultant.

Five business scenarios compared on four indicators, absolute values above and percentage change against the initial sit
Simulation of scenarios to find the optimal setup to maximise profitability — (Image by Samir Saci)

Part of the job involves simulating multiple scenarios to determine the optimal trade-off between several metrics.

I clearly see a conversational agent powered by an MCP server doing the job perfectly.

For more information, have a look at the video linked below

I will share this new experiment in a future article.

Stay tuned!

About Me

Let’s connect on Linkedin and Twitter. I am a Supply Chain Engineer who uses data analytics to improve logistics operations and reduce costs.

For consulting or advice on analytics and sustainable supply chain transformation, feel free to contact me.

Need Help?