MCP Product Search Server

MCP Product Search Server

Enables product search functionality via MCP, allowing Claude to search products by keyword with filters, list categories, and retrieve product details.

Category
Visit Server

README

MCP Product Search Server

一个基于 Model Context Protocol (MCP) 的产品搜索服务器,让 Claude 能够根据关键词检索产品目录并返回结构化数据。

功能

提供三个工具供 Claude 调用:

工具 说明
search 按关键词搜索产品,支持分类、价格、评分过滤
list_categories 列出所有产品分类及数量
get_product 按 ID 查询单个产品的完整信息

快速开始

1. 克隆项目

git clone <your-repo-url>
cd mcp-product-search

2. 创建虚拟环境并安装依赖

macOS / Linux:

python3 -m venv .venv
source .venv/bin/activate
pip install "mcp[cli]"

Windows:

python -m venv .venv
.venv\Scripts\activate
pip install "mcp[cli]"

需要 Python 3.10 及以上版本。可用 python3 --version 检查。

3. 在浏览器中测试

mcp dev server.py

浏览器会自动打开 MCP Inspector。如果没有自动打开,手动访问终端输出的地址(通常是 http://localhost:6274)。

连接步骤:

  1. 将左侧 Command 改为虚拟环境中 Python 的绝对路径:
    • macOS/Linux:/绝对路径/mcp-product-search/.venv/bin/python
    • Windows:C:\绝对路径\mcp-product-search\.venv\Scripts\python.exe
  2. Argumentsserver.py
  3. 点击 Connect,左下角显示 Connected 即成功
  4. 点击顶部 Tools 标签,选择工具,填写参数,点击 Run Tool

MCP Inspector 连接成功示意

4. 接入 Claude Desktop

找到配置文件:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json

添加以下内容(替换为实际的绝对路径):

{
  "mcpServers": {
    "product-search": {
      "command": "/绝对路径/mcp-product-search/.venv/bin/python",
      "args": ["/绝对路径/mcp-product-search/server.py"]
    }
  }
}

查看当前目录的绝对路径:

# macOS / Linux
pwd

# Windows
cd

保存配置文件后,完全退出并重启 Claude Desktop

5. 接入 Claude Code(命令行)

claude mcp add product-search \
  /绝对路径/mcp-product-search/.venv/bin/python \
  /绝对路径/mcp-product-search/server.py

使用示例

接入 Claude 后,可以这样提问:

帮我搜索苹果品牌的笔记本电脑
找一款评分 4.8 以上、价格不超过 300 美元的耳机
列出所有产品分类
查询产品 P003 的详细信息

Claude 会自动判断调用哪个工具,并基于返回的结构化数据给出回答。

工具参数说明

search

参数 类型 必填 默认值 说明
keyword string 匹配产品名称、描述、品牌、分类和标签
category string 按分类过滤,如 "Laptops""Headphones"
max_price float 最高价格(USD)
min_rating float 最低评分(0–5)
limit int 10 返回结果数量上限(最多 50)

返回结果按评分从高到低、价格从低到高排序。

返回示例:

{
  "keyword": "apple",
  "filters": { "category": "Laptops", "max_price": null, "min_rating": null },
  "total_results": 1,
  "products": [
    {
      "id": "P001",
      "name": "Apple MacBook Pro 14-inch M3",
      "category": "Laptops",
      "brand": "Apple",
      "price": 1999.0,
      "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"]
    }
  ]
}

list_categories

无参数。返回所有分类名称及对应产品数量。

get_product

参数 类型 必填 说明
product_id string 产品 ID,如 "P001"(不区分大小写)

项目结构

mcp-product-search/
├── server.py        # MCP 服务器,定义工具
├── products.py      # 产品目录与搜索逻辑
├── pyproject.toml   # 项目依赖
└── README.md

扩展产品数据

当前产品目录是写在 products.py 中的 12 条示例数据,替换为真实数据只需修改 search_products() 函数,server.py 无需改动。

数据来源 改法
本地 JSON/CSV 启动时读文件填充 CATALOG
SQLite / PostgreSQL 用 SQL 查询替换遍历逻辑
电商 API 函数内部发 HTTP 请求
Elasticsearch 调用 ES 全文搜索接口

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured