应用商店MCP服务器
⚠️ 实验状态:此MCP服务器是实验性的,按原样提供。目前没有计划进行修复或维护。您可以根据自己的需求对项目进行分叉和改进。
一个全面的Node.js TypeScript MCP(模型上下文协议)服务器,通过多种传输协议提供完整的应用商店抓取功能。此服务器与Google Play商店和Apple App Store抓取库集成,提供对所有可用抓取方法的完全访问,返回原始数据模型以保存完整信息。
特性
- 双重运输支持:实现MCP流式HTTP和SSE(服务器发送事件)传输协议
- 固定SSE传输:SSE传输现在包括自动MCP初始化,以防止客户端超时问题
- 全面覆盖:19个MCP工具,涵盖两个应用商店抓取库的所有可用功能
- 响应滤波:自动过滤详细字段(描述、摘要),将令牌使用量减少高达93%
- 原始数据模型:返回来自底层抓取库的完整、未修改的响应(当fullDetail=true时)
- 双平台支持:完全访问Google Play商店和Apple App Store数据
- TypeScript:完全类型安全和现代JavaScript功能
- Docker就绪:具有多阶段构建的容器化部署
- 生产就绪:全面的错误处理、日志记录和健康检查
- 速率限制:防止API滥用的内置保护
- 可配置的:基于环境的配置管理
- 传统兼容性:用于自动初始化的旧MCP客户端的SSE传输
快速开始
先决条件
- Node.js 18+
- npm或纱线
- Docker(可选,用于容器化部署)
安装
- 克隆存储库
git clone
cd app-store-mcp-server- 安装依赖项
npm install- 构建项目
npm run build- 启动服务器
npm start默认情况下,服务器将在端口3000上启动。您可以通过访问来验证它是否正在运行 http://localhost:3000/health.
Docker部署
- 使用Docker Compose构建和运行
docker-compose up --build- 或者手动构建和运行
docker build -t app-store-mcp-server .
docker run -p 3000:3000 app-store-mcp-server可用的MCP工具
服务器公开了19个全面的MCP工具,用于完整的应用商店数据访问:
Google Play商店工具(10个工具)
google-play-app-details-获取详细的应用程序信息,包括元数据、评级和描述google-play-app-reviews-使用分页和排序选项获取应用评论google-play-search-搜索应用程序(每个请求最多100个结果,无分页)google-play-list-从集合(TOP_FREE、TOP_PAID、NEW_FREE等)和类别(每个请求最多100个结果,无分页)中获取应用程序列表google-play-developer-使用分页功能获取特定开发人员的所有应用程序google-play-suggest-获取应用发现的搜索建议google-play-similar-查找与给定应用程序类似的应用程序google-play-permissions-获取详细的应用程序权限信息google-play-datasafety-获取应用程序数据安全和隐私信息google-play-categories-获取可用应用类别列表
苹果应用商店工具(9个工具)
app-store-app-details-获取详细的应用程序信息,包括元数据、评级和描述app-store-app-reviews-使用分页和排序选项获取应用评论app-store-search-搜索应用程序(每个请求最多100个结果,无分页)app-store-list-从集合和类别中获取应用程序列表(每个请求最多100个结果,无分页)app-store-developer-获取特定开发人员的所有应用程序app-store-privacy-获取详细的应用程序隐私信息和政策app-store-suggest-获取应用发现的搜索建议app-store-similar-查找与给定应用程序类似的应用程序app-store-ratings-获取详细的评级细分和统计数据
所有工具都从底层抓取库返回原始、未修改的数据,以保留完整的信息和元数据。
工具配置
MCP服务器支持通过环境变量选择性启用/禁用工具,允许您:
- 通过禁用未使用的工具减少内存使用
- 出于安全原因限制暴露的功能
- 仅使用特定工具创建专门的部署
- 通过隔离特定工具调试问题
配置方法
1.批量配置
禁用多个工具:
# Disable specific tools (comma-separated)
DISABLED_TOOLS=google-play-app-reviews,app-store-app-reviews,google-play-permissions仅启用特定工具:
# Enable only these tools (all others will be disabled)
ENABLED_TOOLS=google-play-search,app-store-search,google-play-app-details,app-store-app-details2.单独工具控制
# Disable individual tools
DISABLE_TOOL_GOOGLE_PLAY_SEARCH=true
DISABLE_TOOL_APP_STORE_REVIEWS=true
# Enable individual tools (when using restrictive ENABLED_TOOLS)
ENABLE_TOOL_GOOGLE_PLAY_APP_DETAILS=true3.Docker编写配置
services:
app-store-mcp-server:
environment:
# Disable review tools
- DISABLED_TOOLS=google-play-app-reviews,app-store-app-reviews
# Or enable only search and details tools
# - ENABLED_TOOLS=google-play-search,app-store-search,google-play-app-details,app-store-app-details
# Individual controls
- DISABLE_TOOL_GOOGLE_PLAY_PERMISSIONS=true配置助手
使用附带的配置助手脚本生成工具配置:
# List all available tools
node scripts/configure-tools.js list
# Generate configuration for specific tools
node scripts/configure-tools.js enable google-play-search app-store-search
# Generate configuration by category
node scripts/configure-tools.js category search
# Use presets for common configurations
node scripts/configure-tools.js preset search-only
node scripts/configure-tools.js preset no-reviews
node scripts/configure-tools.js preset core常见用例
- 仅搜索:
ENABLED_TOOLS=google-play-search,app-store-search - 没有评论:
DISABLED_TOOLS=google-play-app-reviews,app-store-app-reviews - 仅限Google Play:全部禁用
app-store-*工具 - 核心工具:
ENABLED_TOOLS=google-play-search,app-store-search,google-play-app-details,app-store-app-details
有关详细的配置文档,请参阅 工具配置.md.
有关响应筛选和令牌使用优化的信息,请参阅 响应_过滤.md.
本地化和区域支持
MCP工具通过可选参数支持本地化和区域定制:
语言支持(Google Play商店)
- 参数:
lang(可选) - 格式:ISO 639-1双字母小写语言代码(例如“en”、“fr”、“es”、“de”)
- 默认:'en'(英语)
- 支持的工具:所有检索内容的Google Play商店工具
国家/地区支持(两家店)
- 参数:
country(可选) - 格式:ISO 3166-1 alpha-2两个字母的小写国家代码(例如“us”、“ca”、“gb”、“fr”)
- 默认:“我们”(美国)
- 支持的工具:来自两个应用商店的大多数工具
使用示例
// Google Play app details with French language and Canadian region
{
"jsonrpc": "2.0",
"id": "1",
"method": "tools/call",
"params": {
"name": "google-play-app-details",
"arguments": {
"appId": "com.whatsapp",
"lang": "fr",
"country": "ca"
}
}
}
// App Store app reviews with Canadian region
{
"jsonrpc": "2.0",
"id": "2",
"method": "tools/call",
"params": {
"name": "app-store-app-reviews",
"arguments": {
"appId": "310633997",
"country": "ca",
"page": 1
}
}
}参数验证
- 使用正则表达式模式验证语言和国家代码
- 无效代码返回描述性错误消息
- 参数是可选的,向后兼容
配置
可以使用环境变量配置服务器:
核心设置
PORT-服务器端口(默认值:3000)LOG_LEVEL-日志记录级别:调试、信息、警告、错误(默认值:信息)NODE_ENV-环境:开发、生产、测试(默认:开发)
速率限制
RATE_LIMIT_WINDOW_MS-速率限制窗口(毫秒)(默认值:900000-15分钟)RATE_LIMIT_MAX_REQUESTS-每个窗口的最大请求数(默认值:100)
报废配置
SCRAPING_TIMEOUT-请求超时(毫秒)(默认值:30000)SCRAPING_RETRIES-重试次数(默认值:3)
传输配置
ENABLE_HTTP_TRANSPORT-启用HTTP传输(默认值:true)ENABLE_SSE_TRANSPORT-启用SSE传输(默认值:true)SSE_HEARTBEAT_INTERVAL-SSE心跳间隔(毫秒)(默认值:30000)SSE_CONNECTION_TIMEOUT-SSE连接超时(毫秒)(默认值:300000)SSE_MAX_CONNECTIONS-最大并发SSE连接数(默认值:100)SSE_AUTO_INITIALIZE-为SSE连接启用自动MCP初始化(默认值:true)SSE_INITIALIZATION_TIMEOUT-SSE初始化超时(毫秒)(默认值:5000)
CORS与安全
CORS_ORIGINS-允许的CORS源,逗号分隔(默认值:\*)REQUEST_TIMEOUT-HTTP请求超时(毫秒)(默认值:60000)ENABLE_LOGGING-启用请求日志记录(默认值:true)
HTTPS配置
HTTPS_ENABLED-启用HTTPS/SSL支持(默认值:false)HTTPS_KEY_PATH-SSL私钥文件的路径(如果启用HTTPS,则需要)HTTPS_CERT_PATH-SSL证书文件的路径(如果启用HTTPS,则需要)HTTPS_CA_PATH-证书颁发机构文件的路径(可选)HTTPS_PASSPHRASE-私钥密码(可选)
工具配置
ENABLED_TOOLS-以逗号分隔的要启用的工具列表(如果设置,则仅启用这些工具)DISABLED_TOOLS-以逗号分隔的禁用工具列表ENABLE_TOOL_-启用特定工具(例如。,ENABLE_TOOL_GOOGLE_PLAY_SEARCH=true)DISABLE_TOOL_-禁用特定工具(例如。,DISABLE_TOOL_APP_STORE_REVIEWS=true)
配置示例
创建一个 .env 文件:
PORT=3000
LOG_LEVEL=info
RATE_LIMIT_WINDOW_MS=900000
RATE_LIMIT_MAX_REQUESTS=100
SCRAPING_TIMEOUT=30000
SCRAPING_RETRIES=3
CORS_ORIGINS=http://localhost:3000,https://yourdomain.com
# HTTPS Configuration (optional)
HTTPS_ENABLED=true
HTTPS_KEY_PATH=./ssl/server.key
HTTPS_CERT_PATH=./ssl/server.crt
# Tool Configuration (optional)
# DISABLED_TOOLS=google-play-app-reviews,app-store-app-reviews
# ENABLED_TOOLS=google-play-search,app-store-search,google-play-app-details,app-store-app-detailsHTTPS设置
MCP服务器支持HTTPS以实现安全连接。您可以通过两种方式启用HTTPS:
选项1:生成自签名证书(开发)
对于开发和测试,您可以生成自签名证书:
# Generate SSL certificates (creates ssl/ directory, not tracked in git)
./scripts/generate-ssl-certs.sh
# Enable HTTPS with generated certificates
export HTTPS_ENABLED=true
export HTTPS_KEY_PATH=./ssl/server.key
export HTTPS_CERT_PATH=./ssl/server.crt
# Start the server
npm start选项2:使用生产证书
对于生产部署,请使用来自受信任的证书颁发机构的证书:
# Set environment variables for your production certificates
export HTTPS_ENABLED=true
export HTTPS_KEY_PATH=/path/to/your/private.key
export HTTPS_CERT_PATH=/path/to/your/certificate.crt
export HTTPS_CA_PATH=/path/to/your/ca-bundle.crt # Optional
# If your private key has a passphrase
export HTTPS_PASSPHRASE=your_passphrase
# Start the server
npm startHTTPS客户端配置
使用HTTPS时,更新MCP客户端配置以使用 https:// 网址:
{
"mcpServers": {
"app-store-secure": {
"transport": "http",
"url": "https://your-domain.com/mcp",
"timeout": 60000
}
}
}备注:对于自签名证书,客户端可能需要禁用证书验证或将证书添加到其信任存储中。
发展
脚本
npm run dev-使用热重新加载启动开发服务器npm run build-将TypeScript构建为JavaScriptnpm run test-运行所有测试npm run test:unit-仅运行单元测试npm run test:integration-运行集成测试npm run test:coverage-使用覆盖率报告运行测试npm run lint-运行ESLint
项目结构
src/
├── config/ # Configuration management
├── errors/ # Error handling utilities
├── protocol/ # MCP protocol implementation
├── registry/ # Tool registry management
├── services/ # App store scraper services
├── tools/ # MCP tool implementations
├── transport/ # HTTP transport layer
├── types/ # TypeScript type definitions
├── utils/ # Utility functions
├── index.ts # Application entry point
└── server.ts # Main server class
tests/
├── integration/ # Integration tests
├── unit/ # Unit tests by component
└── fixtures/ # Test data and mocks添加新工具
- 创建一个新的工具类,实现
MCPTool接口 - 在中注册该工具
src/server.ts - 添加综合测试
- 更新文档
运输用途
HTTP传输(推荐)
HTTP传输为现代MCP客户端使用MCP Streamable HTTP协议:
# MCP endpoint
POST http://localhost:3000/mcp
# Health check
GET http://localhost:3000/healthSSE传输(增强兼容性)
SSE传输提供了与MCP客户端的兼容性,包括 自动MCP初始化 具有增强的客户端兼容性功能:
# Establish SSE connection
GET http://localhost:3000/sse
# Send MCP messages to specific connection
POST http://localhost:3000/sse/{connectionId}/message主要特点
- 自动初始化:服务器在连接时自动发送MCP初始化消息
- 防止超时:消除握手过程中的客户端超时问题
- 标准MCP兼容性:无需修改即可使用现有的MCP客户端库
- 请求排队:将传入请求排队,直到初始化完成
- 综合录井:用于解决连接问题的详细日志记录
SSE连接示例
// Establish SSE connection
const eventSource = new EventSource('http://localhost:3000/sse');
eventSource.onopen = function(event) {
console.log('SSE connection established');
};
eventSource.addEventListener('connection', function(event) {
const data = JSON.parse(event.data);
console.log('Connection ID:', data.connectionId);
window.sseConnectionId = data.connectionId;
});
// Handle automatic initialization response
eventSource.addEventListener('mcp-response', function(event) {
const response = JSON.parse(event.data);
if (response.result && response.result.serverInfo) {
console.log('MCP initialization complete:', response.result.serverInfo);
console.log('Server capabilities:', response.result.capabilities);
// Now ready to send MCP requests
sendToolRequest();
} else {
console.log('MCP Response:', response);
}
});
eventSource.addEventListener('heartbeat', function(event) {
const data = JSON.parse(event.data);
console.log('Heartbeat received:', data.timestamp);
});
// Send MCP request after initialization
function sendToolRequest() {
fetch(`http://localhost:3000/sse/${window.sseConnectionId}/message`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
jsonrpc: '2.0',
id: '1',
method: 'tools/call',
params: {
name: 'google-play-app-details',
arguments: { appId: 'com.whatsapp' }
}
})
});
}SSE配置选项
SSE传输可以配置以下环境变量:
# SSE Transport Configuration
SSE_AUTO_INITIALIZE=true # Enable automatic initialization (default: true)
SSE_INITIALIZATION_TIMEOUT=5000 # Initialization timeout in ms (default: 5000)
SSE_HEARTBEAT_INTERVAL=30000 # Heartbeat interval in ms (default: 30000)
SSE_CONNECTION_TIMEOUT=300000 # Connection timeout in ms (default: 300000)
SSE_MAX_CONNECTIONS=100 # Maximum concurrent connections (default: 100)MCP客户端设置
要将Cursor或Windsurf等MCP客户端连接到此服务器,请参阅 MCP_CLIENT_SETUP.md.
API文档
有关API的详细文档,包括请求/响应示例,请参阅 API毫米.
故障排除
有关常见问题和解决方案,请参阅 故障排除.md.
Docker文档
有关Docker部署的详细说明,请参阅 医生.md.
贡献
- 分叉存储库
- 创建要素分支
- 进行更改
- 添加测试
- 运行测试套件
- 提交拉取请求
许可证
MIT许可证-请参阅 许可证 了解详情。
额外资源
应用商店优化(ASO)指南
这 docs/aso/ 目录包含手动App Store优化的全面指南:
appstore_keywords.md-高级iOS App Store关键字优化指南playstore_keywords.md-逐步优化Google Play商店关键字appstore_page.md-iOS应用商店页面优化策略playstore_page.md-Google Play商店列表优化guide_traffic_difficulty.md-流量分析和关键字难度评估
这些指南通过提供使用您可以通过服务器工具收集的数据优化应用商店列表的策略来补充MCP服务器。
支持
- 为错误报告或功能请求创建问题
- 在创建新问题之前检查现有问题
- 提供详细信息,包括日志和配置
