mirror of
https://github.com/nuxt/ui.git
synced 2026-09-14 19:51:10 +08:00
41e5a18f21
Co-authored-by: vercel[bot] <35613825+vercel[bot]@users.noreply.github.com>
20 lines
630 B
TypeScript
20 lines
630 B
TypeScript
import { z } from 'zod'
|
|
|
|
export default defineMcpTool({
|
|
description: 'Retrieves specific UI example implementation code and details',
|
|
inputSchema: {
|
|
exampleName: z.string().describe('The name of the example (PascalCase)')
|
|
},
|
|
cache: '30m',
|
|
async handler({ exampleName }) {
|
|
try {
|
|
const result = await $fetch<{ code: string }>(`/api/component-example/${exampleName}.json`)
|
|
return {
|
|
content: [{ type: 'text' as const, text: result.code }]
|
|
}
|
|
} catch {
|
|
return errorResult(`Example '${exampleName}' not found. Use the list_examples tool to see all available examples.`)
|
|
}
|
|
}
|
|
})
|