@orval/mcp 8.0.0-rc.0 → 8.0.0-rc.2
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.
- package/dist/{index.d.ts → index.d.mts} +3 -3
- package/dist/{index.js → index.mjs} +23 -38
- package/dist/index.mjs.map +1 -0
- package/package.json +15 -14
- package/dist/index.js.map +0 -1
|
@@ -3,12 +3,12 @@ import { ClientBuilder, ClientExtraFilesBuilder, ClientGeneratorsBuilder, Client
|
|
|
3
3
|
//#region src/index.d.ts
|
|
4
4
|
declare const getMcpHeader: ClientHeaderBuilder;
|
|
5
5
|
declare const generateMcp: ClientBuilder;
|
|
6
|
-
declare const generateServer: (verbOptions: Record<string, GeneratorVerbOptions>, output: NormalizedOutputOptions, context: ContextSpecs) =>
|
|
6
|
+
declare const generateServer: (verbOptions: Record<string, GeneratorVerbOptions>, output: NormalizedOutputOptions, context: ContextSpecs) => {
|
|
7
7
|
content: string;
|
|
8
8
|
path: string;
|
|
9
|
-
}[]
|
|
9
|
+
}[];
|
|
10
10
|
declare const generateExtraFiles: ClientExtraFilesBuilder;
|
|
11
11
|
declare const builder: () => () => ClientGeneratorsBuilder;
|
|
12
12
|
//#endregion
|
|
13
13
|
export { builder, builder as default, generateExtraFiles, generateMcp, generateServer, getMcpHeader };
|
|
14
|
-
//# sourceMappingURL=index.d.
|
|
14
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -8,27 +8,21 @@ const getHeader = (option, info) => {
|
|
|
8
8
|
const header = option(info);
|
|
9
9
|
return Array.isArray(header) ? jsDoc({ description: header }) : header;
|
|
10
10
|
};
|
|
11
|
-
const getMcpHeader = ({ verbOptions, output
|
|
11
|
+
const getMcpHeader = ({ verbOptions, output }) => {
|
|
12
12
|
const targetInfo = getFileInfo(output.target);
|
|
13
13
|
const schemaInfo = getFileInfo(output.schemas);
|
|
14
14
|
const relativeSchemaImportPath = output.schemas ? upath.relativeSafe(targetInfo.dirname, schemaInfo.dirname) : "./" + targetInfo.filename + ".schemas";
|
|
15
|
-
return [`import {\n ${Object.values(verbOptions).flatMap((verbOption) => {
|
|
15
|
+
return [`import {\n ${new Set(Object.values(verbOptions).flatMap((verbOption) => {
|
|
16
16
|
const imports = [];
|
|
17
17
|
const pascalOperationName = pascal(verbOption.operationName);
|
|
18
18
|
if (verbOption.queryParams) imports.push(`${pascalOperationName}Params`);
|
|
19
19
|
if (verbOption.body.definition) imports.push(`${pascalOperationName}Body`);
|
|
20
20
|
return imports;
|
|
21
|
-
}).
|
|
22
|
-
|
|
23
|
-
return acc;
|
|
24
|
-
}, []).join(",\n ")}\n} from '${relativeSchemaImportPath}';
|
|
25
|
-
`, `import {\n ${Object.values(verbOptions).flatMap((verbOption) => verbOption.operationName).reduce((acc, name) => {
|
|
26
|
-
if (!acc.find((i) => i === name)) acc.push(name);
|
|
27
|
-
return acc;
|
|
28
|
-
}, []).join(",\n ")}\n} from './http-client';
|
|
21
|
+
})).values().toArray().join(",\n ")}\n} from '${relativeSchemaImportPath}';
|
|
22
|
+
`, `import {\n ${new Set(Object.values(verbOptions).flatMap((verbOption) => verbOption.operationName)).values().toArray().join(",\n ")}\n} from './http-client';
|
|
29
23
|
`].join("\n") + "\n";
|
|
30
24
|
};
|
|
31
|
-
const generateMcp =
|
|
25
|
+
const generateMcp = (verbOptions) => {
|
|
32
26
|
const handlerArgsTypes = [];
|
|
33
27
|
const pathParamsType = verbOptions.params.map((param) => {
|
|
34
28
|
return ` ${param.name.split(": ")[0]}: ${param.implementation.split(": ")[1]}`;
|
|
@@ -69,23 +63,23 @@ export const ${`${verbOptions.operationName}Handler`} = async (${handlerArgsType
|
|
|
69
63
|
imports: []
|
|
70
64
|
};
|
|
71
65
|
};
|
|
72
|
-
const generateServer =
|
|
66
|
+
const generateServer = (verbOptions, output, context) => {
|
|
73
67
|
const info = context.specs[context.specKey].info;
|
|
74
68
|
const { extension, dirname } = getFileInfo(output.target);
|
|
75
69
|
const serverPath = upath.join(dirname, `server${extension}`);
|
|
76
70
|
const header = getHeader(output.override.header, info);
|
|
77
71
|
const toolImplementations = Object.values(verbOptions).map((verbOption) => {
|
|
78
|
-
const
|
|
79
|
-
if (verbOption.params.length > 0)
|
|
80
|
-
if (verbOption.queryParams)
|
|
81
|
-
if (verbOption.body.definition)
|
|
82
|
-
const
|
|
83
|
-
${
|
|
72
|
+
const inputSchemaTypes = [];
|
|
73
|
+
if (verbOption.params.length > 0) inputSchemaTypes.push(` pathParams: ${verbOption.operationName}Params`);
|
|
74
|
+
if (verbOption.queryParams) inputSchemaTypes.push(` queryParams: ${verbOption.operationName}QueryParams`);
|
|
75
|
+
if (verbOption.body.definition) inputSchemaTypes.push(` bodyParams: ${verbOption.operationName}Body`);
|
|
76
|
+
const inputSchemaImplementation = inputSchemaTypes.length > 0 ? ` {
|
|
77
|
+
${inputSchemaTypes.join(",\n ")}
|
|
84
78
|
},` : "";
|
|
85
79
|
return `
|
|
86
80
|
server.tool(
|
|
87
81
|
'${verbOption.operationName}',
|
|
88
|
-
'${verbOption.summary}',${
|
|
82
|
+
'${verbOption.summary}',${inputSchemaImplementation ? `\n${inputSchemaImplementation}` : ""}
|
|
89
83
|
${verbOption.operationName}Handler
|
|
90
84
|
);`;
|
|
91
85
|
}).join("\n");
|
|
@@ -129,9 +123,9 @@ server.connect(transport).then(() => {
|
|
|
129
123
|
}];
|
|
130
124
|
};
|
|
131
125
|
const generateZodFiles = async (verbOptions, output, context) => {
|
|
132
|
-
const { extension, dirname
|
|
126
|
+
const { extension, dirname } = getFileInfo(output.target);
|
|
133
127
|
const header = getHeader(output.override.header, context.specs[context.specKey].info);
|
|
134
|
-
const zods = await Promise.all(Object.values(verbOptions).map((verbOption) => generateZod(verbOption, {
|
|
128
|
+
const zods = await Promise.all(Object.values(verbOptions).map(async (verbOption) => generateZod(verbOption, {
|
|
135
129
|
route: verbOption.route,
|
|
136
130
|
pathRoute: verbOption.pathRoute,
|
|
137
131
|
override: output.override,
|
|
@@ -139,11 +133,7 @@ const generateZodFiles = async (verbOptions, output, context) => {
|
|
|
139
133
|
mock: output.mock,
|
|
140
134
|
output: output.target
|
|
141
135
|
}, output.client)));
|
|
142
|
-
|
|
143
|
-
for (const mutator of z.mutators ?? []) acc[mutator.name] = mutator;
|
|
144
|
-
return acc;
|
|
145
|
-
}, {});
|
|
146
|
-
let content = `${header}import { z as zod } from 'zod';\n${generateMutatorImports({ mutators: Object.values(allMutators) })}\n`;
|
|
136
|
+
let content = `${header}import { z as zod } from 'zod';\n${generateMutatorImports({ mutators: new Map(zods.flatMap((z) => z.mutators ?? []).map((m) => [m.name, m])).values().toArray() })}\n`;
|
|
147
137
|
const zodPath = upath.join(dirname, `tool-schemas.zod${extension}`);
|
|
148
138
|
content += zods.map((zod) => zod.implementation).join("\n");
|
|
149
139
|
return [{
|
|
@@ -151,10 +141,10 @@ const generateZodFiles = async (verbOptions, output, context) => {
|
|
|
151
141
|
path: zodPath
|
|
152
142
|
}];
|
|
153
143
|
};
|
|
154
|
-
const
|
|
144
|
+
const generateHttpClientFiles = async (verbOptions, output, context) => {
|
|
155
145
|
const { extension, dirname, filename } = getFileInfo(output.target);
|
|
156
146
|
const header = getHeader(output.override.header, context.specs[context.specKey].info);
|
|
157
|
-
const clients = await Promise.all(Object.values(verbOptions).map((verbOption) => {
|
|
147
|
+
const clients = await Promise.all(Object.values(verbOptions).map(async (verbOption) => {
|
|
158
148
|
return generateClient(verbOption, {
|
|
159
149
|
route: getFullRoute(verbOption.route, context.specs[context.specKey].servers, output.baseUrl),
|
|
160
150
|
pathRoute: verbOption.pathRoute,
|
|
@@ -166,13 +156,11 @@ const generateHttpClinetFiles = async (verbOptions, output, context) => {
|
|
|
166
156
|
}));
|
|
167
157
|
const clientImplementation = clients.map((client) => client.implementation).join("\n");
|
|
168
158
|
const relativeSchemasPath = output.schemas ? upath.relativeSafe(dirname, getFileInfo(output.schemas).dirname) : "./" + filename + ".schemas";
|
|
159
|
+
const importNames = clients.flatMap((client) => client.imports).map((imp) => imp.name);
|
|
169
160
|
return [{
|
|
170
161
|
content: [
|
|
171
162
|
header,
|
|
172
|
-
`import { ${
|
|
173
|
-
if (!acc.find((i) => i === imp.name)) acc.push(imp.name);
|
|
174
|
-
return acc;
|
|
175
|
-
}, []).join(",\n")} } from '${relativeSchemasPath}';`,
|
|
163
|
+
`import { ${new Set(importNames).values().toArray().join(",\n")} } from '${relativeSchemasPath}';`,
|
|
176
164
|
generateFetchHeader({
|
|
177
165
|
title: "",
|
|
178
166
|
isRequestOptions: false,
|
|
@@ -191,11 +179,8 @@ const generateHttpClinetFiles = async (verbOptions, output, context) => {
|
|
|
191
179
|
}];
|
|
192
180
|
};
|
|
193
181
|
const generateExtraFiles = async (verbOptions, output, context) => {
|
|
194
|
-
const
|
|
195
|
-
|
|
196
|
-
generateZodFiles(verbOptions, output, context),
|
|
197
|
-
generateHttpClinetFiles(verbOptions, output, context)
|
|
198
|
-
]);
|
|
182
|
+
const server = generateServer(verbOptions, output, context);
|
|
183
|
+
const [zods, httpClients] = await Promise.all([generateZodFiles(verbOptions, output, context), generateHttpClientFiles(verbOptions, output, context)]);
|
|
199
184
|
return [
|
|
200
185
|
...server,
|
|
201
186
|
...zods,
|
|
@@ -212,4 +197,4 @@ var src_default = builder;
|
|
|
212
197
|
|
|
213
198
|
//#endregion
|
|
214
199
|
export { builder, src_default as default, generateExtraFiles, generateMcp, generateServer, getMcpHeader };
|
|
215
|
-
//# sourceMappingURL=index.
|
|
200
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["getMcpHeader: ClientHeaderBuilder","generateMcp: ClientBuilder","generateExtraFiles: ClientExtraFilesBuilder","mcpClientBuilder: ClientGeneratorsBuilder"],"sources":["../src/index.ts"],"sourcesContent":["import {\n camel,\n type ClientBuilder,\n type ClientExtraFilesBuilder,\n type ClientGeneratorsBuilder,\n type ClientHeaderBuilder,\n type ContextSpecs,\n generateMutatorImports,\n type GeneratorVerbOptions,\n getFileInfo,\n getFullRoute,\n jsDoc,\n type NormalizedOutputOptions,\n pascal,\n upath,\n} from '@orval/core';\nimport { generateClient, generateFetchHeader } from '@orval/fetch';\nimport { generateZod } from '@orval/zod';\nimport type { InfoObject } from 'openapi3-ts/oas30';\n\nconst getHeader = (\n option: false | ((info: InfoObject) => string | string[]),\n info: InfoObject,\n): string => {\n if (!option) {\n return '';\n }\n\n const header = option(info);\n\n return Array.isArray(header) ? jsDoc({ description: header }) : header;\n};\n\nexport const getMcpHeader: ClientHeaderBuilder = ({ verbOptions, output }) => {\n const targetInfo = getFileInfo(output.target);\n const schemaInfo = getFileInfo(output.schemas);\n\n const relativeSchemaImportPath = output.schemas\n ? upath.relativeSafe(targetInfo.dirname, schemaInfo.dirname)\n : './' + targetInfo.filename + '.schemas';\n\n const importSchemaNames = new Set(\n Object.values(verbOptions).flatMap((verbOption) => {\n const imports = [];\n const pascalOperationName = pascal(verbOption.operationName);\n\n if (verbOption.queryParams) {\n imports.push(`${pascalOperationName}Params`);\n }\n\n if (verbOption.body.definition) {\n imports.push(`${pascalOperationName}Body`);\n }\n\n return imports;\n }),\n )\n .values()\n .toArray();\n\n const importSchemasImplementation = `import {\\n ${importSchemaNames.join(\n ',\\n ',\n )}\\n} from '${relativeSchemaImportPath}';\n`;\n\n const relativeFetchClientPath = './http-client';\n const importFetchClientNames = new Set(\n Object.values(verbOptions).flatMap(\n (verbOption) => verbOption.operationName,\n ),\n )\n .values()\n .toArray();\n\n const importFetchClientImplementation = `import {\\n ${importFetchClientNames.join(\n ',\\n ',\n )}\\n} from '${relativeFetchClientPath}';\n `;\n\n const content = [\n importSchemasImplementation,\n importFetchClientImplementation,\n ].join('\\n');\n\n return content + '\\n';\n};\n\nexport const generateMcp: ClientBuilder = (verbOptions) => {\n const handlerArgsTypes = [];\n const pathParamsType = verbOptions.params\n .map((param) => {\n const paramName = param.name.split(': ')[0];\n const paramType = param.implementation.split(': ')[1];\n return ` ${paramName}: ${paramType}`;\n })\n .join(',\\n');\n if (pathParamsType) {\n handlerArgsTypes.push(` pathParams: {\\n${pathParamsType}\\n };`);\n }\n if (verbOptions.queryParams) {\n handlerArgsTypes.push(\n ` queryParams: ${verbOptions.queryParams.schema.name};`,\n );\n }\n if (verbOptions.body.definition) {\n handlerArgsTypes.push(` bodyParams: ${verbOptions.body.definition};`);\n }\n\n const handlerArgsName = `${verbOptions.operationName}Args`;\n const handlerArgsImplementation =\n handlerArgsTypes.length > 0\n ? `\nexport type ${handlerArgsName} = {\n${handlerArgsTypes.join('\\n')}\n}\n`\n : '';\n\n const fetchParams = [];\n if (verbOptions.params.length > 0) {\n const pathParamsArgs = verbOptions.params\n .map((param) => {\n const paramName = param.name.split(': ')[0];\n\n return `args.pathParams.${paramName}`;\n })\n .join(', ');\n\n fetchParams.push(pathParamsArgs);\n }\n if (verbOptions.body.definition) fetchParams.push(`args.bodyParams`);\n if (verbOptions.queryParams) fetchParams.push(`args.queryParams`);\n\n const handlerName = `${verbOptions.operationName}Handler`;\n const handlerImplementation = `\nexport const ${handlerName} = async (${handlerArgsTypes.length > 0 ? `args: ${handlerArgsName}` : ''}) => {\n const res = await ${verbOptions.operationName}(${fetchParams.join(', ')});\n\n return {\n content: [\n {\n type: 'text' as const,\n text: JSON.stringify(res),\n },\n ],\n };\n};`;\n\n const handlersImplementation = [\n handlerArgsImplementation,\n handlerImplementation,\n ].join('');\n\n return {\n implementation: handlersImplementation ? `${handlersImplementation}\\n` : '',\n imports: [],\n };\n};\n\nexport const generateServer = (\n verbOptions: Record<string, GeneratorVerbOptions>,\n output: NormalizedOutputOptions,\n context: ContextSpecs,\n) => {\n const info = context.specs[context.specKey].info;\n const { extension, dirname } = getFileInfo(output.target);\n const serverPath = upath.join(dirname, `server${extension}`);\n const header = getHeader(output.override.header, info);\n\n const toolImplementations = Object.values(verbOptions)\n .map((verbOption) => {\n const inputSchemaTypes = [];\n if (verbOption.params.length > 0)\n inputSchemaTypes.push(\n ` pathParams: ${verbOption.operationName}Params`,\n );\n if (verbOption.queryParams)\n inputSchemaTypes.push(\n ` queryParams: ${verbOption.operationName}QueryParams`,\n );\n if (verbOption.body.definition)\n inputSchemaTypes.push(` bodyParams: ${verbOption.operationName}Body`);\n\n const inputSchemaImplementation =\n inputSchemaTypes.length > 0\n ? ` {\n ${inputSchemaTypes.join(',\\n ')}\n },`\n : '';\n\n const toolImplementation = `\nserver.tool(\n '${verbOption.operationName}',\n '${verbOption.summary}',${inputSchemaImplementation ? `\\n${inputSchemaImplementation}` : ''}\n ${verbOption.operationName}Handler\n);`;\n\n return toolImplementation;\n })\n .join('\\n');\n\n const importToolSchemas = Object.values(verbOptions)\n .flatMap((verbOption) => {\n const imports = [];\n\n if (verbOption.headers)\n imports.push(` ${verbOption.operationName}Header`);\n if (verbOption.params.length > 0)\n imports.push(` ${verbOption.operationName}Params`);\n if (verbOption.queryParams)\n imports.push(` ${verbOption.operationName}QueryParams`);\n if (verbOption.body.definition)\n imports.push(` ${verbOption.operationName}Body`);\n\n return imports;\n })\n .join(',\\n');\n const importToolSchemasImplementation = `import {\\n${importToolSchemas}\\n} from './tool-schemas.zod';`;\n\n const importHandlers = Object.values(verbOptions)\n .filter((verbOption) =>\n toolImplementations.includes(`${verbOption.operationName}Handler`),\n )\n .map((verbOption) => ` ${verbOption.operationName}Handler`)\n .join(`,\\n`);\n const importHandlersImplementation = `import {\\n${importHandlers}\\n} from './handlers';`;\n\n const importDependenciesImplementation = `import {\n McpServer\n} from '@modelcontextprotocol/sdk/server/mcp.js';\n \nimport {\n StdioServerTransport\n} from '@modelcontextprotocol/sdk/server/stdio.js'; \n`;\n const newMcpServerImplementation = `\nconst server = new McpServer({\n name: '${camel(info.title)}Server',\n version: '1.0.0',\n});\n`;\n const serverConnectImplementation = `\nconst transport = new StdioServerTransport();\n\nserver.connect(transport).then(() => {\n console.error('MCP server running on stdio');\n}).catch(console.error);\n`;\n\n const content = [\n header,\n importDependenciesImplementation,\n importHandlersImplementation,\n importToolSchemasImplementation,\n newMcpServerImplementation,\n toolImplementations,\n serverConnectImplementation,\n ].join('\\n');\n\n return [\n {\n content,\n path: serverPath,\n },\n ];\n};\n\nconst generateZodFiles = async (\n verbOptions: Record<string, GeneratorVerbOptions>,\n output: NormalizedOutputOptions,\n context: ContextSpecs,\n) => {\n const { extension, dirname } = getFileInfo(output.target);\n\n const header = getHeader(\n output.override.header,\n context.specs[context.specKey].info,\n );\n\n const zods = await Promise.all(\n Object.values(verbOptions).map(async (verbOption) =>\n generateZod(\n verbOption,\n {\n route: verbOption.route,\n pathRoute: verbOption.pathRoute,\n override: output.override,\n context,\n mock: output.mock,\n output: output.target,\n },\n output.client,\n ),\n ),\n );\n\n const allMutators = new Map(\n zods.flatMap((z) => z.mutators ?? []).map((m) => [m.name, m]),\n )\n .values()\n .toArray();\n\n const mutatorsImports = generateMutatorImports({\n mutators: allMutators,\n });\n\n let content = `${header}import { z as zod } from 'zod';\\n${mutatorsImports}\\n`;\n\n const zodPath = upath.join(dirname, `tool-schemas.zod${extension}`);\n\n content += zods.map((zod) => zod.implementation).join('\\n');\n\n return [\n {\n content,\n path: zodPath,\n },\n ];\n};\n\nconst generateHttpClientFiles = async (\n verbOptions: Record<string, GeneratorVerbOptions>,\n output: NormalizedOutputOptions,\n context: ContextSpecs,\n) => {\n const { extension, dirname, filename } = getFileInfo(output.target);\n\n const header = getHeader(\n output.override.header,\n context.specs[context.specKey].info,\n );\n\n const clients = await Promise.all(\n Object.values(verbOptions).map(async (verbOption) => {\n const fullRoute = getFullRoute(\n verbOption.route,\n context.specs[context.specKey].servers,\n output.baseUrl,\n );\n\n const options = {\n route: fullRoute,\n pathRoute: verbOption.pathRoute,\n override: output.override,\n context,\n mock: output.mock,\n output: output.target,\n };\n\n return generateClient(verbOption, options, output.client, output);\n }),\n );\n\n const clientImplementation = clients\n .map((client) => client.implementation)\n .join('\\n');\n\n const relativeSchemasPath = output.schemas\n ? upath.relativeSafe(dirname, getFileInfo(output.schemas).dirname)\n : './' + filename + '.schemas';\n\n const importNames = clients\n .flatMap((client) => client.imports)\n .map((imp) => imp.name);\n const uniqueImportNames = new Set(importNames).values().toArray();\n\n const importImplementation = `import { ${uniqueImportNames.join(\n ',\\n',\n )} } from '${relativeSchemasPath}';`;\n\n const fetchHeader = generateFetchHeader({\n title: '',\n isRequestOptions: false,\n isMutator: false,\n noFunction: false,\n isGlobalMutator: false,\n provideIn: false,\n hasAwaitedType: false,\n output,\n verbOptions,\n clientImplementation,\n });\n\n const content = [\n header,\n importImplementation,\n fetchHeader,\n clientImplementation,\n ].join('\\n');\n const outputPath = upath.join(dirname, `http-client${extension}`);\n\n return [\n {\n content,\n path: outputPath,\n },\n ];\n};\n\nexport const generateExtraFiles: ClientExtraFilesBuilder = async (\n verbOptions,\n output,\n context,\n) => {\n const server = generateServer(verbOptions, output, context);\n const [zods, httpClients] = await Promise.all([\n generateZodFiles(verbOptions, output, context),\n generateHttpClientFiles(verbOptions, output, context),\n ]);\n\n return [...server, ...zods, ...httpClients];\n};\n\nconst mcpClientBuilder: ClientGeneratorsBuilder = {\n client: generateMcp,\n header: getMcpHeader,\n extraFiles: generateExtraFiles,\n};\n\nexport const builder = () => () => mcpClientBuilder;\n\nexport default builder;\n"],"mappings":";;;;;AAoBA,MAAM,aACJ,QACA,SACW;AACX,KAAI,CAAC,OACH,QAAO;CAGT,MAAM,SAAS,OAAO,KAAK;AAE3B,QAAO,MAAM,QAAQ,OAAO,GAAG,MAAM,EAAE,aAAa,QAAQ,CAAC,GAAG;;AAGlE,MAAaA,gBAAqC,EAAE,aAAa,aAAa;CAC5E,MAAM,aAAa,YAAY,OAAO,OAAO;CAC7C,MAAM,aAAa,YAAY,OAAO,QAAQ;CAE9C,MAAM,2BAA2B,OAAO,UACpC,MAAM,aAAa,WAAW,SAAS,WAAW,QAAQ,GAC1D,OAAO,WAAW,WAAW;AA6CjC,QALgB,CAnBoB,eAnBV,IAAI,IAC5B,OAAO,OAAO,YAAY,CAAC,SAAS,eAAe;EACjD,MAA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AM,eAAe,MAAM,QAAQ,IAAI,CAC5C,iBAAiB,aAAa,QAAQ,QAAQ,EAC9C,wBAAwB,aAAa,QAAQ,QAAQ,CACtD,CAAC;AAEF,QAAO;EAAC,GAAG;EAAQ,GAAG;EAAM,GAAG;EAAY;;AAG7C,MAAMC,mBAA4C;CAChD,QAAQ;CACR,QAAQ;CACR,YAAY;CACb;AAED,MAAa,sBAAsB;AAEnC,kBAAe"}
|
package/package.json
CHANGED
|
@@ -1,36 +1,37 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orval/mcp",
|
|
3
|
-
"version": "8.0.0-rc.
|
|
3
|
+
"version": "8.0.0-rc.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
7
7
|
"import": {
|
|
8
|
-
"types": "./dist/index.d.
|
|
9
|
-
"import": "./dist/index.
|
|
8
|
+
"types": "./dist/index.d.mts",
|
|
9
|
+
"import": "./dist/index.mjs"
|
|
10
10
|
}
|
|
11
11
|
},
|
|
12
12
|
"files": [
|
|
13
13
|
"dist",
|
|
14
|
-
"!dist/**/*.d.ts.map"
|
|
14
|
+
"!dist/**/*.d.ts.map",
|
|
15
|
+
"!dist/**/*.d.mts.map"
|
|
15
16
|
],
|
|
16
17
|
"scripts": {
|
|
17
|
-
"build": "tsdown --config-loader
|
|
18
|
-
"dev": "tsdown --config-loader
|
|
18
|
+
"build": "tsdown --config-loader unrun",
|
|
19
|
+
"dev": "tsdown --config-loader unrun --watch src",
|
|
19
20
|
"lint": "eslint .",
|
|
20
21
|
"clean": "rimraf .turbo dist",
|
|
21
22
|
"nuke": "rimraf .turbo dist node_modules"
|
|
22
23
|
},
|
|
23
24
|
"dependencies": {
|
|
24
|
-
"@orval/core": "8.0.0-rc.
|
|
25
|
-
"@orval/fetch": "8.0.0-rc.
|
|
26
|
-
"@orval/zod": "8.0.0-rc.
|
|
25
|
+
"@orval/core": "8.0.0-rc.2",
|
|
26
|
+
"@orval/fetch": "8.0.0-rc.2",
|
|
27
|
+
"@orval/zod": "8.0.0-rc.2",
|
|
27
28
|
"openapi3-ts": "4.5.0"
|
|
28
29
|
},
|
|
29
30
|
"devDependencies": {
|
|
30
|
-
"eslint": "
|
|
31
|
-
"rimraf": "
|
|
32
|
-
"tsdown": "
|
|
33
|
-
"typescript": "
|
|
31
|
+
"eslint": "9.39.1",
|
|
32
|
+
"rimraf": "6.1.0",
|
|
33
|
+
"tsdown": "0.16.4",
|
|
34
|
+
"typescript": "5.9.3"
|
|
34
35
|
},
|
|
35
|
-
"stableVersion": "
|
|
36
|
+
"stableVersion": "8.0.0-rc.1"
|
|
36
37
|
}
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["getMcpHeader: ClientHeaderBuilder","generateMcp: ClientBuilder","generateExtraFiles: ClientExtraFilesBuilder","mcpClientBuilder: ClientGeneratorsBuilder"],"sources":["../src/index.ts"],"sourcesContent":["import {\n camel,\n type ClientBuilder,\n type ClientExtraFilesBuilder,\n type ClientGeneratorsBuilder,\n type ClientHeaderBuilder,\n type ContextSpecs,\n generateMutatorImports,\n type GeneratorMutator,\n type GeneratorVerbOptions,\n getFileInfo,\n getFullRoute,\n jsDoc,\n type NormalizedOutputOptions,\n pascal,\n upath,\n} from '@orval/core';\nimport { generateClient, generateFetchHeader } from '@orval/fetch';\nimport { generateZod } from '@orval/zod';\nimport type { InfoObject } from 'openapi3-ts/oas30';\n\nconst getHeader = (\n option: false | ((info: InfoObject) => string | string[]),\n info: InfoObject,\n): string => {\n if (!option) {\n return '';\n }\n\n const header = option(info);\n\n return Array.isArray(header) ? jsDoc({ description: header }) : header;\n};\n\nexport const getMcpHeader: ClientHeaderBuilder = ({\n verbOptions,\n output,\n clientImplementation,\n}) => {\n const targetInfo = getFileInfo(output.target);\n const schemaInfo = getFileInfo(output.schemas);\n\n const relativeSchemaImportPath = output.schemas\n ? upath.relativeSafe(targetInfo.dirname, schemaInfo.dirname)\n : './' + targetInfo.filename + '.schemas';\n\n const importSchemaNames = Object.values(verbOptions)\n .flatMap((verbOption) => {\n const imports = [];\n const pascalOperationName = pascal(verbOption.operationName);\n\n if (verbOption.queryParams) {\n imports.push(`${pascalOperationName}Params`);\n }\n\n if (verbOption.body.definition) {\n imports.push(`${pascalOperationName}Body`);\n }\n\n return imports;\n })\n .reduce<string[]>((acc, name) => {\n if (!acc.find((i) => i === name)) {\n acc.push(name);\n }\n return acc;\n }, []);\n\n const importSchemasImplementation = `import {\\n ${importSchemaNames.join(\n ',\\n ',\n )}\\n} from '${relativeSchemaImportPath}';\n`;\n\n const relativeFetchClientPath = './http-client';\n const importFetchClientNames = Object.values(verbOptions)\n .flatMap((verbOption) => verbOption.operationName)\n .reduce<string[]>((acc, name) => {\n if (!acc.find((i) => i === name)) {\n acc.push(name);\n }\n\n return acc;\n }, []);\n\n const importFetchClientImplementation = `import {\\n ${importFetchClientNames.join(\n ',\\n ',\n )}\\n} from '${relativeFetchClientPath}';\n `;\n\n const content = [\n importSchemasImplementation,\n importFetchClientImplementation,\n ].join('\\n');\n\n return content + '\\n';\n};\n\nexport const generateMcp: ClientBuilder = async (verbOptions, options) => {\n const handlerArgsTypes = [];\n const pathParamsType = verbOptions.params\n .map((param) => {\n const paramName = param.name.split(': ')[0];\n const paramType = param.implementation.split(': ')[1];\n return ` ${paramName}: ${paramType}`;\n })\n .join(',\\n');\n if (pathParamsType) {\n handlerArgsTypes.push(` pathParams: {\\n${pathParamsType}\\n };`);\n }\n if (verbOptions.queryParams) {\n handlerArgsTypes.push(\n ` queryParams: ${verbOptions.queryParams.schema.name};`,\n );\n }\n if (verbOptions.body.definition) {\n handlerArgsTypes.push(` bodyParams: ${verbOptions.body.definition};`);\n }\n\n const handlerArgsName = `${verbOptions.operationName}Args`;\n const handlerArgsImplementation =\n handlerArgsTypes.length > 0\n ? `\nexport type ${handlerArgsName} = {\n${handlerArgsTypes.join('\\n')}\n}\n`\n : '';\n\n const fetchParams = [];\n if (verbOptions.params.length > 0) {\n const pathParamsArgs = verbOptions.params\n .map((param) => {\n const paramName = param.name.split(': ')[0];\n\n return `args.pathParams.${paramName}`;\n })\n .join(', ');\n\n fetchParams.push(pathParamsArgs);\n }\n if (verbOptions.body.definition) fetchParams.push(`args.bodyParams`);\n if (verbOptions.queryParams) fetchParams.push(`args.queryParams`);\n\n const handlerName = `${verbOptions.operationName}Handler`;\n const handlerImplementation = `\nexport const ${handlerName} = async (${handlerArgsTypes.length > 0 ? `args: ${handlerArgsName}` : ''}) => {\n const res = await ${verbOptions.operationName}(${fetchParams.join(', ')});\n\n return {\n content: [\n {\n type: 'text' as const,\n text: JSON.stringify(res),\n },\n ],\n };\n};`;\n\n const handlersImplementation = [\n handlerArgsImplementation,\n handlerImplementation,\n ].join('');\n\n return {\n implementation: handlersImplementation ? `${handlersImplementation}\\n` : '',\n imports: [],\n };\n};\n\nexport const generateServer = async (\n verbOptions: Record<string, GeneratorVerbOptions>,\n output: NormalizedOutputOptions,\n context: ContextSpecs,\n) => {\n const info = context.specs[context.specKey].info;\n const { extension, dirname } = getFileInfo(output.target);\n const serverPath = upath.join(dirname, `server${extension}`);\n const header = getHeader(output.override.header, info);\n\n const toolImplementations = Object.values(verbOptions)\n .map((verbOption) => {\n const imputSchemaTypes = [];\n if (verbOption.params.length > 0)\n imputSchemaTypes.push(\n ` pathParams: ${verbOption.operationName}Params`,\n );\n if (verbOption.queryParams)\n imputSchemaTypes.push(\n ` queryParams: ${verbOption.operationName}QueryParams`,\n );\n if (verbOption.body.definition)\n imputSchemaTypes.push(` bodyParams: ${verbOption.operationName}Body`);\n\n const imputSchemaImplementation =\n imputSchemaTypes.length > 0\n ? ` {\n ${imputSchemaTypes.join(',\\n ')}\n },`\n : '';\n\n const toolImplementation = `\nserver.tool(\n '${verbOption.operationName}',\n '${verbOption.summary}',${imputSchemaImplementation ? `\\n${imputSchemaImplementation}` : ''}\n ${verbOption.operationName}Handler\n);`;\n\n return toolImplementation;\n })\n .join('\\n');\n\n const importToolSchemas = Object.values(verbOptions)\n .flatMap((verbOption) => {\n const imports = [];\n\n if (verbOption.headers)\n imports.push(` ${verbOption.operationName}Header`);\n if (verbOption.params.length > 0)\n imports.push(` ${verbOption.operationName}Params`);\n if (verbOption.queryParams)\n imports.push(` ${verbOption.operationName}QueryParams`);\n if (verbOption.body.definition)\n imports.push(` ${verbOption.operationName}Body`);\n\n return imports;\n })\n .join(',\\n');\n const importToolSchemasImplementation = `import {\\n${importToolSchemas}\\n} from './tool-schemas.zod';`;\n\n const importHandlers = Object.values(verbOptions)\n .filter((verbOption) =>\n toolImplementations.includes(`${verbOption.operationName}Handler`),\n )\n .map((verbOption) => ` ${verbOption.operationName}Handler`)\n .join(`,\\n`);\n const importHandlersImplementation = `import {\\n${importHandlers}\\n} from './handlers';`;\n\n const importDependenciesImplementation = `import {\n McpServer\n} from '@modelcontextprotocol/sdk/server/mcp.js';\n \nimport {\n StdioServerTransport\n} from '@modelcontextprotocol/sdk/server/stdio.js'; \n`;\n const newMcpServerImplementation = `\nconst server = new McpServer({\n name: '${camel(info.title)}Server',\n version: '1.0.0',\n});\n`;\n const serverConnectImplementation = `\nconst transport = new StdioServerTransport();\n\nserver.connect(transport).then(() => {\n console.error('MCP server running on stdio');\n}).catch(console.error);\n`;\n\n const content = [\n header,\n importDependenciesImplementation,\n importHandlersImplementation,\n importToolSchemasImplementation,\n newMcpServerImplementation,\n toolImplementations,\n serverConnectImplementation,\n ].join('\\n');\n\n return [\n {\n content,\n path: serverPath,\n },\n ];\n};\n\nconst generateZodFiles = async (\n verbOptions: Record<string, GeneratorVerbOptions>,\n output: NormalizedOutputOptions,\n context: ContextSpecs,\n) => {\n const { extension, dirname, filename } = getFileInfo(output.target);\n\n const header = getHeader(\n output.override.header,\n context.specs[context.specKey].info,\n );\n\n const zods = await Promise.all(\n Object.values(verbOptions).map((verbOption) =>\n generateZod(\n verbOption,\n {\n route: verbOption.route,\n pathRoute: verbOption.pathRoute,\n override: output.override,\n context,\n mock: output.mock,\n output: output.target!,\n },\n output.client,\n ),\n ),\n );\n\n const allMutators = zods.reduce<Record<string, GeneratorMutator>>(\n (acc, z) => {\n for (const mutator of z.mutators ?? []) {\n acc[mutator.name] = mutator;\n }\n return acc;\n },\n {},\n );\n\n const mutatorsImports = generateMutatorImports({\n mutators: Object.values(allMutators),\n });\n\n let content = `${header}import { z as zod } from 'zod';\\n${mutatorsImports}\\n`;\n\n const zodPath = upath.join(dirname, `tool-schemas.zod${extension}`);\n\n content += zods.map((zod) => zod.implementation).join('\\n');\n\n return [\n {\n content,\n path: zodPath,\n },\n ];\n};\n\nconst generateHttpClinetFiles = async (\n verbOptions: Record<string, GeneratorVerbOptions>,\n output: NormalizedOutputOptions,\n context: ContextSpecs,\n) => {\n const { extension, dirname, filename } = getFileInfo(output.target);\n\n const header = getHeader(\n output.override.header,\n context.specs[context.specKey].info,\n );\n\n const clients = await Promise.all(\n Object.values(verbOptions).map((verbOption) => {\n const fullRoute = getFullRoute(\n verbOption.route,\n context.specs[context.specKey].servers,\n output.baseUrl,\n );\n\n const options = {\n route: fullRoute,\n pathRoute: verbOption.pathRoute,\n override: output.override,\n context,\n mock: output.mock,\n output: output.target!,\n };\n\n return generateClient(verbOption, options, output.client, output);\n }),\n );\n\n const clientImplementation = clients\n .map((client) => client.implementation)\n .join('\\n');\n\n const relativeSchemasPath = output.schemas\n ? upath.relativeSafe(dirname, getFileInfo(output.schemas).dirname)\n : './' + filename + '.schemas';\n const importNames = clients\n .flatMap((client) => client.imports)\n .reduce<string[]>((acc, imp) => {\n if (!acc.find((i) => i === imp.name)) {\n acc.push(imp.name);\n }\n\n return acc;\n }, []);\n const importImplementation = `import { ${importNames.join(\n ',\\n',\n )} } from '${relativeSchemasPath}';`;\n\n const fetchHeader = generateFetchHeader({\n title: '',\n isRequestOptions: false,\n isMutator: false,\n noFunction: false,\n isGlobalMutator: false,\n provideIn: false,\n hasAwaitedType: false,\n output,\n verbOptions,\n clientImplementation,\n });\n\n const content = [\n header,\n importImplementation,\n fetchHeader,\n clientImplementation,\n ].join('\\n');\n const outputPath = upath.join(dirname, `http-client${extension}`);\n\n return [\n {\n content,\n path: outputPath,\n },\n ];\n};\n\nexport const generateExtraFiles: ClientExtraFilesBuilder = async (\n verbOptions,\n output,\n context,\n) => {\n const [server, zods, httpClients] = await Promise.all([\n generateServer(verbOptions, output, context),\n generateZodFiles(verbOptions, output, context),\n generateHttpClinetFiles(verbOptions, output, context),\n ]);\n\n return [...server, ...zods, ...httpClients];\n};\n\nconst mcpClientBuilder: ClientGeneratorsBuilder = {\n client: generateMcp,\n header: getMcpHeader,\n extraFiles: generateExtraFiles,\n};\n\nexport const builder = () => () => mcpClientBuilder;\n\nexport default builder;\n"],"mappings":";;;;;AAqBA,MAAM,aACJ,QACA,SACW;AACX,KAAI,CAAC,OACH,QAAO;CAGT,MAAM,SAAS,OAAO,KAAK;AAE3B,QAAO,MAAM,QAAQ,OAAO,GAAG,MAAM,EAAE,aAAa,QAAQ,CAAC,GAAG;;AAGlE,MAAaA,gBAAqC,EAChD,aACA,QACA,2BACI;CACJ,MAAM,aAAa,YAAY,OAAO,OAAO;CAC7C,MAAM,aAAa,YAAY,OAAO,QAAQ;CAE9C,MAAM,2BAA2B,OAAO,UACpC,MAAM,aAAa,WAAW,SAAS,WAAW,QAAQ,GAC1D,OAAO,WAAW,WAAW;AAkDjC,QALgB,CArBoB,eAtBV,OAAO,OAAO,YAAY,CACjD,SAAS,eAAe;EACvB,MAAM,UAAU,EAAE;EAClB,MAAM,sBAAsB,OAAO,WAAW,cAAc;AAE5D,MAAI,WAAW,YACb,SAAQ,KAAK,GAAG,oBAAoB,QAAQ;AAG9C,MAAI,WAAW,KAAK,WAClB,SAAQ,KAAK,GAAG,oBAAoB,MAAM;AAG5C,SAAO;GACP,CACD,QAAkB,KAAK,SAAS;AAC/B,MAAI,CAAC,IAAI,MAAM,MAAM,MAAM,KAAK,CAC9B,KAAI,KAAK,KAAK;AAEhB,SAAO;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