This template repository contains a Model Context Protocol (MCP) server implementation for managing clothing store inventory in Python. The sample can be easily deployed to Azure using the Azure Developer CLI (azd). It uses managed identity and a virtual network to make sure deployment is secure by default. You can opt out of a VNet being used in the sample by setting VNET_ENABLED to false in the parameters.
Model Context Protocol (MCP) is an open standard that enables secure connections between host applications (like Claude Desktop, IDEs, or other AI tools) and external data sources and tools. MCP allows AI assistants to securely interact with local and remote resources while maintaining user control and privacy.
This sample demonstrates how to create an MCP server that provides tools for managing clothing inventory, including adding items, searching inventory, updating quantities, and retrieving item details. The server uses FastMCP for HTTP transport and SQLite for data persistence.
- Python 3.8+
- Azure Functions Core Tools
- Azure Developer CLI (azd)
- To use Visual Studio Code to run and debug locally:
You can initialize a project from this azd template in one of these ways:
-
Use this
azd initcommand from an empty local (root) folder:azd init --template functions-mcp-inventory-server-python
Supply an environment name, such as
mcpinventorywhen prompted. Inazd, the environment is used to maintain a unique deployment context for your app. -
Clone the GitHub template repository locally using the
git clonecommand:git clone https://github.com/Azure-Samples/functions-mcp-inventory-server-python.git cd functions-mcp-inventory-server-pythonYou can also clone the repository from your own fork in GitHub.
-
Navigate to the app folder and create a file in that folder named
local.settings.jsonthat contains this JSON data:{ "IsEncrypted": false, "Values": { "FUNCTIONS_WORKER_RUNTIME": "python" } } -
Create a Python virtual environment and activate it
-
From the app folder, install Python dependencies:
pip install -r requirements.txt
-
Start the Functions host locally:
func start
-
The MCP server will be available at
http://localhost:7071/mcpand will accept MCP protocol requests. The server provides the following tools:add_item: Add a new clothing item to inventoryget_inventory: Get all items with their sizes and quantitiesget_item_by_id: Get details of a specific itemsearch_items: Search items by name or categoryupdate_item_quantity: Update stock quantity for specific item and size
-
Connect to the MCP server by going to mcp.json (inside .vscode/) and clicking start button above the local server.
-
Test the server by opening VSCode Copilot in agent mode and asking it questions related to clothing inventory.
-
When you're done, press Ctrl+C in the terminal window to stop the app
- Open the app folder in a new terminal.
- Run the
code .command to open the project in Visual Studio Code. - Install Python dependencies by running
pip install -r requirements.txtin the terminal. - Press Run/Debug (F5) to run in the debugger. Select Debug anyway if prompted about local emulator not running.
- The MCP server will be available at
http://localhost:7071/mcpand ready to accept MCP protocol requests.
The server uses SQLite for local data persistence with automatic initialization from sample data. The inventory data is stored in two tables:
items: Core item information (name, category, price, description)item_sizes: Size-specific quantities for each item
The server includes sample clothing inventory data that's automatically loaded into the database. You can modify this file to customize the initial inventory:
SAMPLE_INVENTORY = [
{
"id": 1,
"name": "Navy Single-Breasted Slim Fit Formal Blazer",
"category": "Jackets",
"price": 89.99,
"description": "Tailored navy blazer with notch lapels",
"sizes": {
"XS": 0, "S": 0, "M": 0, "L": 0, "XL": 0, "XXL": 0, "XXXL": 0
}
},
# More items...
]Run this command to provision the function app, with any required Azure resources, and deploy your code:
azd upBy default, this sample prompts to enable a virtual network for enhanced security. If you want to deploy without a virtual network without prompting, you can configure VNET_ENABLED to false before running azd up:
azd env set VNET_ENABLED false
azd upYou're prompted to supply these required deployment parameters:
| Parameter | Description |
|---|---|
| Environment name | An environment that's used to maintain a unique deployment context for your app. You won't be prompted if you created the local project using azd init. |
| Azure subscription | Subscription in which your resources are created. |
| Azure location | Azure region in which to create the resource group that contains the new Azure resources. Only regions that currently support the Flex Consumption plan are shown. |
Once deployment is done, test the MCP server by making requests to the deployed endpoint. To get the endpoint quickly, run the following:
az functionapp function list --resource-group <resource-group-name> --name <function-app-name> --query "[].{name:name, url:invokeUrlTemplate}" --output tableThe MCP server endpoint should look like:
https://<function-app-name>.azurewebsites.net/mcp
Sample server currently has anonymous access, which is not secured. Will add authentication layer soon!
You can run the azd up command as many times as you need to both provision your Azure resources and deploy code updates to your function app.
Note: Deployed code files are always overwritten by the latest deployment package.
When you're done working with your function app and related resources, you can use this command to delete the function app and its related resources from Azure and avoid incurring any further costs:
azd downThis repository contains an MCP (Model Context Protocol) server implementation for clothing inventory management written in Python. It's deployed to Azure Functions Flex Consumption plan using the Azure Developer CLI (azd). The sample uses managed identity and a virtual network to make sure deployment is secure by default.
The MCP server provides tools for:
- Adding new clothing items with sizes and quantities
- Searching and retrieving inventory items
- Updating stock quantities
- Managing clothing store inventory through the MCP protocol
This enables AI assistants and other MCP-compatible applications to securely interact with inventory data while maintaining proper access controls and data persistence.