关于 INDIAN MEDICINES (MCP SERVER)
INDIAN MEDICINES 是一个 MCP 服务,可查询和分析来自所提供数据库的药品记录。它支持精确与模糊名称搜索、成分和价格筛选、成分分析及替代药品建议,适用于药品信息查询流程。
主要功能
- 01精确及模糊药品名称搜索
- 02按有效成分搜索
- 03按价格、厂商或处方要求筛选
- 04分析成分并比较相似药品
- 05建议替代药品并汇总数据库统计
适用场景
- 01按准确或拼写有误的名称查找药品
- 02比较成分相近药品的价格
- 03按厂商或处方状态筛选记录
MCP 相关
该服务通过 MCP 向客户端提供 15 个药品搜索、筛选、分析和实用功能端点。
配置
本地服务的配置在各客户端中通用,复制后粘贴到客户端的 MCP 配置文件即可。
我们还没有获取到这个服务的安装包或远程地址,请按项目 README 中的说明安装。
工具
本地服务需要在你的电脑上运行后才能读取工具,维护者暂未提供工具列表。
详细介绍
印度药品(MCP 服务)
一款全面的 API 服务,可用于查询药品信息、获取替代药品建议和分析药品成分。该服务提供多个端点,用于搜索、筛选和分析药品数据,并支持模糊匹配和价格比较等高级功能。
📖 目录
📋 简介
MedicineDB API 服务是一款高性能工具,旨在全面提供药品信息。它提供丰富的功能,既支持基本的药品查询,也支持高级的成分分析和替代药品建议。该服务能够高效处理大型数据集,同时提供准确且相关的结果。
✨ 功能
-
高级搜索功能
- 精确匹配和模糊匹配药品名称
- 基于成分/原料的搜索
- 支持分页的多条件筛选
- 按制造商和价格范围筛选
-
分析工具
- 成分字符串解析器和分析器
- 数据库统计分析
- 成分分类
-
医疗决策支持
- 替代药品建议
- 相似药品之间的价格比较
- 按处方要求筛选
-
性能优化
- 使用多个索引加快查询
- 高效的相似度计算
- 预先提取成分
🛠️ 技术栈
| 技术 | 用途 |
|---|---|
| 核心编程语言 | |
| 服务端框架 | |
| 数据存储格式 |
库:
difflib:用于模糊字符串匹配和药品名称相似度比较re:用于解析成分字符串和提取成分collections:用于优化数据结构(defaultdict、Counter)math:用于价格分桶和分页计算typing:用于类型提示dataclasses:用于结构化数据
🚀 安装
- 克隆仓库:
git clone https://github.com/yourusername/medicines-db.git
cd medicines-db
- 安装依赖:
pip install -r requirements.txt
- 准备药品数据库:
# Ensure your JSON data file is at the correct path
# Default path: /Users/siddharthbajpai/Downloads/MCP_SERVER/medicines.json
# Update DATA_PATH in the code if needed
- 运行服务:
python medicines_server.py
📘 使用方法
该服务通过 MCP(模型上下文协议)架构提供多个 API 端点。你可以使用任何 MCP 客户端与服务交互。
基本示例:
from mcp.client import MCPClient
# Connect to the server
client = MCPClient("medicines-db")
# Search for a medicine
result = client.search_medicines("paracetamol", max_results=5)
print(result)
# Get alternatives to a specific medicine
alternatives = client.suggest_alternatives("Dolo 650")
print(alternatives)
📚 API 参考
该服务通过 MCP 框架提供 15 个 API 端点:
搜索端点
1. get_medicine_by_name
GET /get_medicine_by_name
按药品的确切名称检索药品记录,并可选择包含更便宜的替代药品。
参数:
name(字符串,必需):药品的确切 Name 字段值include_alternatives(布尔值,可选,默认值=true):是否在结果中包含更便宜的替代药品
响应:
{
"medicine": {
"Name": "Dolo 650",
"Manufacturer": "Micro Labs Ltd",
"Composition": "Paracetamol (650mg)",
"MRP": "30.29",
"Prescription": "No",
"Price_INR": "₹30.29",
"Price_Category": "Low",
"Active_Ingredients": ["Paracetamol"],
"Ingredient_Count": 1,
"Is_Combination": false,
"Requires_Prescription": false,
"Prescription_Type": "Over-the-Counter"
},
"cheaper_alternatives": [
{
"medicine": {...},
"price_savings": "₹10.30",
"savings_percentage": "34.0%",
"similarity_score": "1.00"
}
]
}
2. search_medicines
GET /search_medicines
在所有药品字段中进行全文搜索。
参数:
query(字符串,必需):要搜索的子字符串(不区分大小写)max_results(整数,可选,默认值=10):要返回的匹配记录数量上限
响应:
[
{
"Name": "Dolo 650",
"Manufacturer": "Micro Labs Ltd",
"Composition": "Paracetamol (650mg)",
"MRP": "30.29",
"Price_INR": "₹30.29",
...
},
...
]
3. fuzzy_search_by_name
GET /fuzzy_search_by_name
使用模糊匹配,根据提供的部分名称搜索名称相似的药品。
参数:
partial_name(string,必填):要搜索的部分或拼写有误的药品名称similarity_threshold(number,可选,默认值=0.6):纳入结果的最低相似度分数(0.0-1.0)max_results(integer,可选,默认值=10):要返回的匹配记录数上限
响应:
[
{
"similarity_score": "0.92",
"medicine": {
"Name": "Dolo 650",
...
}
},
...
]
4. search_by_composition
GET /search_by_composition
搜索含有特定活性成分的药品。
参数:
ingredient(string,必填):要搜索的活性成分名称max_results(integer,可选,默认值=10):要返回的匹配记录数上限
响应:
[
{
"Name": "Dolo 650",
"Composition": "Paracetamol (650mg)",
...
},
...
]
筛选端点
5. filter_by_price_range
GET /filter_by_price_range
按价格范围筛选药品。
参数:
min_price(number,可选,默认值=0):最低价格,单位为 INRmax_price(number,可选,默认值=null):最高价格,单位为 INRmax_results(integer,可选,默认值=20):要返回的匹配记录数上限
响应:
[
{
"Name": "Crocin Pain Relief",
"MRP": "49.43",
"Price_INR": "₹49.43",
...
},
...
]
6. filter_by_manufacturer
GET /filter_by_manufacturer
按制造商筛选药品。
参数:
manufacturer(string,必填):制造商全名或部分名称max_results(integer,可选,默认值=20):要返回的匹配记录数上限
响应:
[
{
"Name": "Dolo 650",
"Manufacturer": "Micro Labs Ltd",
...
},
...
]
7. filter_by_prescription_requirement
GET /filter_by_prescription_requirement
按处方要求筛选药品。
参数:
prescription_required(boolean,必填):处方药为 True,非处方药为 Falsemax_results(integer,可选,默认值=20):要返回的匹配记录数上限
响应:
[
{
"Name": "Dolo 650",
"Prescription": "No",
"Requires_Prescription": false,
"Prescription_Type": "Over-the-Counter",
...
},
...
]
8. paginated_search
GET /paginated_search
支持分页和多个筛选条件的高级搜索。
参数:
query(string,可选,默认值=""):常规搜索词(搜索所有字段)page(integer,可选,默认值=1):页码(从 1 开始)page_size(integer,可选,默认值=10):每页结果数manufacturer(string,可选,默认值=""):按制造商筛选(全名或部分名称)min_price(number,可选,默认值=0):最低价格筛选条件max_price(number,可选,默认值=null):最高价格筛选条件prescription_required(boolean 或 null,可选,默认值=null):按处方要求筛选(null 表示不限)ingredient(string,可选,默认值=""):按活性成分筛选
响应:
{
"meta": {
"total_results": 150,
"page": 1,
"page_size": 10,
"total_pages": 15
},
"results": [
{
"Name": "Dolo 650",
...
},
...
]
}
分析端点
9. find_similar_medicines
GET /find_similar_medicines
查找成分与指定药品相似的药品。
参数:
medicine_name(string,必填):参考药品的名称max_results(integer,可选,默认值=5):要返回的相似药品数上限
响应:
{
"reference_medicine": {
"Name": "Dolo 650",
...
},
"similar_medicines": [
{
"similarity_score": "1.00",
"medicine": {
"Name": "Crocin Pain Relief",
...
}
},
...
]
}
10. analyze_composition
GET /analyze_composition
分析药品成分字符串,提取并整理其中的成分。
参数:
composition(string,必填):成分字符串(例如 "Ambroxol (30mg/5ml) + Levosalbutamol (1mg/5ml)")
响应:
{
"raw_composition": "Ambroxol (30mg/5ml) + Levosalbutamol (1mg/5ml)",
"ingredients": [
{
"raw_text": "Ambroxol (30mg/5ml)",
"name": "Ambroxol",
"dosage": "30mg/5ml",
"dosage_value": "30",
"dosage_unit": "mg"
},
{
"raw_text": "Levosalbutamol (1mg/5ml)",
"name": "Levosalbutamol",
"dosage": "1mg/5ml",
"dosage_value": "1",
"dosage_unit": "mg"
}
],
"medicines_with_this_composition": [
{
"Name": "Ascoril LS Syrup",
...
},
...
]
}
11. count_medicines_by_composition
GET /count_medicines_by_composition
统计并列出成分相同或含有特定成分的所有药品。
参数:
composition(string,必填):要搜索的成分组合或成分exact_match(boolean,可选,默认值=false):若为 True,仅查找成分组合完全相同的药品;若为 False,则查找含有该成分的药品。
响应:
{
"query": "Paracetamol",
"exact_match": false,
"total_medicines_found": 500,
"total_manufacturers": 25,
"price_statistics": {
"min_price": "₹10.50",
"max_price": "₹150.75",
"avg_price": "₹45.30",
"total_medicines_with_price": 490
},
"medicines": [...],
"by_manufacturer": {
"Cipla": {
"count": 50,
"medicines": [...]
},
...
}
}
12. categorize_medicines
GET /categorize_medicines
按活性成分对药品分类,并返回最常见的类别。
参数:
max_categories(integer,可选,默认值=10):要返回的类别数上限
响应:
[
{
"category": "Paracetamol",
"medicine_count": 500,
"example_medicines": [...]
},
{
"category": "Amoxicillin",
"medicine_count": 300,
"example_medicines": [...]
},
...
]
实用工具端点
13. get_medicine_statistics
GET /get_medicine_statistics
获取药品数据库的统计概览。
参数: 无
响应:
{
"total_medicines": 15000,
"prescription_count": 7500,
"otc_count": 7000,
"unknown_prescription_status": 500,
"manufacturer_counts": {
"Sun Pharma": 1200,
"Cipla": 900,
...
},
"price_distribution": {
"min_price": "₹1.50",
"max_price": "₹2500.00",
"avg_price": "₹125.45",
"price_ranges": {
"₹0 - ₹99.99": 5000,
"₹100 - ₹199.99": 4000,
...
}
},
"common_ingredients": {
"Paracetamol": 500,
"Amoxicillin": 300,
...
}
}
14. get_all_manufacturers
GET /get_all_manufacturers
获取数据库中所有制造商的列表。
参数: 无
响应:
[
{
"name": "Sun Pharma",
"medicine_count": 1200
},
{
"name": "Cipla",
"medicine_count": 900
},
...
]
15. suggest_alternatives
GET /suggest_alternatives
根据成分相似度和价格推荐替代药品。
参数:
medicine_name(string,必填):参考药品的名称max_suggestions(integer,可选,默认值=5):建议的替代药品数量上限
响应:
{
"reference_medicine": {
"Name": "Dolo 650",
"MRP": "30.29",
...
},
"alternatives": [
{
"medicine": {
"Name": "Calpol 650",
"MRP": "26.50",
...
},
"ingredient_similarity": 1.0,
"price_difference_percentage": -12.5,
"price_comparison": "cheaper",
"absolute_price_difference": 3.79
},
...
]
}
📊 数据结构
系统需要一个由药品对象组成的 JSON 数组,结构如下:
[
{
"Name": "Medicine Name",
"Manufacturer": "Company Name",
"Composition": "Ingredient1 (10mg) + Ingredient2 (20mg)",
"MRP": "123.45",
"Prescription": "Yes"
},
...
]
系统会使用额外计算的字段丰富这些数据:
Price_INR:带货币符号的格式化价格Price_Category:价格分类:低/中/高/高端Active_Ingredients:提取出的成分列表Ingredient_Count:活性成分数量Is_Combination:药品是否含有多种成分Requires_Prescription:是否需要处方的布尔值Prescription_Type:易于理解的处方状态
⚡ 性能优化
服务实现了多项优化:
-
多个索引,用于快速查找:
- 名称索引
- 制造商索引
- 成分索引
- 价格索引
- 处方索引
-
成分提取在启动时只执行一次,避免重复解析
-
相似度计算采用高效算法:
- 使用 SequenceMatcher 计算字符串相似度
- 使用 Jaccard 系数计算成分相似度
-
价格分桶,加快范围查询
🤝 参与贡献
欢迎贡献!以下是你可以提供帮助的方式:
- Fork 此仓库
- 创建功能分支(
git checkout -b feature/amazing-feature) - 提交更改(
git commit -m 'Add some amazing feature') - 将分支推送到远程仓库(
git push origin feature/amazing-feature) - 发起 Pull Request
请确保根据需要更新测试。
📄 许可证
本项目采用 MIT License,详情请参阅 LICENSE 文件。
评论
一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。