Skip to content

Commit 46eb0ef

Browse files
authored
fix: refactor mcp servers into separate packages (#9061)
* refactor mcp server to be two separate servers * update README and docs * fix data loading * cleanup * improve structure * yarn.lock * update npx commands to use @latest
1 parent 66cbd63 commit 46eb0ef

27 files changed

+964
-700
lines changed

eslint.config.mjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ export default [{
5959
"packages/dev/parcel-transformer-storybook/*",
6060
"packages/dev/storybook-builder-parcel/*",
6161
"packages/dev/storybook-react-parcel/*",
62-
"packages/dev/s2-docs/pages/**"
62+
"packages/dev/s2-docs/pages/**",
63+
"packages/dev/mcp/*/dist"
6364
],
6465
}, ...compat.extends("eslint:recommended"), {
6566
plugins: {

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
"build:docs": "DOCS_ENV=staging parcel build 'packages/@react-{spectrum,aria,stately}/*/docs/*.mdx' 'packages/react-aria-components/docs/**/*.mdx' 'packages/@internationalized/*/docs/*.mdx' 'packages/dev/docs/pages/**/*.mdx'",
2828
"start:s2-docs": "yarn workspace @react-spectrum/s2-docs start",
2929
"build:s2-docs": "yarn workspace @react-spectrum/s2-docs build",
30-
"build:mcp": "yarn workspace @react-spectrum/mcp build",
31-
"start:mcp": "yarn workspace @react-spectrum/s2-docs generate:md && yarn workspace @react-spectrum/mcp build && node packages/dev/mcp/dist/index.js",
30+
"build:mcp": "yarn workspace @react-spectrum/mcp build && yarn workspace @react-aria/mcp build",
31+
"start:mcp": "yarn workspace @react-spectrum/s2-docs generate:md && yarn build:mcp && node packages/dev/mcp/s2/dist/index.js && node packages/dev/mcp/react-aria/dist/index.js",
3232
"test:mcp": "yarn build:s2-docs && yarn build:mcp && node packages/dev/mcp/scripts/smoke-list-pages.mjs",
3333
"test": "cross-env STRICT_MODE=1 VIRT_ON=1 yarn jest",
3434
"test:lint": "node packages/**/*.test-lint.js",
@@ -66,6 +66,8 @@
6666
"packages/react-aria",
6767
"packages/react-aria-components",
6868
"packages/tailwindcss-react-aria-components",
69+
"packages/dev/mcp/s2",
70+
"packages/dev/mcp/react-aria",
6971
"packages/*/*"
7072
],
7173
"devDependencies": {

packages/dev/mcp/README.md

Lines changed: 0 additions & 172 deletions
This file was deleted.
Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
# @react-aria/mcp
2+
3+
The `@react-aria/mcp` package provides a [Model Context Protocol (MCP)](https://modelcontextprotocol.io/docs/getting-started/intro) server for React Aria documentation. It exposes a set of tools that MCP clients can discover and call to browse the docs.
4+
5+
## Installation
6+
7+
### Quick Start
8+
9+
Simply run the server using npx:
10+
11+
```bash
12+
npx @react-aria/mcp@latest
13+
```
14+
15+
### Using with an MCP client
16+
17+
Add the server to your MCP client configuration (the exact file and schema may depend on your client).
18+
19+
```json
20+
{
21+
"mcpServers": {
22+
"React Aria": {
23+
"command": "npx",
24+
"args": ["@react-aria/mcp@latest"]
25+
}
26+
}
27+
}
28+
```
29+
30+
<details>
31+
<summary>Cursor</summary>
32+
33+
#### Click the button to install:
34+
35+
[![Install MCP Server](https://cursor.com/deeplink/mcp-install-dark.svg)](cursor://anysphere.cursor-deeplink/mcp/install?name=React%20Aria&config=eyJjb21tYW5kIjoibnB4IEByZWFjdC1hcmlhL21jcEBsYXRlc3QifQ%3D%3D)
36+
37+
Or follow the MCP install [guide](https://docs.cursor.com/en/context/mcp#installing-mcp-servers) and use the standard config above.
38+
39+
</details>
40+
41+
<details>
42+
<summary>VS Code</summary>
43+
44+
#### Click the button to install:
45+
46+
[<img src="https://img.shields.io/badge/VS_Code-VS_Code?style=flat-square&label=Install%20Server&color=0098FF" alt="Install in VS Code">](vscode:mcp/install?%7B%22name%22%3A%22React%20Aria%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22%40react-aria%2Fmcp%40latest%22%5D%7D)
47+
48+
#### Or install manually:
49+
50+
Follow the MCP install [guide](https://code.visualstudio.com/docs/copilot/chat/mcp-servers#_add-an-mcp-server) and use the standard config above. You can also add the server using the VS Code CLI:
51+
52+
```bash
53+
code --add-mcp '{"name":"React Aria","command":"npx","args":["@react-aria/mcp@latest"]}'
54+
```
55+
56+
</details>
57+
58+
<details>
59+
<summary>Claude Code</summary>
60+
61+
Use the Claude Code CLI to add the server:
62+
63+
```bash
64+
claude mcp add react-aria npx @react-aria/mcp@latest
65+
```
66+
For more information, see the [Claude Code MCP documentation](https://docs.claude.com/en/docs/claude-code/mcp).
67+
</details>
68+
69+
<details>
70+
<summary>Codex</summary>
71+
72+
Create or edit the configuration file `~/.codex/config.toml` and add:
73+
74+
```toml
75+
[mcp_servers.react-aria]
76+
command = "npx"
77+
args = ["@react-aria/mcp@latest"]
78+
```
79+
80+
For more information, see the [Codex MCP documentation](https://github.com/openai/codex/blob/main/docs/config.md#mcp_servers).
81+
82+
</details>
83+
84+
<details>
85+
<summary>Gemini CLI</summary>
86+
87+
Use the Gemini CLI to add the server:
88+
89+
```bash
90+
gemini mcp add react-aria npx @react-aria/mcp@latest
91+
```
92+
93+
For more information, see the [Gemini CLI MCP documentation](https://github.com/google-gemini/gemini-cli/blob/main/docs/tools/mcp-server.md#how-to-set-up-your-mcp-server).
94+
95+
</details>
96+
97+
<details>
98+
<summary>Windsurf</summary>
99+
100+
Follow Windsurf MCP [documentation](https://docs.windsurf.com/windsurf/cascade/mcp) and use the standard config above.
101+
102+
</details>
103+
104+
## Tools
105+
106+
| Tool | Input | Description |
107+
| --- | --- | --- |
108+
| `list_react_aria_pages` | `{ includeDescription?: boolean }` | List available pages in the React Aria docs. |
109+
| `get_react_aria_page_info` | `{ page_name: string }` | Return page description and list of section titles. |
110+
| `get_react_aria_page` | `{ page_name: string, section_name?: string }` | Return full page markdown, or only the specified section. |
111+
112+
## Development
113+
114+
### Testing locally
115+
116+
Build the docs and MCP server locally, then start the docs server.
117+
118+
```bash
119+
yarn workspace @react-spectrum/s2-docs generate:md
120+
yarn workspace @react-aria/mcp build
121+
yarn start:s2-docs
122+
```
123+
124+
Update your MCP client configuration to use the local MCP server:
125+
126+
```json
127+
{
128+
"mcpServers": {
129+
"React Aria": {
130+
"command": "node",
131+
"args": ["{your path here}/react-spectrum/packages/dev/mcp/react-aria/dist/index.js"],
132+
"env": {
133+
"DOCS_CDN_BASE": "http://localhost:1234"
134+
}
135+
}
136+
}
137+
}
138+
```
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"name": "@react-aria/mcp",
3+
"version": "0.1.0",
4+
"description": "MCP server for React Aria documentation",
5+
"type": "module",
6+
"bin": "dist/react-aria/src/index.js",
7+
"scripts": {
8+
"prepublishOnly": "yarn build",
9+
"build": "tsc -p tsconfig.json",
10+
"start": "node dist/react-aria/src/index.js",
11+
"dev": "node --enable-source-maps dist/react-aria/src/index.js"
12+
},
13+
"dependencies": {
14+
"@modelcontextprotocol/sdk": "^1.17.3",
15+
"@swc/helpers": "^0.5.0",
16+
"zod": "^3.23.8"
17+
},
18+
"devDependencies": {
19+
"typescript": "^5.8.2"
20+
},
21+
"engines": {
22+
"node": ">=18"
23+
},
24+
"license": "Apache-2.0",
25+
"publishConfig": {
26+
"access": "public"
27+
},
28+
"repository": {
29+
"type": "git",
30+
"url": "https://github.com/adobe/react-spectrum"
31+
},
32+
"files": [
33+
"dist",
34+
"src"
35+
],
36+
"sideEffects": false,
37+
"main": "dist/main.js",
38+
"module": "dist/module.js",
39+
"types": "dist/types.d.ts",
40+
"source": "src/index.ts"
41+
}

0 commit comments

Comments
 (0)