From 0bed3a5d123f3c78ed1a370eaf4586301a019072 Mon Sep 17 00:00:00 2001 From: Fini Date: Mon, 27 Apr 2026 09:40:00 +0800 Subject: [PATCH] fix(mcp): drop hardcoded section list from get_design_prompt description MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The tool-level description still listed 11 specific sections (schema / layout / roles / text / style / icons / examples / guidelines / planning / elements / design-md) even though the actual catalog has 28. Replace with a pointer at inputSchema.section.enum, which is already derived from listPromptSections() — the description now can't go stale as sections are added or removed. D0 parity snapshot refreshed for the new description text. --- .../__snapshots__/d0-parity-spike.test.ts.snap | 2 +- packages/pen-mcp/src/routes/design-routes.ts | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/pen-mcp/src/__tests__/__snapshots__/d0-parity-spike.test.ts.snap b/packages/pen-mcp/src/__tests__/__snapshots__/d0-parity-spike.test.ts.snap index df31daf36..bfd2dfdf9 100644 --- a/packages/pen-mcp/src/__tests__/__snapshots__/d0-parity-spike.test.ts.snap +++ b/packages/pen-mcp/src/__tests__/__snapshots__/d0-parity-spike.test.ts.snap @@ -3,7 +3,7 @@ exports[`D0 parity spike — additive & gated tool registration > pre-D0 production design tool DEFINITIONS are unchanged (snapshot) > pre-d0-design-tool-definitions 1`] = ` [ { - "description": "Get design knowledge prompt. Use "section" to retrieve a focused subset instead of the full prompt. Sections: schema (PenNode types), layout (flexbox rules), roles (semantic roles), text (typography/CJK/copywriting), style (visual style policy — reads the active document's design.md when present), icons (icon names), examples (design examples), guidelines (design tips), planning (layered workflow guide), elements (N-tool element-tool family reference), design-md (raw style policy derived from the active document's design.md, or a "no design.md" notice). Omit section for the full prompt.", + "description": "Get design knowledge prompt. Pass \`section\` to retrieve a focused subset instead of the full prompt; the available section names are published in \`inputSchema.section.enum\` (derived at server-start from the implementation registry, so this description never drifts as sections are added). Omit \`section\` for the full prompt. The "style" and "design-md" sections are derived from the active document's design.md so the response never leaks another file's design system.", "inputSchema": { "properties": { "filePath": { diff --git a/packages/pen-mcp/src/routes/design-routes.ts b/packages/pen-mcp/src/routes/design-routes.ts index 885d3a69c..1124caee1 100644 --- a/packages/pen-mcp/src/routes/design-routes.ts +++ b/packages/pen-mcp/src/routes/design-routes.ts @@ -25,12 +25,12 @@ const CORE_DESIGN_TOOL_DEFINITIONS = [ { name: 'get_design_prompt', description: - 'Get design knowledge prompt. Use "section" to retrieve a focused subset instead of the full prompt. ' + - 'Sections: schema (PenNode types), layout (flexbox rules), roles (semantic roles), text (typography/CJK/copywriting), ' + - "style (visual style policy — reads the active document's design.md when present), icons (icon names), " + - 'examples (design examples), guidelines (design tips), planning (layered workflow guide), ' + - 'elements (N-tool element-tool family reference), design-md (raw style policy derived from the active ' + - 'document\'s design.md, or a "no design.md" notice). Omit section for the full prompt.', + 'Get design knowledge prompt. Pass `section` to retrieve a focused subset instead of the ' + + 'full prompt; the available section names are published in `inputSchema.section.enum` ' + + '(derived at server-start from the implementation registry, so this description never ' + + 'drifts as sections are added). Omit `section` for the full prompt. The "style" and ' + + '"design-md" sections are derived from the active document\'s design.md so the response ' + + "never leaks another file's design system.", inputSchema: { type: 'object' as const, properties: {