@efolusi/meridian-mcp 0.1.3 → 0.1.5

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 +2 -2
  2. package/package.json +4 -3
  3. package/server.mjs +24 -6
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
 
@@ -60,4 +60,4 @@ MERIDIAN_SOURCE=.. node server.mjs # read the local registry
60
60
  node smoke.mjs # quick end-to-end check of every tool
61
61
  ```
62
62
 
63
- MIT licensed.
63
+ Apache-2.0 licensed.
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@efolusi/meridian-mcp",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "description": "MCP server exposing the Meridian design system registry (components, source, types, usage guides, tokens) to AI coding agents.",
5
- "license": "MIT",
5
+ "license": "Apache-2.0",
6
6
  "homepage": "https://meridian.efolusi.com",
7
7
  "repository": {
8
8
  "type": "git",
@@ -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',
@@ -76,8 +80,18 @@ server.registerTool(
76
80
  return { content: [{ type: 'text', text: `No component named "${name}". Call list_components to see valid names.` }], isError: true };
77
81
  }
78
82
  const dep = (c.registryDependencies || []).length ? `\nMeridian dependencies (copy these too if vendoring): ${c.registryDependencies.join(', ')}` : '';
83
+ // `target` is where the file goes in a project; `path` is only where the
84
+ // registry keeps it (the inline Icon lives in registry/icons/ but is copied
85
+ // to components/icons/). A generated data file such as the 48 kB glyph map
86
+ // would only flood the agent's context, so it is named, not printed.
79
87
  const files = (c.files || [])
80
- .map((f) => `\n\n### ${f.path} (${f.type})\n\`\`\`\n${f.content}\n\`\`\``)
88
+ .map((f) => {
89
+ const where = f.target || f.path;
90
+ const body = /^\/\/ Generated by /.test(f.content || '')
91
+ ? `(generated data file, ${Math.round((f.content || '').length / 1024)} kB, not shown: copy it with \`npx @efolusi/meridian-cli add ${c.name}\` or from ${SOURCE}/site/registry/${c.name}.json)`
92
+ : `\`\`\`\n${f.content}\n\`\`\``;
93
+ return `\n\n### ${where} (${f.type})\n${body}`;
94
+ })
81
95
  .join('');
82
96
  return { content: [{ type: 'text', text: `# ${c.title || c.name}\n${c.description || ''}${dep}${files}` }] };
83
97
  }
@@ -104,12 +118,16 @@ server.registerTool(
104
118
  'get_tokens',
105
119
  {
106
120
  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".') },
121
+ 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, coarse (touch pointer), increased and increased-dark (prefers-contrast: more) 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.',
122
+ 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
123
  },
110
124
  async ({ group }) => {
111
125
  const tokens = await readJSON('tokens.json');
112
- const text = JSON.stringify(group ? { [group]: tokens[group] ?? tokens } : tokens, null, 2);
126
+ const groups = Object.keys(tokens).filter(k => !k.startsWith('$'));
127
+ if (group && !groups.includes(group)) {
128
+ return { content: [{ type: 'text', text: `No token group "${group}". groups: ${groups.join(', ')}` }], isError: true };
129
+ }
130
+ const text = JSON.stringify(group ? { [group]: tokens[group] } : tokens, null, 2);
113
131
  return { content: [{ type: 'text', text }] };
114
132
  }
115
133
  );