@efolusi/meridian-mcp 0.1.3 → 0.1.4

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.
Files changed (3) hide show
  1. package/README.md +1 -1
  2. package/package.json +3 -2
  3. package/server.mjs +13 -5
package/README.md CHANGED
@@ -11,7 +11,7 @@ UI instead of guessing. It exposes the same generated registry the docs site use
11
11
  | `list_components` | Every UI component with a one-line description and categories. Optional `category` filter. |
12
12
  | `get_component` | One component's full detail: description, Meridian dependencies, and each file's real content — the `.jsx` source, the `.d.ts` types, and the `.prompt.md` usage guide. |
13
13
  | `search_components` | Components matching a keyword across name, title, description and category. |
14
- | `get_tokens` | Design tokens (colour, typography, spacing, effects) in light, dark and compact. Optional `group` filter. |
14
+ | `get_tokens` | Design tokens (colour, typography, spacing, effects) as DTCG JSON. `$value` is the light theme at default density; tokens that change carry their `dark`, `compact` and `coarse` (touch pointer) values under `$extensions["com.efolusi.meridian"].modes`, and references are `{group.leaf}` aliases. Optional `group` filter; an unknown group returns the list of groups. |
15
15
 
16
16
  ## Data source
17
17
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@efolusi/meridian-mcp",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "MCP server exposing the Meridian design system registry (components, source, types, usage guides, tokens) to AI coding agents.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://meridian.efolusi.com",
@@ -18,7 +18,8 @@
18
18
  "README.md"
19
19
  ],
20
20
  "dependencies": {
21
- "@modelcontextprotocol/sdk": "^1.0.0"
21
+ "@modelcontextprotocol/sdk": "^1.32.2",
22
+ "zod": "^4.6.6"
22
23
  },
23
24
  "keywords": [
24
25
  "mcp",
package/server.mjs CHANGED
@@ -40,11 +40,15 @@ async function index() {
40
40
  async function components() {
41
41
  return (await index()).items.filter((it) => it.type === 'registry:ui');
42
42
  }
43
+ // The name becomes a file path, so only registry item names get through.
44
+ const COMPONENT_NAME = /^[a-z][a-z0-9-]*$/i;
43
45
  async function component(name) {
44
- return readJSON(`site/registry/${String(name).toLowerCase()}.json`);
46
+ if (!COMPONENT_NAME.test(name)) throw new Error(`invalid component name ${JSON.stringify(name)}`);
47
+ return readJSON(`site/registry/${name.toLowerCase()}.json`);
45
48
  }
46
49
 
47
- const server = new McpServer({ name: 'meridian', version: '0.1.0' });
50
+ const { version } = JSON.parse(await fs.readFile(new URL('./package.json', import.meta.url), 'utf8'));
51
+ const server = new McpServer({ name: 'meridian', version });
48
52
 
49
53
  server.registerTool(
50
54
  'list_components',
@@ -104,12 +108,16 @@ server.registerTool(
104
108
  'get_tokens',
105
109
  {
106
110
  title: 'Get Meridian design tokens',
107
- description: 'The design tokens (colors, typography, spacing, effects) in light, dark and compact. Use semantic tokens in generated CSS — never hardcode hex.',
108
- inputSchema: { group: z.string().optional().describe('Optional group filter, e.g. "color", "spacing", "typography".') },
111
+ description: 'The design tokens (colors, typography, spacing, effects) as DTCG JSON. Each $value is the light theme at default density; a token that changes elsewhere also carries $extensions["com.efolusi.meridian"].modes with its dark, compact and coarse (touch pointer) values. References between tokens are DTCG aliases, {group.leaf}: the CSS custom property is --group-leaf (e.g. {surface.page} is --surface-page). In generated CSS use the custom property so the theme, density and pointer modes all apply; never hardcode hex.',
112
+ inputSchema: { group: z.string().optional().describe('Optional top-level group, e.g. "brand", "surface", "text", "space", "radius", "font". An unknown group returns the list of groups.') },
109
113
  },
110
114
  async ({ group }) => {
111
115
  const tokens = await readJSON('tokens.json');
112
- const text = JSON.stringify(group ? { [group]: tokens[group] ?? tokens } : tokens, null, 2);
116
+ const groups = Object.keys(tokens).filter(k => !k.startsWith('$'));
117
+ if (group && !groups.includes(group)) {
118
+ return { content: [{ type: 'text', text: `No token group "${group}". groups: ${groups.join(', ')}` }], isError: true };
119
+ }
120
+ const text = JSON.stringify(group ? { [group]: tokens[group] } : tokens, null, 2);
113
121
  return { content: [{ type: 'text', text }] };
114
122
  }
115
123
  );