|
| 1 | +import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; |
| 2 | + |
| 3 | +const INSTRUCTIONS = ` |
| 4 | + # Writing User Interfaces |
| 5 | +
|
| 6 | + When writing UI, prefer breaking larger components up into smaller parts. |
| 7 | +
|
| 8 | + ALWAYS write a Storybook story for any component written. If editing a component, ensure appropriate changes have been made to stories for that component. |
| 9 | +
|
| 10 | + When writing stories, use CSF3 importing types from '@storybook/nextjs-vite'. Here is a simple example: |
| 11 | +
|
| 12 | + \`\`\`ts |
| 13 | + import { Meta, StoryObj } from '@storybook/nextjs-vite'; |
| 14 | +
|
| 15 | + import { Break } from './Break'; |
| 16 | +
|
| 17 | + type Story = StoryObj<typeof Break>; |
| 18 | +
|
| 19 | + const meta: Meta<typeof Break> = { |
| 20 | + component: Break, |
| 21 | + args: {}, |
| 22 | + }; |
| 23 | +
|
| 24 | + export default meta; |
| 25 | +
|
| 26 | + export const Horizontal: Story = { |
| 27 | + args: { |
| 28 | + orientation: 'horizontal', |
| 29 | + }, |
| 30 | + }; |
| 31 | + \`\`\` |
| 32 | +
|
| 33 | + After completing each step of the process, provide a link to each story added or modified in the format [Story Name](https://storybook.dev-chromatic.com/?path=/story/<storyId>). |
| 34 | +`; |
| 35 | + |
| 36 | +export function registerUIBuildingTool(server: McpServer) { |
| 37 | + server.registerTool( |
| 38 | + "getUIBuildingInstructions", |
| 39 | + { |
| 40 | + title: "UI Building Instructions", |
| 41 | + description: `Instructions on how to do UI development. |
| 42 | + |
| 43 | + ALWAYS call this tool before doing any UI/frontend/React development, including but not |
| 44 | + limited to adding or updating new components, pages, screens or layouts.`, |
| 45 | + inputSchema: {}, |
| 46 | + }, |
| 47 | + async () => ({ |
| 48 | + content: [{ type: "text", text: INSTRUCTIONS }], |
| 49 | + }), |
| 50 | + ); |
| 51 | +} |
0 commit comments