Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
b201c8a
wip: v1
bharatkashyap May 27, 2025
adb4f2d
fix: CI
bharatkashyap May 27, 2025
31e1bc1
fix: typo
bharatkashyap May 27, 2025
38bdeb7
fix: Ready for review
bharatkashyap May 29, 2025
c8d2cf5
fix: CI
bharatkashyap May 29, 2025
b0a2f50
Merge branch 'master' into mcp-docs
bharatkashyap May 29, 2025
d80cd3d
fix: review, CI
bharatkashyap May 29, 2025
8c9d2f5
Merge branch 'mcp-docs' of github.com:bharatkashyap/material-ui into …
bharatkashyap May 29, 2025
e8d6b90
fix: CI
bharatkashyap May 29, 2025
d320f36
fix: Vale CI
bharatkashyap May 29, 2025
dc6fd5c
fix: More vale
bharatkashyap Jun 2, 2025
dbba686
Merge branch 'master' into mcp-docs
bharatkashyap Jun 2, 2025
427f44b
fix: Generalise package name
bharatkashyap Jun 2, 2025
62c75c9
Merge branch 'mcp-docs' of github.com:bharatkashyap/material-ui into …
bharatkashyap Jun 2, 2025
dde6600
Merge branch 'master' into mcp-docs
bharatkashyap Jun 2, 2025
6db343b
Merge branch 'master' into mcp-docs
bharatkashyap Jun 2, 2025
5ad47b2
Merge branch 'master' into mcp-docs
bharatkashyap Jun 3, 2025
1b77cb4
fix: more cohesion
bharatkashyap Jun 3, 2025
4bee657
Merge branch 'mcp-docs' of github.com:bharatkashyap/material-ui into …
bharatkashyap Jun 3, 2025
25aecba
Merge branch 'master' into mcp-docs
bharatkashyap Jun 5, 2025
d2491f3
Update docs/data/material/pages.ts
bharatkashyap Jun 10, 2025
7e3eb05
Merge branch 'master' into mcp-docs
bharatkashyap Jun 10, 2025
8b43b5c
fix: More review
bharatkashyap Jun 10, 2025
298c3fd
Merge branch 'mcp-docs' of github.com:bharatkashyap/material-ui into …
bharatkashyap Jun 10, 2025
fec8492
Merge branch 'master' into mcp-docs
bharatkashyap Jun 13, 2025
5db2130
fix: Sam review
bharatkashyap Jun 13, 2025
027a260
Merge branch 'mcp-docs' of github.com:bharatkashyap/material-ui into …
bharatkashyap Jun 13, 2025
de1b6c5
Update docs/data/material/getting-started/mcp/mcp.md
bharatkashyap Jun 23, 2025
68959cc
Merge branch 'master' into mcp-docs
bharatkashyap Jun 23, 2025
cbc0c01
fix: Prettier
bharatkashyap Jun 23, 2025
b185eb7
Merge branch 'master' into mcp-docs
bharatkashyap Jun 23, 2025
664201e
fix: Vale
bharatkashyap Jun 23, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
203 changes: 203 additions & 0 deletions docs/data/material/getting-started/mcp/mcp.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,203 @@
# Model Context Protocol (MCP) for MUI

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

## What is MCP?

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

Want to learn more about MCP?
See the [official MCP documentation](https://modelcontextprotocol.io/introduction).

## Why MCP?

Popular AI coding assistants are excellent at providing answers, especially to straightforward questions.
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.
MCP solves these problems by:

- Quoting **real, direct sources** in answers
- Linking to **actual documentation** - no imaginary links that lead to 404s
- Using component code from officially published registries

## Installation & Setup

The MCP is available as a separate package that runs locally and communicates via your AI client using the `stdio` transport.
Use the following command to test the MCP in the [MCP inspector](https://modelcontextprotocol.io/docs/tools/inspector):

```bash
npx -y @mui/mcp@latest
```

### Cursor/Windsurf

1. Open MCP configuration in Windsurf ("Settings" -> "MCP" -> "Add Server")
2. Add a new MCP:

```json
"mcp": {
"servers": {
"mui-mcp": {
"type": "stdio",
"command": "npx",
"args": ["-y", "@mui/mcp@latest"]
}
}
}
```

### VS Code

Apart from the setup provided above, VS Code requires the following conditions to be met for the MCP to be usable:

1. Enable Agent mode (for Copilot Chat)
2. Add the following to your `settings.json`:

```json
"chat.mcp.enabled": true,
"chat.mcp.discovery.enabled": true
```

### Zed

There are two ways you can add the Material UI MCP server in Zed:

#### As an extension

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`.

Then, search for "MUI MCP" and install the extension.

Check warning on line 69 in docs/data/material/getting-started/mcp/mcp.md

View workflow job for this annotation

GitHub Actions / runner / vale

[vale] reported by reviewdog 🐶 [MUI.NoCompanyName] We avoid referencing the company name 'MUI MCP'. Instead you can reference a product or the team. Raw Output: {"message": "[MUI.NoCompanyName] We avoid referencing the company name 'MUI MCP'. Instead you can reference a product or the team.", "location": {"path": "docs/data/material/getting-started/mcp/mcp.md", "range": {"start": {"line": 69, "column": 19}}}, "severity": "WARNING"}
No configuration is required to have this server working, but you can optionally add the `preferred_theme` and `component_filter` fields.

#### As a custom server

This approach is essentially the same as adding it in VS Code and forks.

1. Search for `agent: add context server` in the Command Palette.
2. Add the following JSON in the modal:

```json
{
"mui-mcp-server": {
"command": {
"path": "npx",
"args": ["-y", "@mui/mcp@latest"]
"env": {}
}
}
}
```

## Example

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.

### Question

> I am using DataGrid Pro version and I am trying to use pinning and reordering in the same time.
> I don't want the reorder handler to disappear when I have the row pinned.
> I am using it for functionality with pagination so I can:

Check warning on line 99 in docs/data/material/getting-started/mcp/mcp.md

View workflow job for this annotation

GitHub Actions / runner / vale

[vale] reported by reviewdog 🐶 [Google.FirstPerson] Avoid first-person pronouns such as ' I '. Raw Output: {"message": "[Google.FirstPerson] Avoid first-person pronouns such as ' I '.", "location": {"path": "docs/data/material/getting-started/mcp/mcp.md", "range": {"start": {"line": 99, "column": 53}}}, "severity": "WARNING"}

Check warning on line 99 in docs/data/material/getting-started/mcp/mcp.md

View workflow job for this annotation

GitHub Actions / runner / vale

[vale] reported by reviewdog 🐶 [Google.FirstPerson] Avoid first-person pronouns such as 'I '. Raw Output: {"message": "[Google.FirstPerson] Avoid first-person pronouns such as 'I '.", "location": {"path": "docs/data/material/getting-started/mcp/mcp.md", "range": {"start": {"line": 99, "column": 3}}}, "severity": "WARNING"}
>
> Pin a row to the top,
>
> Move the pagination forwards or backwards,
>
> Drag into the new page row to change order on the different pages with a pinned row,
>
> However, when I'm trying to use GRID_REORDER_COL_DEF the renderCell is returning null for pinned rows.

Check warning on line 107 in docs/data/material/getting-started/mcp/mcp.md

View workflow job for this annotation

GitHub Actions / runner / vale

[vale] reported by reviewdog 🐶 [Google.FirstPerson] Avoid first-person pronouns such as 'I'm'. Raw Output: {"message": "[Google.FirstPerson] Avoid first-person pronouns such as 'I'm'.", "location": {"path": "docs/data/material/getting-started/mcp/mcp.md", "range": {"start": {"line": 107, "column": 17}}}, "severity": "WARNING"}

### AI clients without MCP

> This is a known limitation in MUI DataGrid Pro: when a row is pinned, the default row reorder handler

Check warning on line 111 in docs/data/material/getting-started/mcp/mcp.md

View workflow job for this annotation

GitHub Actions / runner / vale

[vale] reported by reviewdog 🐶 [MUI.NoCompanyName] We avoid referencing the company name 'MUI DataGrid'. Instead you can reference a product or the team. Raw Output: {"message": "[MUI.NoCompanyName] We avoid referencing the company name 'MUI DataGrid'. Instead you can reference a product or the team.", "location": {"path": "docs/data/material/getting-started/mcp/mcp.md", "range": {"start": {"line": 111, "column": 33}}}, "severity": "WARNING"}
> (provided by GRID_REORDER_COL_DEF) is hidden for pinned rows, and the renderCell returns null.
> This is by design to prevent reordering of pinned rows, but your use case requires both features together.
>
> To achieve your goal (showing the reorder handler for pinned rows and allowing cross-page drag-and-drop with pinned rows), you need to:
>
> Override the default renderCell of the reorder column to always render the reorder handler, even for pinned rows.
> Implement custom logic to handle reordering, especially across pages and with pinned rows.
>
> Here's how you can proceed:
>
> Create a custom reorder column definition
> Use your own renderCell that always renders the reorder handler, regardless of pinning
> You can copy the default reorder handler from MUI source and adjust the logic as needed

Check warning on line 124 in docs/data/material/getting-started/mcp/mcp.md

View workflow job for this annotation

GitHub Actions / runner / vale

[vale] reported by reviewdog 🐶 [MUI.NoCompanyName] We avoid referencing the company name 'MUI source'. Instead you can reference a product or the team. Raw Output: {"message": "[MUI.NoCompanyName] We avoid referencing the company name 'MUI source'. Instead you can reference a product or the team.", "location": {"path": "docs/data/material/getting-started/mcp/mcp.md", "range": {"start": {"line": 124, "column": 49}}}, "severity": "WARNING"}
> Add this custom column to your columns array, replacing the default reorder column
> Handle the row reordering logic in your onRowOrderChange callback
>
> Would you like a code example for a custom reorder column that works with pinned rows?
> 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

### AI clients with MCP

> You are encountering this issue because, according to the official MUI DataGrid Pro documentation, row pinning and row reordering are not fully compatible.

Check warning on line 133 in docs/data/material/getting-started/mcp/mcp.md

View workflow job for this annotation

GitHub Actions / runner / vale

[vale] reported by reviewdog 🐶 [MUI.NoCompanyName] We avoid referencing the company name 'MUI DataGrid'. Instead you can reference a product or the team. Raw Output: {"message": "[MUI.NoCompanyName] We avoid referencing the company name 'MUI DataGrid'. Instead you can reference a product or the team.", "location": {"path": "docs/data/material/getting-started/mcp/mcp.md", "range": {"start": {"line": 133, "column": 70}}}, "severity": "WARNING"}
> Specifically:
>
> > "Pinned rows do not support the following features: selection, row grouping, tree data, row reordering, master detail..."
>
> When a row is pinned, the reorder handler (the drag handle) is intentionally not rendered for those rows.
> This is why GRID_REORDER_COL_DEF's renderCell returns null for pinned rows.
>
> **Workarounds and Recommendations:**
> You can still reorder non-pinned rows as usual
> For pinned rows, implement a custom UI/UX (action buttons like "Move Up/Down" or "Unpin and Move" for example)
> To move a pinned row to a different page, first unpin it, reorder, then pin it again
>
> **Summary:**
> This is a current limitation of MUI DataGrid Pro.

Check warning on line 147 in docs/data/material/getting-started/mcp/mcp.md

View workflow job for this annotation

GitHub Actions / runner / vale

[vale] reported by reviewdog 🐶 [MUI.NoCompanyName] We avoid referencing the company name 'MUI DataGrid'. Instead you can reference a product or the team. Raw Output: {"message": "[MUI.NoCompanyName] We avoid referencing the company name 'MUI DataGrid'. Instead you can reference a product or the team.", "location": {"path": "docs/data/material/getting-started/mcp/mcp.md", "range": {"start": {"line": 147, "column": 35}}}, "severity": "WARNING"}
> The reorder handler is hidden for pinned rows by design.
> You can upvote or comment on the related GitHub issues to help prioritize this feature.
>
> If you want a code example for a custom workaround, let me know!

Check warning on line 151 in docs/data/material/getting-started/mcp/mcp.md

View workflow job for this annotation

GitHub Actions / runner / vale

[vale] reported by reviewdog 🐶 [Google.FirstPerson] Avoid first-person pronouns such as 'me'. Raw Output: {"message": "[Google.FirstPerson] Avoid first-person pronouns such as 'me'.", "location": {"path": "docs/data/material/getting-started/mcp/mcp.md", "range": {"start": {"line": 151, "column": 59}}}, "severity": "WARNING"}

<hr/>

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.

## FAQ

### I've installed the MCP, but there are errors in connection

Try and use the MCP inspector to debug the connection.
To do so, run:

```bash
npx @modelcontextprotocol/inspector
```

1. Wait till the terminal says: "🔍 MCP Inspector is up and running at http://127.0.0.1:6274".

1. Navigate to this URL in your browser

1. Choose "Transport type" as "Stdio"

1. Set the "Command" to `npx`

1. Set the "Arguments" to `y @mui/mcp@latest`

1. Click on "Connect"

1. Wait for the connection to be established

The MCP should successfully connect, and you should see a list of available tools.
If not, check the logs in the terminal where you ran the MCP inspector for more details

### I've installed the MCP, but it is not being used when I ask questions

Check warning on line 185 in docs/data/material/getting-started/mcp/mcp.md

View workflow job for this annotation

GitHub Actions / runner / vale

[vale] reported by reviewdog 🐶 [Google.FirstPerson] Avoid first-person pronouns such as ' I '. Raw Output: {"message": "[Google.FirstPerson] Avoid first-person pronouns such as ' I '.", "location": {"path": "docs/data/material/getting-started/mcp/mcp.md", "range": {"start": {"line": 185, "column": 58}}}, "severity": "WARNING"}

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.

Most editors allow you to specify rules for AI assistants to follow.
Depending on the editor, the rules file might be specified in different locations.
For VS Code, for instance, add the following to `.github/instructions/mui.md`:

```text
## Use the mui-mcp server to answer any MUI questions --

- 1. call the "useMuiDocs" tool to fetch the docs of the package relevant in the question
- 2. call the "fetchDocs" tool to fetch any additional docs if needed using ONLY the URLs
present in the returned content.
- 3. repeat steps 1-2 until you have fetched all relevant docs for the given question
- 4. use the fetched content to answer the question
```

You can use the same content as rules for whichever AI-enabled IDE you're using.
1 change: 1 addition & 0 deletions docs/data/material/pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const pages: MuiPage[] = [
{ pathname: '/material-ui/getting-started', title: 'Overview' },
{ pathname: '/material-ui/getting-started/installation' },
{ pathname: '/material-ui/getting-started/usage' },
{ pathname: '/material-ui/getting-started/mcp', newFeature: true, title: 'MCP' },
{ pathname: '/material-ui/getting-started/example-projects' },
{ pathname: '/material-ui/getting-started/templates' },
{ pathname: '/material-ui/getting-started/learn' },
Expand Down
7 changes: 7 additions & 0 deletions docs/pages/material-ui/getting-started/mcp.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import * as React from 'react';
import MarkdownDocs from 'docs/src/modules/components/MarkdownDocs';
import * as pageProps from 'docs/data/material/getting-started/mcp/mcp.md?muiMarkdown';

export default function Page() {
return <MarkdownDocs {...pageProps} />;
}
1 change: 1 addition & 0 deletions docs/translations/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"/material-ui/getting-started": "Overview",
"/material-ui/getting-started/installation": "Installation",
"/material-ui/getting-started/usage": "Usage",
"/material-ui/getting-started/mcp": "MCP",
"/material-ui/getting-started/example-projects": "Example projects",
"/material-ui/getting-started/templates": "Templates",
"/material-ui/getting-started/learn": "Learn",
Expand Down
Loading