Laboratory Inventory HTTP Server MCP Server

Local setup required. This server has to be cloned and prepared on your machine before you register it in Claude Code.
1

Set the server up locally

Run this once to clone and prepare the server before adding it to Claude Code.

Run in terminal
npm install
npm start
2

Register it in Claude Code

After the local setup is done, run this command to point Claude Code at the built server.

Run in terminal
claude mcp add -e "MONGODB_URI=${MONGODB_URI}" lab-inventory-server -- node "<FULL_PATH_TO_MCP>/dist/index.js"

Replace <FULL_PATH_TO_MCP>/dist/index.js with the actual folder you prepared in step 1.

Required:MONGODB_URI+ 1 optional
README.md

RESTful API to query laboratory inventory data from MongoDB

Laboratory Inventory HTTP Server

这是一个独立的 HTTP 服务器,用于提供实验室库存数据的 REST API 接口。通过 HTTP 端点查询 MongoDB 中的库存数据,可被任何 HTTP 客户端调用。

功能特性

RESTful API - 标准的 HTTP GET 端点,易于集成 ✅ Token 优化 - 只查询需要的数据,节省 80-98% 的 Token 消耗 ✅ MongoDB 集成 - 直接查询 MongoDB 数据库 ✅ 独立运行 - 不依赖主应用,可单独部署 ✅ 灵活查询 - 提供多种查询方式,支持按条件筛选

可用 API 端点

端点 描述 使用场景
GET /tools/inventory-summary 获取库存统计摘要 查看整体库存状况
GET /tools/expired-items 获取已过期耗材 查找过期耗材
GET /tools/expiring-items 获取即将过期耗材 查找快过期的耗材
GET /tools/low-stock-items 获取库存不足耗材 查找低库存耗材
GET /tools/out-of-stock-items 获取缺货耗材 查找缺货项目
GET /tools/search-inventory 根据关键词搜索耗材 搜索特定耗材
GET /tools/check-item 检查耗材可用性 查询特定耗材详情
GET /tools/purchase-suggestions 获取采购建议 获取采购推荐
GET /health 健康检查 检查服务状态

快速开始

1. 安装依赖

cd mcp
npm install

2. 配置环境变量

复制示例配置文件并修改:

# 复制示例配置文件
cp .env.example .env

# 编辑 .env 文件,设置你的 MongoDB 连接

.env 文件内容:

MONGODB_URI=mongodb://localhost:27017/test
PORT=3001

⚠️ 重要: .env 文件包含敏感信息,已在 .gitignore 中,不会提交到 git。

3. 启动服务器

npm start

服务器将在 http://localhost:3001 上运行(默认端口)。

HTTP API 使用指南

基础 URL

http://localhost:3001

端点详解

1. 获取库存统计摘要
GET /tools/inventory-summary?labName=<实验室名>

示例

curl "http://localhost:3001/tools/inventory-summary?labName=实验室A"

响应

{
  "success": true,
  "queryType": "summary",
  "data": {
    "totalItems": 128,
    "normalItems": 98,
    "expired": 5,
    "expiringSoon": 12,
    "lowStock": 8,
    "outOfStock": 5,
    "issueItems": [
      {
        "name": "胰蛋白酶",
        "quantity": 3,
        "minQuantity": 5,
        "expiryDate": "2024-03-15",
        "status": "库存不足"
      }
    ]
  }
}
2. 获取已过期耗材
GET /tools/expired-items?labName=<实验室名>&limit=5

示例

curl "http://localhost:3001/tools/expired-items?labName=实验室A&limit=10"

响应

{
  "success": true,
  "queryType": "expired",
  "count": 3,
  "items": [
    {
      "name": "PBS缓冲液",
      "quantity": 2,
      "expiryDate": "2024-01-15"
    }
  ]
}
3. 获取即将过期耗材
GET /tools/expiring-items?labName=<实验室名>&days=30&limit=10

参数

  • days: 天数范围(默认30天)
  • limit: 返回数量限制(默认10)

示例

curl "http://localhost:3001/tools/expiring-items?labName=实验室A&days=30&limit=10"

响应

{
  "success": true,
  "queryType": "expiring",
  "count": 5,
  "items": [
    {
      "name": "胎牛血清",
      "quantity": 8,
      "expiryDate": "2024-04-01",
      "daysLeft": 15
    }
  ]
}
4. 获取库存不足耗材
GET /tools/low-stock-items?labName=<实验室名>&limit=10

示例

curl "http://localhost:3001/tools/low-stock-items?labName=实验室A"

响应

{
  "success": true,
  "queryType": "low_stock",
  "count": 8,
  "items": [
    {
      "name": "胰蛋白酶",
      "current": 3,
      "min": 5,
      "deficit": 2
    }
  ]
}
5. 获取缺货耗材
GET /tools/out-of-stock-items?labName=<实验室名>&limit=5

示例

curl "http://localhost:3001/tools/out-of-stock-items?labName=实验室A"

响应

{
  "success": true,
  "queryType": "out_of_stock",
  "count": 5,
  "items": [
    {"name": "细胞培养板"}
  ]
}
6. 搜索库存
GET /tools/search-inventory?labName=<实验室名>&keyword=<关键词>&limit=5

参数

  • keyword: 搜索关键词(匹配名称、编码、规格)
  • limit: 返回数量限制(默认5)

示例

curl "http://localhost:3001/tools/search-inventory?labName=实验室A&keyword=胰蛋白"

响应

{
  "success": true,
  "queryType": "specific",
  "count": 2,
  "items": [
    {
      "name": "胰蛋白酶",
      "quantity": 3,
      "minQuantity": 5,
      "expiryDate": "2024-06-01",
      "status": "low_stock"
    }
  ]
}
7. 检查特定耗材
GET /tools/check-item?labName=<实验室名>&itemName=<耗材名>

示例

curl "http://localhost:3001/tools/check-item?labName=实验室A&itemName=胰蛋白酶"

响应

{
  "success": true,
  "found": true,
  "queryType": "check",
  "item": {
    "name": "胰蛋白酶",
    "quantity": 3,
    "minQuantity": 5,
    "expiryDate": "2024-06-01",
    "status": "low_stock",
    "statusMessage": "库存不足"
  }
}
8. 获取采购建议
GET /tools/purchase-suggestions?labName=<实验室名>

示例

curl "http://localhost:3001/tools/purchase-suggestions?labName=实验室A"

响应

{
  "success": true,
  "queryType": "purchase",
  "summary": {
    "totalItems": 128
  },
  "lowStock": [
    {
      "name": "胰蛋白酶",
      "current": 3,
      "min": 5,
      "deficit": 2
    }
  ],
  "expiringSoon": [
    {
      "name": "胎牛血清",
      "quantity": 8,
      "expiryDate": "2024-04-01",
      "daysLeft": 15
    }
  ]
}
9. 健康检查
GET /health

示例

curl "http://localhost:3001/health"

响应

{
  "status": "ok",
  "service": "MCP HTTP Server for Lab Inventory",
  "timestamp": "2024-03-11T08:00:00.000Z"
}

错误处理

所有端点在发

Tools (8)

inventory-summaryGet a summary of overall inventory status
expired-itemsRetrieve a list of expired laboratory items
expiring-itemsRetrieve a list of items nearing their expiration date
low-stock-itemsRetrieve a list of items with low stock levels
out-of-stock-itemsRetrieve a list of items that are currently out of stock
search-inventorySearch for specific items by keyword
check-itemCheck the availability and status of a specific item
purchase-suggestionsGet recommendations for items that need to be purchased

Environment Variables

MONGODB_URIrequiredThe connection string for the MongoDB database
PORTThe port number for the HTTP server

Configuration

claude_desktop_config.json
{ "mcpServers": { "lab-inventory": { "command": "node", "args": ["/path/to/mcp/index.js"], "env": { "MONGODB_URI": "mongodb://localhost:27017/test", "PORT": "3001" } } } }

Try it

Check the current inventory summary for Lab A and identify any critical stock issues.
List all laboratory items that are expiring within the next 30 days.
Search for '胰蛋白酶' in the inventory and check its current stock level.
Generate a list of purchase suggestions for Lab A based on current low stock and expiring items.

Frequently Asked Questions

What are the key features of Laboratory Inventory HTTP Server?

RESTful API endpoints for standard HTTP integration. Token-optimized data querying to reduce AI context usage. Direct integration with MongoDB databases. Independent deployment architecture. Flexible filtering for inventory status and expiration dates.

What can I use Laboratory Inventory HTTP Server for?

Automating laboratory supply replenishment by generating purchase suggestions. Monitoring expiration dates of sensitive chemical reagents. Quickly checking stock levels of specific lab consumables during experiments. Generating periodic inventory reports for laboratory management.

How do I install Laboratory Inventory HTTP Server?

Install Laboratory Inventory HTTP Server by running: npm install && npm start

What MCP clients work with Laboratory Inventory HTTP Server?

Laboratory Inventory HTTP Server works with any MCP-compatible client including Claude Desktop, Claude Code, Cursor, and other editors with MCP support.

Turn this server into reusable context

Keep Laboratory Inventory HTTP Server docs, env vars, and workflow notes in Conare so your agent carries them across sessions.

Need the old visual installer? Open Conare IDE.
Open Conare