在 Expo 中使用模型上下文协议(MCP)
关于将模型上下文协议与 Expo 项目集成以增强 AI 模型能力的指南。
信息 Expo MCP 服务器需要一个 EAS 付费计划。
模型上下文协议 (MCP) 是一种标准协议,允许 AI 模型与外部数据源集成,从而提供增强的上下文以获得更精确的响应。它使 AI 辅助工具(如智能代理)能够更深入地理解你的开发环境,从而更好地协助处理你的代码库。
Expo MCP 服务器是由 Expo 托管的远程 MCP 服务器,它可以与 Claude Code、Cursor、VS Code 等流行的 AI 辅助工具集成,使它们能够直接与你的 Expo 项目进行交互。
🌐 Expo MCP Server is a remote MCP server hosted by Expo that integrates with popular AI-assisted tools such as Claude Code, Cursor, VS Code, and others, enabling them to interact directly with your Expo projects.

使用 Expo 提升你的 AI 辅助应用构建工具。
Expo MCP 服务器是做什么的?
🌐 What does Expo MCP Server do?
Expo MCP 服务器可以向你的 AI 辅助工具传授 Expo SDK 的知识,并让它们与移动模拟器和 React Native 开发工具进行交互。以下是 Expo MCP 服务器增强的三种任务示例:
🌐 Expo MCP Server teaches your AI-assisted tools about the Expo SDK and lets them interact with mobile simulators and the React Native DevTools. These are three examples of the tasks Expo MCP Server enhances:
了解使用 Expo 开发。 你的 AI 辅助工具可以按需获取最新的官方 Expo 文档,并用它来回复如下提示信息:
- 将 AGENTS.md/CLAUDE.md 添加到我的项目中
- 我该如何使用 Expo Router?
- 在 Expo 文档中查找实现深度链接的方法
- Expo CNG是什么?
管理依赖。 Expo MCP 服务器会引导你安装我们推荐的软件包,并使用 npx expo install 安装已知的兼容版本。
- 添加带有基本 CRUD 操作的 SQLite
- 安装
expo-camera并教我如何拍照 - 添加
expo-notifications以启用推送通知
自动化视觉验证和测试。 多模态 AI 辅助工具可以在模拟器中截图并与正在运行的应用互动。Expo MCP 服务器通过在项目依赖中添加 expo-mcp 包来启用本地功能。
- 添加一个蓝色圆形视图,并确保它正确渲染
- 添加一个按钮,然后点击它以验证交互是否正常
- 添加一个点击会增加计数的按钮,并验证状态是否正确更新
你的 AI 辅助工具可以自主编写代码,捕捉截图以验证界面是否正确,测试交互,并修复发现的问题。
🌐 Your AI-assisted tools can autonomously write the code, capture screenshots to verify the UI is correct, test interactions, and fix issues they find.
MCP 功能 的完整表格记录了 Expo MCP 服务器为 AI 辅助工具提供的工具和提示。
🌐 The complete table of MCP capabilities documents the tools and prompts Expo MCP Server provides to AI-assisted tools.
先决条件
🌐 Prerequisites
在使用 Expo MCP 服务器之前,请确保你已:
🌐 Before using Expo MCP Server, ensure you have:
- 具有 EAS 付费计划的 Expo 账户
- 一个使用
npx create-expo-app@latest创建的 Expo 项目,或者安装了最新expo包版本的项目 - 支持远程MCP服务器的AI辅助工具(Claude Code、Cursor、VS Code等)
安装与设置
🌐 Installation and setup
1
安装 Expo MCP 服务器
🌐 Install Expo MCP Server
Expo MCP 服务器支持与各种 AI 辅助工具集成。使用下面的一般设置,或展开特定工具以获取详细说明:
🌐 Expo MCP Server supports integration with various AI-assisted tools. Use the general settings below or expand your specific tool for detailed instructions:
- 服务器类型:可串流 HTTP
- URL:
https://mcp.expo.dev/mcp - 身份验证:OAuth
Claude 代码设置
- claude mcp add --transport http expo-mcp https://mcp.expo.dev/mcp安装后,在你的 Claude Code 会话中运行 /mcp 以进行身份验证。
🌐 After installation, run /mcp in your Claude Code session to authenticate.
2
使用 Expo 进行身份验证
🌐 Authenticate with Expo
安装 MCP 服务器后,你需要使用以下两种方法之一进行身份验证:
🌐 After installing the MCP server, you'll need to authenticate using one of two methods:
访问令牌(推荐)
🌐 Access token (recommended)
从你的 Expo 账户生成一个个人访问令牌,并在 OAuth 流程中使用它。
🌐 Generate a Personal access token from your Expo account and use it during the OAuth flow.
- 要生成访问令牌,请在 EAS 仪表板中打开 访问令牌 设置页面。
- 在 个人访问令牌 下,点击 创建令牌。复制该令牌并在 OAuth 流程中使用。
证书
🌐 Credentials
使用你的 Expo 账户用户名和密码。在这种情况下,服务器将自动生成访问令牌。
🌐 Use your Expo account username and password. In this case, the server will generate an access token automatically.
3
设置本地功能(推荐)
🌐 Set up local capabilities (Recommended)
信息 本地功能仅在 SDK 54 及更高版本 中可用。
要获得完整的 MCP 体验,包括从 iOS 模拟器截图、打开开发者工具和自动化功能,请设置本地 Expo 开发服务器:
🌐 For the full MCP experience with advanced features like taking screenshots from your iOS Simulator, opening DevTools, and automation capabilities, set up a local Expo development server:
- cd /path/to/your-project# Install the expo-mcp package- npx expo install expo-mcp --dev# Ensure you are logged in to Expo CLI with the same account as the one used to# authenticate with the MCP server- npx expo whoami || npx expo login# Start the dev server with MCP capabilities- EXPO_UNSTABLE_MCP_SERVER=1 npx expo start重要 每当你启动或停止开发服务器时,你需要在 AI 辅助工具中 重新连接或重启 你的 MCP 服务器连接,以确保 AI 辅助工具获得更新的功能。
服务器能力与本地能力
🌐 Server capabilities versus local capabilities
Expo MCP 服务器根据你的设置提供两种类型的功能:
🌐 Expo MCP Server provides two types of capabilities depending on your setup:
服务器功能
🌐 Server capabilities
服务器功能只需通过远程 MCP 服务器连接即可使用,无需搭建本地开发服务器。generate_agents_md 工具就是服务器功能的一个示例。
🌐 Server capabilities are available with just the remote MCP server connection, without needing to set up a local development server. The generate_agents_md tool is an example of a server capability.
本地能力
🌐 Local capabilities
本地功能需要本地 Expo 开发服务器运行,并提供与本地开发环境交互的高级功能:
🌐 Local capabilities require a local Expo development server to be running and provide advanced features that interact with your local development environment:
- 自动化工具:截屏、点击视图、通过 testID 查找元素
- 开发工具:打开 React Native 开发工具
- 项目分析:生成
expo-router网站地图
这些功能使更复杂的工作流程成为可能,例如自动化测试、视觉验证和更深入的项目分析。要使用本地功能,你需要遵循上文的设置本地功能部分。
🌐 These capabilities enable more sophisticated workflows like automated testing, visual verification, and deeper project introspection. To use local capabilities, you will need to follow the Set up local capabilities section above.
可用的MCP功能
🌐 Available MCP capabilities
信息 MCP 的功能可能会随着
expo-mcp套件更新或 MCP 服务器的更改而变化。以下列表仅供参考,可能不是最新的。
工具
🌐 Tools
| Tool | Description | Example Prompt | Availability |
|---|---|---|---|
learn | Learn Expo how-to for a specific topic | "learn how to use expo-router" | Server |
search_documentation | Search from Expo documentation using natural language | "search documentation for CNG" | Server |
add_library | Install Expo packages with npx expo install and show documentation | "add sqlite and basic CRUD to the app" | Server |
generate_claude_md | Generate CLAUDE.md configuration files | "generate a CLAUDE.md for the project" | Server (Claude Code only) |
generate_agents_md | Generate AGENTS.md files | "generate an AGENTS.md file for the project" | Server |
build_info | Get details of a specific build | "get the status of my latest iOS build" | Server |
build_list | List builds for a project | "list the recent builds for this project" | Server |
build_logs | Fetch logs for a completed build | "show me the logs for the failed build" | Server |
build_run | Trigger a new build from a git reference | "run a production build for iOS" | Server |
build_cancel | Cancel a build that is queued or in progress | "cancel the build that is currently in progress" | Server |
build_submit | Submit a build to app stores | "submit the latest build to the App Store" | Server |
workflow_create | Create a new workflow YAML file and learn workflow syntax | "create a CI/CD workflow for building and deploying" | Server |
workflow_info | Get details of a specific workflow run | "get the status of the latest workflow run" | Server |
workflow_list | List recent workflow runs for a project | "list the recent workflow runs" | Server |
workflow_logs | Fetch logs for a specific job in an workflow run | "show me the logs for the build job in the workflow" | Server |
workflow_run | Trigger a workflow run from a git reference | "run the build-and-deploy workflow" | Server |
workflow_cancel | Cancel a running workflow | "cancel the running workflow" | Server |
workflow_validate | Validate workflow YAML syntax and configuration | "validate my workflow file" | Server |
expo_router_sitemap | Execute and display expo-router-sitemap output | "check the expo-router-sitemap output" | Local (requires expo-router library) |
open_devtools | Open React Native DevTools | "open devtools" | Local |
automation_tap | Tap at specific screen coordinates | "tap the screen at x=12, y=22" | Local |
automation_take_screenshot | Take full device screenshots | "take a screenshot and verify the blue circle view" | Local |
automation_find_view_by_testid | Find and analyze views by testID | "dump properties for testID 'button-123'" | Local |
automation_tap_by_testid | Tap views by testID | "click the view with testID 'button-123'" | Local |
automation_take_screenshot_by_testid | Screenshot specific views by testID | "screenshot the view with testID 'button-123'" | Local |
提示
🌐 Prompts
如果你的 AI 辅助工具支持 MCP 提示,你可能会看到额外的菜单选项,例如 Claude Code 中的斜杠命令:
🌐 If your AI-assisted tool supports MCP prompts, you may see additional menu options, such as slash commands in Claude Code:
| 工具 | 描述 | 可用性 |
|---|---|---|
expo_router_sitemap | 执行并显示 expo-router-sitemap 输出 | 本地(需要 expo-router 库) |
onboarding | 向 AI 显示 AGENTS.md 内容 | 服务器 |
局限性
🌐 Limitations
当前的实现存在以下限制:
🌐 The current implementation has the following limitations:
- 一次仅支持连接 单个开发服务器
- iOS 对本地功能的支持仅限于模拟器(尚不支持物理设备)
- iOS 对本地功能的支持仅在 macOS 主机上可用。
其他资源
🌐 Additional resources
了解有关 MCP 规范和协议详情的更多信息。