Skip to content

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

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
3,106 changes: 3,055 additions & 51 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
"private": true,
"workspaces": [
"packages/rollup-plugin-import-css",
"packages/react",
"packages/mcp",
"packages/*",
"examples/*"
],
Expand Down
49 changes: 49 additions & 0 deletions packages/mcp/package.json
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",
"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": "^8.2.3",
"@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",
"concurrently": "^9.1.2",
"rimraf": "^6.0.1",
"rollup": "^4.30.1",
"rollup-plugin-typescript2": "^0.36.0",
"typescript": "^5.8.3"
}
}
51 changes: 51 additions & 0 deletions packages/mcp/rollup.config.js
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(),
babel({
extensions: ['.js', '.cjs', '.mjs', '.ts', '.tsx'],
presets: [
[
'@babel/preset-env',
{
targets: {
node: 'current',
},
},
],
'@babel/preset-typescript',
],
plugins: ['@babel/plugin-transform-runtime'],
babelHelpers: 'runtime',
}),
typescript({
tsconfig: './tsconfig.build.json',
}),
json(),
],
output: {
dir: 'dist',
format: 'esm',
importAttributesKey: 'with',
},
})

export default config
73 changes: 73 additions & 0 deletions packages/mcp/src/primer.ts
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}
Loading
Loading