import path from 'node:path' import { Client } from '@kubb/plugin-client/components' import { createReactGenerator } from '@kubb/plugin-oas/generators' import { useOas, useOperationManager } from '@kubb/plugin-oas/hooks' import { getBanner, getFooter } from '@kubb/plugin-oas/utils' import { pluginTsName } from '@kubb/plugin-ts' import { File } from '@kubb/react-fabric' import type { PluginMcp } from '../types' export const mcpGenerator = createReactGenerator({ name: 'mcp', Operation({ config, operation, generator, plugin }) { const { options } = plugin const oas = useOas() const { getSchemas, getName, getFile } = useOperationManager(generator) const mcp = { name: getName(operation, { type: 'function', suffix: 'handler' }), file: getFile(operation), } const type = { file: getFile(operation, { pluginKey: [pluginTsName] }), schemas: getSchemas(operation, { pluginKey: [pluginTsName], type: 'type' }), } return ( {options.client.importPath ? ( <> {options.client.dataReturnType === 'full' && } ) : ( <> {options.client.dataReturnType === 'full' && ( )} )} item.name) || []), ].filter(Boolean)} root={mcp.file.path} path={type.file.path} isTypeOnly /> '} baseURL={options.client.baseURL} operation={operation} typeSchemas={type.schemas} zodSchemas={undefined} dataReturnType={options.client.dataReturnType || 'data'} paramsType={'object'} paramsCasing={options.client?.paramsCasing || options.paramsCasing} pathParamsType={'object'} parser={'client'} > {options.client.dataReturnType === 'data' && `return { content: [ { type: 'text', text: JSON.stringify(res.data) } ], structuredContent: { data: res.data } }`} {options.client.dataReturnType === 'full' && `return { content: [ { type: 'text', text: JSON.stringify(res) } ], structuredContent: { data: res.data } }`} ) }, })