This project implements a simple Model Context Protocol (MCP) server using FastMCP, Pydantic, and Uvicorn.
It exposes three tools:
- Add Product
- Search Product
- Get Product by ID
Products are stored in an in-memory database, making this ideal for demos, prototyping, or integrating with an MCP-compatible AI agent.
- FastMCP-based MCP server
- Tool functions to:
- Add a new product
- Search products by name or category
- Retrieve product details by ID
- Simple in-memory storage
- Runs over HTTP using Uvicorn
python3 -m venv venv
source venv/bin/activatepip install -r requirements.txtStart the MCP server:
python main.pyThe server will start on:
http://localhost:8000Available Tools
Adds a new product to the in-memory catalog.
Input Model (AddProductInput)
{
"name": "Laptop",
"category": "Electronics",
"price": 1299.99,
"stock": 5,
"description": "Powerful gaming laptop"
}Searches for products by name or category.
Input Model (SearchInput)
{
"query": "laptop"
}Gets a product by its unique ID.
Input Model (GetProductInput)
{
"product_id": "uuid-here"
}Run the client
python client.py