@og-ui/mcp 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Omkar
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/package.json CHANGED
@@ -1,6 +1,33 @@
1
1
  {
2
2
  "name": "@og-ui/mcp",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.0",
4
+ "description": "MCP server for OG UI: agents list and read components and themes and add them to a project.",
5
+ "license": "MIT",
6
+ "author": "Omkar",
7
+ "homepage": "https://ui.ogom.in",
8
+ "type": "module",
9
+ "bin": {
10
+ "og-ui-mcp": "./src/index.js"
11
+ },
12
+ "exports": {
13
+ ".": "./src/server.js"
14
+ },
15
+ "files": [
16
+ "src"
17
+ ],
18
+ "publishConfig": {
19
+ "access": "public"
20
+ },
21
+ "engines": {
22
+ "node": ">=20"
23
+ },
24
+ "dependencies": {
25
+ "@modelcontextprotocol/sdk": "^1.32.2",
26
+ "@og-ui/cli": "^0.1.0",
27
+ "zod": "^4.6.7"
28
+ },
29
+ "scripts": {
30
+ "build": "node --check src/server.js && node --check src/index.js",
31
+ "test": "node --test test/"
32
+ }
6
33
  }
package/src/index.js ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env node
2
+ // stdio entry: `npx @og-ui/mcp`. Add it to an MCP client, e.g. claude mcp add og-ui -- npx -y @og-ui/mcp
3
+ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
4
+ import { createServer } from './server.js';
5
+
6
+ await createServer().connect(new StdioServerTransport());
package/src/server.js ADDED
@@ -0,0 +1,165 @@
1
+ // OG UI MCP server: lets coding agents look up components and themes and add them to a project.
2
+ // Reads the same registry as the `ogui` CLI (bundled in @og-ui/cli).
3
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
4
+ import { z } from 'zod';
5
+ import { createInstaller, loadItem, readIndex } from '@og-ui/cli/lib/registry.js';
6
+
7
+ const json = (value) => ({ content: [{ type: 'text', text: JSON.stringify(value, null, 2) }] });
8
+ const fail = (message) => ({ content: [{ type: 'text', text: message }], isError: true });
9
+ const read = { readOnlyHint: true, openWorldHint: false };
10
+
11
+ const isComponent = (i) => i.type === 'registry:component' && !i.name.endsWith('-react');
12
+ const isTheme = (i) => i.name.startsWith('theme-') && !i.name.endsWith('-react');
13
+
14
+ /** An alias item (menu) has no files of its own: follow it to the component that styles it. */
15
+ function resolveComponent(name) {
16
+ const item = loadItem(name);
17
+ if (!item || !isComponent(item)) return null;
18
+ if (item.files.length === 0 && item.registryDependencies?.length === 1) {
19
+ const target = item.registryDependencies[0].split('/').pop().replace(/\.json$/, '');
20
+ return { item: loadItem(target), aliasOf: target };
21
+ }
22
+ return { item };
23
+ }
24
+
25
+ export function createServer() {
26
+ const server = new McpServer({ name: 'og-ui', version: '0.0.1' });
27
+
28
+ server.registerTool(
29
+ 'list_components',
30
+ {
31
+ title: 'List OG UI components',
32
+ description: 'Every OG UI component with its group, a one-line summary and whether a React version exists.',
33
+ annotations: read,
34
+ },
35
+ async () => {
36
+ const all = readIndex();
37
+ const react = new Set(all.filter((i) => i.name.endsWith('-react')).map((i) => i.name.slice(0, -6)));
38
+ return json(
39
+ all.filter(isComponent).map((i) => ({
40
+ name: i.name,
41
+ title: i.title,
42
+ group: i.meta?.group ?? null,
43
+ summary: i.description,
44
+ react: react.has(i.name),
45
+ })),
46
+ );
47
+ },
48
+ );
49
+
50
+ server.registerTool(
51
+ 'get_component',
52
+ {
53
+ title: 'Get an OG UI component',
54
+ description:
55
+ 'Markup examples (HTML using og-* classes), every class the component defines, React usage, keyboard and screen-reader notes, and install commands. Use the markup as written; style only through --og-* variables.',
56
+ inputSchema: {
57
+ name: z.string().describe('Component name from list_components, e.g. "dialog"'),
58
+ includeCss: z.boolean().optional().describe('Also return the compiled CSS (large; usually not needed)'),
59
+ },
60
+ annotations: read,
61
+ },
62
+ async ({ name, includeCss }) => {
63
+ const found = resolveComponent(name);
64
+ if (!found?.item) return fail(`No component "${name}". Call list_components for the names.`);
65
+ const { item, aliasOf } = found;
66
+ const reactItem = loadItem(`${name}-react`) ?? loadItem(`${item.name}-react`);
67
+ return json({
68
+ name,
69
+ ...(aliasOf && { note: `${name} is styled by ${aliasOf}; its markup is in the examples below.` }),
70
+ title: item.title,
71
+ group: item.meta?.group,
72
+ summary: item.description,
73
+ classes: item.meta?.classes ?? [],
74
+ markup: item.meta?.markup ?? [],
75
+ react: item.meta?.react ?? null,
76
+ keyboard: item.meta?.keyboard ?? [],
77
+ notes: item.meta?.notes ?? [],
78
+ setup: 'Load og-ui/index.css (or @og-ui/tokens/themes.css + @og-ui/core/og-ui.css) and call initOgUI() once from @og-ui/core/og-ui.js.',
79
+ install: {
80
+ cli: `npx @og-ui/cli add ${name}`,
81
+ react: reactItem ? `npx @og-ui/cli add ${name} --react` : null,
82
+ shadcn: `npx shadcn add https://ui.ogom.in/r/${name}.json`,
83
+ },
84
+ ...(includeCss && { css: item.files.map((f) => f.content).join('\n') }),
85
+ });
86
+ },
87
+ );
88
+
89
+ server.registerTool(
90
+ 'list_themes',
91
+ {
92
+ title: 'List OG UI themes',
93
+ description: 'The built-in themes. Switch with data-og-theme="<name>" and data-og-mode="light|dark" on <html> or any element.',
94
+ annotations: read,
95
+ },
96
+ async () =>
97
+ json(
98
+ readIndex()
99
+ .filter(isTheme)
100
+ .map((i) => ({ name: i.name.slice(6), label: i.title, description: i.description })),
101
+ ),
102
+ );
103
+
104
+ server.registerTool(
105
+ 'get_theme_tokens',
106
+ {
107
+ title: 'Get a theme’s tokens',
108
+ description:
109
+ 'The --og-* CSS variables a theme sets, with values. Use these variables (never raw colours) when writing your own CSS next to OG UI components.',
110
+ inputSchema: {
111
+ name: z.string().describe('Theme name from list_themes, e.g. "glass"'),
112
+ mode: z.enum(['light', 'dark', 'both']).optional().describe('Default both'),
113
+ },
114
+ annotations: read,
115
+ },
116
+ async ({ name, mode = 'both' }) => {
117
+ const item = loadItem(`theme-${name}`);
118
+ if (!item?.meta?.tokens) return fail(`No theme "${name}". Call list_themes for the names.`);
119
+ const { tokens } = item.meta;
120
+ return json({ theme: name, ...(mode === 'both' ? tokens : { [mode]: tokens[mode] }) });
121
+ },
122
+ );
123
+
124
+ server.registerTool(
125
+ 'add_component',
126
+ {
127
+ title: 'Add OG UI components to a project',
128
+ description:
129
+ 'Writes component CSS (and React source with react: true) into the project like `npx @og-ui/cli add`, installing the base theme first if needed, and updates og-ui/index.css. Files the user changed are kept unless overwrite is true.',
130
+ inputSchema: {
131
+ names: z.array(z.string()).min(1).describe('Component names, e.g. ["button", "dialog"]'),
132
+ react: z.boolean().optional().describe('Also copy the React components'),
133
+ theme: z.string().optional().describe('Also add this theme, e.g. "glass"'),
134
+ cwd: z.string().optional().describe('Project root; defaults to the server’s working directory'),
135
+ overwrite: z.boolean().optional(),
136
+ },
137
+ annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: false },
138
+ },
139
+ async ({ names, react, theme, cwd, overwrite }) => {
140
+ const log = [];
141
+ let installer;
142
+ try {
143
+ installer = createInstaller({ cwd, overwrite: !!overwrite, log: (l) => log.push(l.trim()) });
144
+ const missing = [];
145
+ for (const name of names) {
146
+ const item = react && loadItem(`${name}-react`) ? `${name}-react` : name;
147
+ if (!installer.install(item)) missing.push(name);
148
+ }
149
+ if (theme && !installer.install(`theme-${theme}`)) missing.push(`theme ${theme}`);
150
+ installer.writeIndex();
151
+ return json({
152
+ written: installer.written,
153
+ keptBecauseChanged: installer.kept,
154
+ missing,
155
+ npmDependencies: [...installer.npmDeps],
156
+ next: 'Import og-ui/index.css once in the app' + (theme ? ` and set data-og-theme="${theme}" on <html>` : '') + '.',
157
+ });
158
+ } catch (e) {
159
+ return fail(String(e?.message ?? e));
160
+ }
161
+ },
162
+ );
163
+
164
+ return server;
165
+ }
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.