Skip to main content
Glama
hwqlet

MCP Product Search Server

by hwqlet

get_product

Retrieve full product details by entering a product ID. Solves the need to access specific product information quickly from the product catalog.

Instructions

Retrieve full details for a single product by its ID (e.g. "P001").

Args: product_id: The product's unique identifier.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
product_idYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • server.py:66-77 (handler)
    The MCP tool handler for 'get_product'. It searches the CATALOG list for a product by its ID (case-insensitive) and returns the product details as JSON, or an error message if not found.
    @mcp.tool()
    def get_product(product_id: str) -> str:
        """Retrieve full details for a single product by its ID (e.g. "P001").
    
        Args:
            product_id: The product's unique identifier.
        """
        for product in CATALOG:
            if product.id.upper() == product_id.upper():
                return json.dumps(product.to_dict(), ensure_ascii=False, indent=2)
    
        return json.dumps({"error": f"Product '{product_id}' not found."}, indent=2)
  • server.py:66-67 (registration)
    Registration of 'get_product' as an MCP tool via the @mcp.tool() decorator on FastMCP instance.
    @mcp.tool()
    def get_product(product_id: str) -> str:
  • Schema definition of the Product dataclass used by get_product. The handler calls product.to_dict() to serialize the matched product.
    @dataclass
    class Product:
        id: str
        name: str
        category: str
        brand: str
        price: float
        currency: str
        stock: int
        rating: float
        description: str
        tags: list[str]
    
        def to_dict(self) -> dict[str, Any]:
            return asdict(self)
  • The CATALOG data store containing all products. The get_product handler iterates over this list to find a product by ID.
    CATALOG: list[Product] = [
        Product(
            id="P001",
            name="Apple MacBook Pro 14-inch M3",
            category="Laptops",
            brand="Apple",
            price=1999.00,
            currency="USD",
            stock=42,
            rating=4.8,
            description="14-inch Liquid Retina XDR display, M3 chip, 18GB RAM, 512GB SSD.",
            tags=["laptop", "apple", "macbook", "m3", "professional", "portable"],
        ),
        Product(
            id="P002",
            name="Dell XPS 15 9530",
            category="Laptops",
            brand="Dell",
            price=1749.00,
            currency="USD",
            stock=18,
            rating=4.5,
            description="15.6-inch OLED display, Intel Core i7-13700H, 32GB RAM, 1TB SSD, RTX 4060.",
            tags=["laptop", "dell", "xps", "oled", "gaming", "professional"],
        ),
        Product(
            id="P003",
            name="Sony WH-1000XM5",
            category="Headphones",
            brand="Sony",
            price=349.99,
            currency="USD",
            stock=120,
            rating=4.9,
            description="Industry-leading noise cancelling wireless headphones with 30-hour battery life.",
            tags=["headphones", "sony", "wireless", "noise-cancelling", "audio"],
        ),
        Product(
            id="P004",
            name="Apple AirPods Pro 2nd Gen",
            category="Headphones",
            brand="Apple",
            price=249.00,
            currency="USD",
            stock=85,
            rating=4.7,
            description="Active noise cancellation, Transparency mode, Adaptive Audio, USB-C charging.",
            tags=["earbuds", "apple", "airpods", "wireless", "noise-cancelling", "audio"],
        ),
        Product(
            id="P005",
            name="Samsung Galaxy S24 Ultra",
            category="Smartphones",
            brand="Samsung",
            price=1299.99,
            currency="USD",
            stock=60,
            rating=4.6,
            description="6.8-inch Dynamic AMOLED 2X, Snapdragon 8 Gen 3, 200MP camera, S Pen included.",
            tags=["smartphone", "samsung", "galaxy", "android", "camera", "s-pen"],
        ),
        Product(
            id="P006",
            name="iPhone 16 Pro Max",
            category="Smartphones",
            brand="Apple",
            price=1199.00,
            currency="USD",
            stock=75,
            rating=4.8,
            description="6.9-inch Super Retina XDR, A18 Pro chip, 48MP Fusion camera, titanium design.",
            tags=["smartphone", "apple", "iphone", "ios", "camera", "titanium"],
        ),
        Product(
            id="P007",
            name="LG C3 55-inch OLED TV",
            category="TVs",
            brand="LG",
            price=1296.99,
            currency="USD",
            stock=30,
            rating=4.7,
            description="55-inch OLED evo panel, 4K 120Hz, Dolby Vision, webOS, perfect blacks.",
            tags=["tv", "lg", "oled", "4k", "120hz", "smart-tv", "dolby"],
        ),
        Product(
            id="P008",
            name="Logitech MX Master 3S",
            category="Mice",
            brand="Logitech",
            price=99.99,
            currency="USD",
            stock=200,
            rating=4.8,
            description="High-precision 8000 DPI sensor, ultra-fast MagSpeed scroll wheel, Bluetooth.",
            tags=["mouse", "logitech", "wireless", "ergonomic", "productivity"],
        ),
        Product(
            id="P009",
            name="Keychron K2 Pro Mechanical Keyboard",
            category="Keyboards",
            brand="Keychron",
            price=89.99,
            currency="USD",
            stock=150,
            rating=4.6,
            description="75% layout, hot-swappable, Bluetooth 5.1, RGB backlight, Mac/Windows.",
            tags=["keyboard", "keychron", "mechanical", "wireless", "rgb", "hot-swap"],
        ),
        Product(
            id="P010",
            name="Samsung 49-inch Odyssey G9 OLED",
            category="Monitors",
            brand="Samsung",
            price=1299.99,
            currency="USD",
            stock=15,
            rating=4.5,
            description="49-inch dual QHD OLED, 240Hz, 0.03ms response, G-Sync & FreeSync Premium Pro.",
            tags=["monitor", "samsung", "oled", "ultrawide", "gaming", "240hz"],
        ),
        Product(
            id="P011",
            name="iPad Pro 13-inch M4",
            category="Tablets",
            brand="Apple",
            price=1299.00,
            currency="USD",
            stock=55,
            rating=4.8,
            description="13-inch Ultra Retina XDR OLED, M4 chip, Apple Pencil Pro support, 5G.",
            tags=["tablet", "apple", "ipad", "m4", "oled", "5g", "apple-pencil"],
        ),
        Product(
            id="P012",
            name="Bose QuietComfort Ultra Earbuds",
            category="Headphones",
            brand="Bose",
            price=299.00,
            currency="USD",
            stock=90,
            rating=4.6,
            description="World-class noise cancellation, Immersive Audio, 6-hour battery, IPX4.",
            tags=["earbuds", "bose", "wireless", "noise-cancelling", "audio", "ipx4"],
        ),
    ]
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations exist; description implies read-only but fails to disclose any behavioral details beyond 'retrieve'.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise, front-loading the core purpose and listing the parameter clearly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the simple single-parameter input and presence of an output schema, the description is sufficiently complete for the task.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description adds meaning to the product_id parameter with an example and context, compensating for 0% schema coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states it retrieves full details for a single product by ID, distinguishing it from siblings like list_categories and search.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance on when to use this tool versus siblings like search or list_categories is provided.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/hwqlet/mcp-product-search'

If you have feedback or need assistance with the MCP directory API, please join our Discord server