Skip to content

Commit 4f589d1

Browse files
authored
[docs] Improve MCP docs (#46557)
1 parent 082ce82 commit 4f589d1

File tree

1 file changed

+48
-126
lines changed
  • docs/data/material/getting-started/mcp

1 file changed

+48
-126
lines changed
Lines changed: 48 additions & 126 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,31 @@
11
# Model Context Protocol (MCP) for MUI
22

3-
<p class="description">Gain access to the official Material UI docs and code examples in your AI client.</p>
3+
<p class="description">Access the official Material UI docs and code examples in your AI client.</p>
44

55
## What is MCP?
66

7-
The Model Context Protocol (MCP) is a new open standard for connecting AI assistants to real, trusted sources of documentation and code.
7+
The Model Context Protocol (MCP) is an open standard for connecting AI assistants to real, trusted sources of documentation and code.
88
For Material UI users, this means you get answers that are accurate, up-to-date, and directly reference the official docs.
99

10-
Want to learn more about MCP?
11-
See the [official MCP documentation](https://modelcontextprotocol.io/introduction).
10+
To learn more about MCP, see the [official documentation](https://modelcontextprotocol.io/introduction).
1211

13-
## Why MCP?
12+
## Why use MCP?
1413

1514
Popular AI coding assistants are excellent at providing answers, especially to straightforward questions.
16-
However, when faced with a deeper, more complex question which requires understanding concepts from multiple parts of the documentation, they often hallucinate links, cite non-existent documentation, or provide answers that are hard to verify.
15+
But when faced with deeper, more complex questions that require understanding concepts from multiple parts of the documentation, they often hallucinate links, cite non-existent documentation, or provide answers that are hard to verify.
1716
MCP solves these problems by:
1817

19-
- Quoting **real, direct sources** in answers
20-
- Linking to **actual documentation** - no imaginary links that lead to 404s
18+
- Quoting real, direct sources in answers
19+
- Linking to actual documentationno imaginary links that lead to 404s
2120
- Using component code from officially published registries
2221

23-
## Installation & Setup
22+
## Installation and setup
2423

25-
The MCP is available as a separate package that runs locally and communicates via your AI client using the `stdio` transport.
26-
Use the following command to test the MCP in the [MCP inspector](https://modelcontextprotocol.io/docs/tools/inspector):
27-
28-
```bash
29-
npx -y @mui/mcp@latest
30-
```
24+
The sections below detail how to set up the Material UI MCP in popular IDEs.
3125

32-
### Cursor/Windsurf
26+
### VS Code, Cursor, Windsurf
3327

34-
1. Open MCP configuration in Windsurf ("Settings" -> "MCP" -> "Add Server")
35-
2. Add a new MCP:
28+
Open the MCP configuration (**Settings** -> **MCP** -> **Add Server**) and add the following:
3629

3730
```json
3831
"mcp": {
@@ -46,12 +39,7 @@ npx -y @mui/mcp@latest
4639
}
4740
```
4841

49-
### VS Code
50-
51-
Apart from the setup provided above, VS Code requires the following conditions to be met for the MCP to be usable:
52-
53-
1. Enable Agent mode (for Copilot Chat)
54-
2. Add the following to your `settings.json`:
42+
VS Code users must also enable Agent mode (for Copilot Chat) and add the following to `settings.json`:
5543

5644
```json
5745
"chat.mcp.enabled": true,
@@ -60,32 +48,28 @@ Apart from the setup provided above, VS Code requires the following conditions
6048

6149
### JetBrains IDEs
6250

63-
1. Open MCP configuration in your JetBrains IDE ("Settings" -> "Tools" -> "AI Assistant" -> "Model Context Protocol (MCP)")
64-
2. Add a new MCP:
51+
Open the MCP configuration (**Settings** -> **Tools** -> **AI Assistant** -> **Model Context Protocol (MCP)**) and add the following:
6552

6653
- Name: MUI MCP
6754
- Command: `npx`
6855
- Arguments: `-y @mui/mcp@latest`
6956

70-
3. Press "OK" and "Apply".
57+
Click **OK** and **Apply**.
7158

7259
### Zed
7360

74-
There are two ways you can add the Material UI MCP server in Zed:
61+
You can add the Material UI MCP server to Zed as an extension or as a custom server:
7562

7663
#### As an extension
7764

78-
Go to the Extensions page either via the keybinding `cmd-shift-x`/`ctrl-shift-x` (macOS/Linux), or via the Command Palette, searching for `zed: extensions`.
65+
Go to the Extensions page through the keybinding `cmd-shift-x`/`ctrl-shift-x` (macOS/Linux), or via the Command Palette by searching for `zed: extensions`.
7966

80-
Then, search for "MUI MCP" and install the extension.
81-
No configuration is required to have this server working, but you can optionally add the `preferred_theme` and `component_filter` fields.
67+
Search for "MUI MCP" and install the extension.
68+
No additional configuration is required, but you can optionally add the `preferred_theme` and `component_filter` fields.
8269

8370
#### As a custom server
8471

85-
This approach is essentially the same as adding it in VS Code and forks.
86-
87-
1. Search for `agent: add context server` in the Command Palette.
88-
2. Add the following JSON in the modal:
72+
Search for `agent: add context server` in the Command Palette and add the following:
8973

9074
```json
9175
{
@@ -99,116 +83,54 @@ This approach is essentially the same as adding it in VS Code and forks.
9983
}
10084
```
10185

102-
## Example
103-
104-
Here's a real-world comparison of how MCP helps you get answers that are accurate, up-to-date, and directly reference the official docs.
105-
106-
### Question
107-
108-
> I am using DataGrid Pro version and I am trying to use pinning and reordering in the same time.
109-
> I don't want the reorder handler to disappear when I have the row pinned.
110-
> I am using it for functionality with pagination so I can:
111-
>
112-
> Pin a row to the top,
113-
>
114-
> Move the pagination forwards or backwards,
115-
>
116-
> Drag into the new page row to change order on the different pages with a pinned row,
117-
>
118-
> However, when I'm trying to use GRID_REORDER_COL_DEF the renderCell is returning null for pinned rows.
119-
120-
### AI clients without MCP
121-
122-
> This is a known limitation in MUI DataGrid Pro: when a row is pinned, the default row reorder handler
123-
> (provided by GRID_REORDER_COL_DEF) is hidden for pinned rows, and the renderCell returns null.
124-
> This is by design to prevent reordering of pinned rows, but your use case requires both features together.
125-
>
126-
> To achieve your goal (showing the reorder handler for pinned rows and allowing cross-page drag-and-drop with pinned rows), you need to:
127-
>
128-
> Override the default renderCell of the reorder column to always render the reorder handler, even for pinned rows.
129-
> Implement custom logic to handle reordering, especially across pages and with pinned rows.
130-
>
131-
> Here's how you can proceed:
132-
>
133-
> Create a custom reorder column definition
134-
> Use your own renderCell that always renders the reorder handler, regardless of pinning
135-
> You can copy the default reorder handler from MUI source and adjust the logic as needed
136-
> Add this custom column to your columns array, replacing the default reorder column
137-
> Handle the row reordering logic in your onRowOrderChange callback
138-
>
139-
> Would you like a code example for a custom reorder column that works with pinned rows?
140-
> If yes, please specify if you're using TypeScript or JavaScript, and if you want the handler to be visible for both pinned and unpinned rows
141-
142-
### AI clients with MCP
143-
144-
> You are encountering this issue because, according to the official MUI DataGrid Pro documentation, row pinning and row reordering are not fully compatible.
145-
> Specifically:
146-
>
147-
> > "Pinned rows do not support the following features: selection, row grouping, tree data, row reordering, master detail..."
148-
>
149-
> When a row is pinned, the reorder handler (the drag handle) is intentionally not rendered for those rows.
150-
> This is why GRID_REORDER_COL_DEF's renderCell returns null for pinned rows.
151-
>
152-
> **Workarounds and Recommendations:**
153-
> You can still reorder non-pinned rows as usual
154-
> For pinned rows, implement a custom UI/UX (action buttons like "Move Up/Down" or "Unpin and Move" for example)
155-
> To move a pinned row to a different page, first unpin it, reorder, then pin it again
156-
>
157-
> **Summary:**
158-
> This is a current limitation of MUI DataGrid Pro.
159-
> The reorder handler is hidden for pinned rows by design.
160-
> You can upvote or comment on the related GitHub issues to help prioritize this feature.
161-
>
162-
> If you want a code example for a custom workaround, let me know!
163-
164-
<hr/>
165-
166-
The MCP-aided response is more coherent and directly references the documentation, building trust and enabling the user to be able to discover further details.
167-
168-
## FAQ
169-
170-
### I've installed the MCP, but there are errors in connection
171-
172-
Try and use the MCP inspector to debug the connection.
86+
## Common issues
87+
88+
### I've installed the MCP but there are errors in connection
89+
90+
Try using the MCP inspector to debug the connection.
17391
To do so, run:
17492

17593
```bash
17694
npx @modelcontextprotocol/inspector
17795
```
17896

179-
1. Wait till the terminal says: "🔍 MCP Inspector is up and running at http://127.0.0.1:6274".
180-
181-
1. Navigate to this URL in your browser
97+
Wait for the terminal to print "🔍 MCP Inspector is up and running at http://127.0.0.1:6274".
98+
Navigate to this URL in your browser and set the following paramters:
18299

183-
1. Choose "Transport type" as "Stdio"
100+
- **Transport type: Stdio**
101+
- **Command:**`npx`
102+
- **Arguments:** `y @mui/mcp@latest`
184103

185-
1. Set the "Command" to `npx`
104+
Click **Connect** and wait for the connection to be established.
186105

187-
1. Set the "Arguments" to `y @mui/mcp@latest`
106+
Once connected, you'll see a list of available tools.
107+
If you're not able to connect, check the logs in the terminal where you ran the MCP inspector for more details.
188108

189-
1. Click on "Connect"
109+
### I've installed the MCP but it's not being used when I ask questions
190110

191-
1. Wait for the connection to be established
192-
193-
The MCP should successfully connect, and you should see a list of available tools.
194-
If not, check the logs in the terminal where you ran the MCP inspector for more details
195-
196-
### I've installed the MCP, but it is not being used when I ask questions
197-
198-
If you've installed the MCP and enabled all the necessary settings, but it is not being used when you ask questions, you might need to supply rules to your AI client to use the MCP.
111+
If you've installed the MCP and enabled all the necessary settings but it's not being used when you ask questions, you might need to supply rules to your AI client to tell it to use the MCP.
199112

200113
Most editors allow you to specify rules for AI assistants to follow.
201-
Depending on the editor, the rules file might be specified in different locations.
202-
For VS Code, for instance, add the following to `.github/instructions/mui.md`:
114+
In VS Code, for instance, you can create a new rule at `.github/instructions/mui.md` and add the following:
203115

204116
```text
205117
## Use the mui-mcp server to answer any MUI questions --
206118
207119
- 1. call the "useMuiDocs" tool to fetch the docs of the package relevant in the question
208-
- 2. call the "fetchDocs" tool to fetch any additional docs if needed using ONLY the URLs
209-
present in the returned content.
120+
- 2. call the "fetchDocs" tool to fetch any additional docs if needed using ONLY the URLs present in the returned content.
210121
- 3. repeat steps 1-2 until you have fetched all relevant docs for the given question
211122
- 4. use the fetched content to answer the question
212123
```
213124

214-
You can use the same content as rules for whichever AI-enabled IDE you're using.
125+
:::info
126+
You can use this same text as a rule for any other IDE, but the preferred location for rules may differ.
127+
:::
128+
129+
## Troubleshooting
130+
131+
The MCP is available as a separate package that runs locally and communicates via your AI client using the `stdio` transport.
132+
Use the following command to test the MCP in the [MCP inspector](https://modelcontextprotocol.io/docs/tools/inspector):
133+
134+
```bash
135+
npx -y @mui/mcp@latest
136+
```

0 commit comments

Comments
 (0)