Skip to content

This project implements a simple Model Context Protocol (MCP) server using FastMCP, Pydantic, and Uvicorn.

Notifications You must be signed in to change notification settings

fedilahbib/MCP-server-using-FastMCP

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Product MCP Server

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.


Features

  • 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

Installation

1. Create a virtual environment

python3 -m venv venv
source venv/bin/activate

2. Install dependencies

pip install -r requirements.txt

Running the Server

Start the MCP server:

python main.py

The server will start on:

http://localhost:8000

Available Tools

1. add_product

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"
}

2. search_product

Searches for products by name or category.

Input Model (SearchInput)

{
  "query": "laptop"
}

3. get_product

Gets a product by its unique ID.

Input Model (GetProductInput)

{
  "product_id": "uuid-here"
}

MCP Client Example

Run the client

python client.py

About

This project implements a simple Model Context Protocol (MCP) server using FastMCP, Pydantic, and Uvicorn.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages