-
Notifications
You must be signed in to change notification settings - Fork 625
feat: add mcp package #6222
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
feat: add mcp package #6222
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
26cc41a
feat: add mcp package
joshblack f3a85b3
Merge branch 'main' of github.com:primer/react into feat/add-mcp-server
joshblack 631ab30
chore: cleanup before pull requeswt
joshblack de04339
chore: update lockfile
joshblack 1119e58
chore: fix eslint errors
joshblack 697c270
chore: update build order
joshblack a5319dc
Merge branch 'main' of github.com:primer/react into feat/add-mcp-server
joshblack c4fa4eb
feat: add support for token tool
joshblack a207920
Merge branch 'main' of github.com:primer/react into feat/add-mcp-server
joshblack 9a8a0b5
chore: add eslint disables
joshblack 56e66ec
chore(deps): update mcp package deps
joshblack 25d409a
Update packages/mcp/src/server.ts
joshblack 99db951
Update packages/mcp/src/server.ts
joshblack 08f65eb
chore: add accessibility and guidelines tools for components
joshblack 9f60fef
docs: update readme links
joshblack File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# @primer/mcp | ||
|
||
> The Primer MCP server connects AI tools to Primer's design system. It provides | ||
> tools for AI agents to connect with design tokens, components, patterns, and | ||
> more. | ||
|
||
## Getting started | ||
|
||
[](https://insiders.vscode.dev/redirect/mcp/install?name=Primer+MCP&config=%7B%22type%22%3A%22stdio%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22%40primer%2Fmcp%40latest%22%5D%7D) [](https://insiders.vscode.dev/redirect/mcp/install?name=Primer+MCP&config=%7B%22type%22%3A%22stdio%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22%40primer%2Fmcp%40latest%22%5D%7D&quality=insiders) | ||
|
||
The `@primer/mcp` package provides a server that can be run in your local | ||
development environment or can be setup in tools like GitHub Actions to be used | ||
by AI agents. | ||
|
||
### VS Code | ||
|
||
To use `@primer/mcp` in VS Code, you can use the button in the section above or | ||
follow these steps: | ||
|
||
1. Open the Command Palette (Cmd/Ctrl + Shift + P) | ||
2. Type `MCP: Install Server` and select it | ||
3. Select the `stdio` type | ||
4. Enter in the following command: `npx @primer/mcp@latest` | ||
5. Enter the name `Primer MCP` for the server | ||
|
||
Your MCP servers configuration should look like: | ||
|
||
```json | ||
{ | ||
"servers": { | ||
"Primer MCP": { | ||
"type": "stdio", | ||
"command": "npx", | ||
"args": ["@primer/mcp@latest"] | ||
} | ||
}, | ||
"inputs": [] | ||
} | ||
``` | ||
|
||
## 🙌 Contributing | ||
|
||
We love collaborating with folks inside and outside of GitHub and welcome contributions! If you're interested, check out our [contributing docs](contributor-docs/CONTRIBUTING.md) for more info on how to get started. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
{ | ||
"name": "@primer/mcp", | ||
"version": "0.0.0", | ||
"private": true, | ||
"type": "module", | ||
"bin": "./dist/stdio.js", | ||
"exports": { | ||
"./transports/stdio": { | ||
"types": "./dist/transports/stdio.d.ts", | ||
"default": "./dist/stdio.js" | ||
} | ||
}, | ||
"files": [ | ||
"dist", | ||
"src", | ||
"README.md" | ||
], | ||
"scripts": { | ||
"clean": "rimraf dist", | ||
"build": "rollup -c", | ||
"type-check": "tsc --noEmit", | ||
"watch": "rollup -c -w" | ||
}, | ||
"dependencies": { | ||
"@babel/runtime": "^7.27.0", | ||
"@modelcontextprotocol/sdk": "^1.12.0", | ||
"@primer/primitives": "10.x || 11.x", | ||
"@primer/react": "^37.24.0", | ||
"cheerio": "^1.0.0", | ||
"turndown": "^7.2.0", | ||
"zod": "^3.23.8" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "^7.27.1", | ||
"@babel/plugin-transform-runtime": "^7.27.1", | ||
"@babel/preset-env": "^7.27.2", | ||
"@babel/preset-typescript": "^7.27.1", | ||
"@modelcontextprotocol/inspector": "^0.13.0", | ||
"@rollup/plugin-babel": "^6.0.4", | ||
"@rollup/plugin-commonjs": "^25.0.8", | ||
"@rollup/plugin-json": "^6.1.0", | ||
"@rollup/plugin-node-resolve": "^15.2.3", | ||
"@types/turndown": "^5.0.5", | ||
"rimraf": "^6.0.1", | ||
"rollup": "^4.30.1", | ||
"rollup-plugin-typescript2": "^0.36.0", | ||
"typescript": "^5.8.3" | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import {defineConfig} from 'rollup' | ||
import babel from '@rollup/plugin-babel' | ||
import json from '@rollup/plugin-json' | ||
import nodeResolve from '@rollup/plugin-node-resolve' | ||
import commonjs from '@rollup/plugin-commonjs' | ||
import typescript from 'rollup-plugin-typescript2' | ||
import packageJson from './package.json' with {type: 'json'} | ||
|
||
const external = [ | ||
...Object.keys(packageJson.peerDependencies ?? {}), | ||
...Object.keys(packageJson.dependencies ?? {}), | ||
...Object.keys(packageJson.devDependencies ?? {}), | ||
].map(name => { | ||
return new RegExp(`^${name}(/.*)?`) | ||
}) | ||
|
||
const config = defineConfig({ | ||
input: ['./src/transports/stdio.ts'], | ||
external, | ||
plugins: [ | ||
nodeResolve(), | ||
commonjs(), | ||
typescript({ | ||
tsconfig: './tsconfig.build.json', | ||
}), | ||
babel({ | ||
extensions: ['.js', '.cjs', '.mjs', '.ts', '.tsx'], | ||
presets: [ | ||
[ | ||
'@babel/preset-env', | ||
{ | ||
targets: { | ||
node: 'current', | ||
}, | ||
}, | ||
], | ||
'@babel/preset-typescript', | ||
], | ||
plugins: ['@babel/plugin-transform-runtime'], | ||
babelHelpers: 'runtime', | ||
}), | ||
json(), | ||
], | ||
output: { | ||
dir: 'dist', | ||
format: 'esm', | ||
importAttributesKey: 'with', | ||
}, | ||
}) | ||
|
||
export default config |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import componentsMetadata from '@primer/react/generated/components.json' with {type: 'json'} | ||
|
||
type Component = { | ||
id: string | ||
name: string | ||
importPath: string | ||
} | ||
|
||
const components: Array<Component> = Object.entries(componentsMetadata.components).map(([id, component]) => { | ||
return { | ||
id, | ||
name: component.name, | ||
importPath: component.importPath, | ||
} | ||
}) | ||
|
||
function listComponents(): Array<Component> { | ||
return components | ||
} | ||
|
||
type Pattern = { | ||
id: string | ||
name: string | ||
} | ||
|
||
const patterns: Array<Pattern> = [ | ||
{ | ||
id: 'data-visualization', | ||
name: 'Data Visualization', | ||
}, | ||
{ | ||
id: 'degraded-experiences', | ||
name: 'Degraded Experiences', | ||
}, | ||
{ | ||
id: 'empty-states', | ||
name: 'Empty States', | ||
}, | ||
{ | ||
id: 'feature-onboarding', | ||
name: 'Feature Onboarding', | ||
}, | ||
{ | ||
id: 'forms', | ||
name: 'Forms', | ||
}, | ||
{ | ||
id: 'loading', | ||
name: 'Loading', | ||
}, | ||
{ | ||
id: 'navigation', | ||
name: 'Navigation', | ||
}, | ||
{ | ||
id: 'notification-messaging', | ||
name: 'Notification message', | ||
}, | ||
{ | ||
id: 'progressive-disclosure', | ||
name: 'Progressive disclosure', | ||
}, | ||
{ | ||
id: 'saving', | ||
name: 'Saving', | ||
}, | ||
] | ||
|
||
function listPatterns(): Array<Pattern> { | ||
return patterns | ||
} | ||
|
||
export {listComponents, listPatterns} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The bin field points to
./dist/stdio.js
but the rollup config outputs the file as./dist/transports/stdio.js
based on the input path. This mismatch will prevent the binary from being found.Copilot uses AI. Check for mistakes.