React Native升级助手MCP服务器
一个模型上下文协议(MCP)服务器,用于自动化 React原生升级助手 网站,以提取React Native版本之间的升级信息。
它做什么
此MCP服务器使用Playwright自动执行以下操作:
- 在React Native Upgrade Helper表单中填写您的版本详细信息
- 提取全面的升级信息,包括文件差异
- 返回结构化JSON数据,AI助手可以使用这些数据来帮助React Native升级
安装
- 克隆和安装依赖关系:
git clone
cd react-native-upgrade-helper-mcp
npm install- 安装Playwright浏览器:
npx playwright install chromium- 构建项目:
npm run build配置
将此服务器添加到MCP客户端配置中:
克劳德代码
增添 ~/.config/claude-code/mcp_servers.json:
{
"mcpServers": {
"react-native-upgrade-helper": {
"command": "node",
"args": ["/absolute/path/to/react-native-upgrade-helper-mcp/dist/index.js"]
}
}
}克劳德桌面
增添 claude_desktop_config.json:
{
"mcpServers": {
"react-native-upgrade-helper": {
"command": "node",
"args": ["/absolute/path/to/react-native-upgrade-helper-mcp/dist/index.js"]
}
}
}光标
添加到MCP设置中:
{
"servers": {
"react-native-upgrade-helper": {
"command": "node",
"args": ["/absolute/path/to/react-native-upgrade-helper-mcp/dist/index.js"]
}
}
}重要提示: 替换 /absolute/path/to/react-native-upgrade-helper-mcp/ 带有此项目目录的实际绝对路径。
用法
服务器提供两个工具:
1. get_upgrade_info
获取React Native版本之间的全面升级信息。
参数:
fromVersion(必填):源代码React Native版本(例如“0.70.14”)toVersion(必填):目标React Native版本(例如“0.74.0”)packageName(可选):包名称(默认:“com.example.app”)projectName(可选):项目名称(默认值:“ExampleApp”)
例子:
@react-native-upgrade-helper get_upgrade_info fromVersion=0.70.14 toVersion=0.74.02. get_file_diff
获取升级的特定文件差异。
参数:
fromVersion(必填):源代码React Native版本toVersion(必填):目标React Native版本fileName(必填):获取diff的特定文件(例如“package.json”)packageName(可选):包名称(默认:“com.example.app”)projectName(可选):项目名称(默认值:“ExampleApp”)
例子:
@react-native-upgrade-helper get_file_diff fromVersion=0.70.14 toVersion=0.74.0 fileName=package.jsonAI提示示例
配置后,您可以询问您的AI助手:
- “帮助我将React Native应用程序从0.70.14升级到0.74.0。我需要做出哪些改变?"
- “显示升级到RN 0.74.0时package.json所需的具体更改”
- “从React Native 0.70升级到0.74时,有哪些突破性的变化?”
输出格式
get_upgrade_info 返回:
{
"fromVersion": "0.70.14",
"toVersion": "0.74.0",
"packageName": "com.example.app",
"projectName": "ExampleApp",
"url": "https://react-native-community.github.io/upgrade-helper/",
"summary": "Upgrade summary information",
"breakingChanges": ["Breaking change descriptions"],
"fileChanges": [
{
"fileName": "package.json",
"changeType": "modified",
"hasChanges": true,
"content": "diff content..."
}
],
"totalFiles": 15,
"modifiedFiles": 12,
"addedFiles": 2,
"deletedFiles": 1
}get_file_diff 返回:
{
"fromVersion": "0.70.14",
"toVersion": "0.74.0",
"fileName": "package.json",
"changeType": "modified",
"diff": "actual diff content...",
"found": true
}发展
# Run in development mode
npm run dev
# Build for production
npm run build
# Test the server manually
echo '{"jsonrpc": "2.0", "id": 1, "method": "tools/list", "params": {}}' | node dist/index.js故障排除
编剧问题: 确保安装了Chromium:
npx playwright install chromium权限错误: 确保脚本可执行:
chmod +x dist/index.js路径问题: 在MCP配置文件中始终使用绝对路径。
网络超时: 服务器等待页面加载15秒。对于较慢的连接,请在中修改超时 src/index.ts.
许可证
MIT许可证
