@autoview/cli 0.1.0

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.
Files changed (297) hide show
  1. package/LICENSE +661 -0
  2. package/README.md +407 -0
  3. package/lib/AutoViewAgent.d.ts +109 -0
  4. package/lib/AutoViewAgent.js +123 -0
  5. package/lib/AutoViewAgent.js.map +1 -0
  6. package/lib/agent/emitMcpServer.d.ts +15 -0
  7. package/lib/agent/emitMcpServer.js +157 -0
  8. package/lib/agent/emitMcpServer.js.map +1 -0
  9. package/lib/agent/emitReport.d.ts +14 -0
  10. package/lib/agent/emitReport.js +85 -0
  11. package/lib/agent/emitReport.js.map +1 -0
  12. package/lib/agent/toolSurface.d.ts +130 -0
  13. package/lib/agent/toolSurface.js +342 -0
  14. package/lib/agent/toolSurface.js.map +1 -0
  15. package/lib/agent/verifyAgentTasks.d.ts +87 -0
  16. package/lib/agent/verifyAgentTasks.js +126 -0
  17. package/lib/agent/verifyAgentTasks.js.map +1 -0
  18. package/lib/cli/main.d.ts +2 -0
  19. package/lib/cli/main.js +295 -0
  20. package/lib/cli/main.js.map +1 -0
  21. package/lib/compiler/AutoViewInterfaceCompiler.d.ts +27 -0
  22. package/lib/compiler/AutoViewInterfaceCompiler.js +68 -0
  23. package/lib/compiler/AutoViewInterfaceCompiler.js.map +1 -0
  24. package/lib/constants/AutoViewFrontendTemplate.d.ts +1 -0
  25. package/lib/constants/AutoViewFrontendTemplate.js +46 -0
  26. package/lib/constants/AutoViewFrontendTemplate.js.map +1 -0
  27. package/lib/constants/AutoViewSystemPromptConstant.d.ts +5 -0
  28. package/lib/constants/AutoViewSystemPromptConstant.js +4 -0
  29. package/lib/constants/AutoViewSystemPromptConstant.js.map +1 -0
  30. package/lib/context/IAutoViewAgentContext.d.ts +60 -0
  31. package/lib/context/IAutoViewAgentContext.js +3 -0
  32. package/lib/context/IAutoViewAgentContext.js.map +1 -0
  33. package/lib/fromSwagger.d.ts +53 -0
  34. package/lib/fromSwagger.js +513 -0
  35. package/lib/fromSwagger.js.map +1 -0
  36. package/lib/generateDeterministic.d.ts +26 -0
  37. package/lib/generateDeterministic.js +75 -0
  38. package/lib/generateDeterministic.js.map +1 -0
  39. package/lib/index.d.ts +15 -0
  40. package/lib/index.js +41 -0
  41. package/lib/index.js.map +1 -0
  42. package/lib/orchestrate/orchestrateAutoView.d.ts +17 -0
  43. package/lib/orchestrate/orchestrateAutoView.js +491 -0
  44. package/lib/orchestrate/orchestrateAutoView.js.map +1 -0
  45. package/lib/orchestrate/orchestrateAutoViewProductPlan.d.ts +37 -0
  46. package/lib/orchestrate/orchestrateAutoViewProductPlan.js +109 -0
  47. package/lib/orchestrate/orchestrateAutoViewProductPlan.js.map +1 -0
  48. package/lib/orchestrate/orchestrateAutoViewRender.d.ts +133 -0
  49. package/lib/orchestrate/orchestrateAutoViewRender.js +943 -0
  50. package/lib/orchestrate/orchestrateAutoViewRender.js.map +1 -0
  51. package/lib/orchestrate/orchestrateAutoViewRenderDeterministic.d.ts +24 -0
  52. package/lib/orchestrate/orchestrateAutoViewRenderDeterministic.js +92 -0
  53. package/lib/orchestrate/orchestrateAutoViewRenderDeterministic.js.map +1 -0
  54. package/lib/orchestrate/orchestrateAutoViewReview.d.ts +48 -0
  55. package/lib/orchestrate/orchestrateAutoViewReview.js +328 -0
  56. package/lib/orchestrate/orchestrateAutoViewReview.js.map +1 -0
  57. package/lib/orchestrate/orchestrateAutoViewScaffold.d.ts +45 -0
  58. package/lib/orchestrate/orchestrateAutoViewScaffold.js +586 -0
  59. package/lib/orchestrate/orchestrateAutoViewScaffold.js.map +1 -0
  60. package/lib/orchestrate/orchestrateAutoViewSdkStudy.d.ts +26 -0
  61. package/lib/orchestrate/orchestrateAutoViewSdkStudy.js +85 -0
  62. package/lib/orchestrate/orchestrateAutoViewSdkStudy.js.map +1 -0
  63. package/lib/orchestrate/structures/IAutoViewProductPlan.d.ts +96 -0
  64. package/lib/orchestrate/structures/IAutoViewProductPlan.js +3 -0
  65. package/lib/orchestrate/structures/IAutoViewProductPlan.js.map +1 -0
  66. package/lib/orchestrate/structures/IAutoViewProductPlanApplication.d.ts +38 -0
  67. package/lib/orchestrate/structures/IAutoViewProductPlanApplication.js +3 -0
  68. package/lib/orchestrate/structures/IAutoViewProductPlanApplication.js.map +1 -0
  69. package/lib/orchestrate/structures/IAutoViewRenderApplication.d.ts +38 -0
  70. package/lib/orchestrate/structures/IAutoViewRenderApplication.js +3 -0
  71. package/lib/orchestrate/structures/IAutoViewRenderApplication.js.map +1 -0
  72. package/lib/orchestrate/structures/IAutoViewReviewApplication.d.ts +40 -0
  73. package/lib/orchestrate/structures/IAutoViewReviewApplication.js +3 -0
  74. package/lib/orchestrate/structures/IAutoViewReviewApplication.js.map +1 -0
  75. package/lib/orchestrate/structures/IAutoViewSdkMap.d.ts +63 -0
  76. package/lib/orchestrate/structures/IAutoViewSdkMap.js +3 -0
  77. package/lib/orchestrate/structures/IAutoViewSdkMap.js.map +1 -0
  78. package/lib/orchestrate/structures/IAutoViewSdkStudyApplication.d.ts +37 -0
  79. package/lib/orchestrate/structures/IAutoViewSdkStudyApplication.js +3 -0
  80. package/lib/orchestrate/structures/IAutoViewSdkStudyApplication.js.map +1 -0
  81. package/lib/orchestrate/utils/HistoryMessage.d.ts +10 -0
  82. package/lib/orchestrate/utils/HistoryMessage.js +25 -0
  83. package/lib/orchestrate/utils/HistoryMessage.js.map +1 -0
  84. package/lib/orchestrate/utils/auditFrontendRuntime.d.ts +53 -0
  85. package/lib/orchestrate/utils/auditFrontendRuntime.js +362 -0
  86. package/lib/orchestrate/utils/auditFrontendRuntime.js.map +1 -0
  87. package/lib/orchestrate/utils/buildDeterministicPlan.d.ts +4 -0
  88. package/lib/orchestrate/utils/buildDeterministicPlan.js +233 -0
  89. package/lib/orchestrate/utils/buildDeterministicPlan.js.map +1 -0
  90. package/lib/orchestrate/utils/buildDeterministicSdkMap.d.ts +22 -0
  91. package/lib/orchestrate/utils/buildDeterministicSdkMap.js +154 -0
  92. package/lib/orchestrate/utils/buildDeterministicSdkMap.js.map +1 -0
  93. package/lib/orchestrate/utils/cacheNodeModules.d.ts +31 -0
  94. package/lib/orchestrate/utils/cacheNodeModules.js +134 -0
  95. package/lib/orchestrate/utils/cacheNodeModules.js.map +1 -0
  96. package/lib/orchestrate/utils/describeEndpointPropsShape.d.ts +37 -0
  97. package/lib/orchestrate/utils/describeEndpointPropsShape.js +192 -0
  98. package/lib/orchestrate/utils/describeEndpointPropsShape.js.map +1 -0
  99. package/lib/orchestrate/utils/describeEndpointRequestBodyShape.d.ts +22 -0
  100. package/lib/orchestrate/utils/describeEndpointRequestBodyShape.js +29 -0
  101. package/lib/orchestrate/utils/describeEndpointRequestBodyShape.js.map +1 -0
  102. package/lib/orchestrate/utils/describeEndpointResponseShape.d.ts +19 -0
  103. package/lib/orchestrate/utils/describeEndpointResponseShape.js +30 -0
  104. package/lib/orchestrate/utils/describeEndpointResponseShape.js.map +1 -0
  105. package/lib/orchestrate/utils/executeCachedBatch.d.ts +22 -0
  106. package/lib/orchestrate/utils/executeCachedBatch.js +64 -0
  107. package/lib/orchestrate/utils/executeCachedBatch.js.map +1 -0
  108. package/lib/orchestrate/utils/loadShoppingFixture.d.ts +33 -0
  109. package/lib/orchestrate/utils/loadShoppingFixture.js +17 -0
  110. package/lib/orchestrate/utils/loadShoppingFixture.js.map +1 -0
  111. package/lib/orchestrate/utils/normalizeProductPlanPaths.d.ts +24 -0
  112. package/lib/orchestrate/utils/normalizeProductPlanPaths.js +77 -0
  113. package/lib/orchestrate/utils/normalizeProductPlanPaths.js.map +1 -0
  114. package/lib/orchestrate/utils/renderJsonSchema.d.ts +23 -0
  115. package/lib/orchestrate/utils/renderJsonSchema.js +122 -0
  116. package/lib/orchestrate/utils/renderJsonSchema.js.map +1 -0
  117. package/lib/orchestrate/utils/renderResourcePage.d.ts +36 -0
  118. package/lib/orchestrate/utils/renderResourcePage.js +1415 -0
  119. package/lib/orchestrate/utils/renderResourcePage.js.map +1 -0
  120. package/lib/orchestrate/utils/validateFrontendTypecheck.d.ts +109 -0
  121. package/lib/orchestrate/utils/validateFrontendTypecheck.js +274 -0
  122. package/lib/orchestrate/utils/validateFrontendTypecheck.js.map +1 -0
  123. package/lib/preview/renderPreview.d.ts +22 -0
  124. package/lib/preview/renderPreview.js +198 -0
  125. package/lib/preview/renderPreview.js.map +1 -0
  126. package/lib/typings/compiler.d.ts +39 -0
  127. package/lib/typings/compiler.js +3 -0
  128. package/lib/typings/compiler.js.map +1 -0
  129. package/lib/typings/events.d.ts +106 -0
  130. package/lib/typings/events.js +3 -0
  131. package/lib/typings/events.js.map +1 -0
  132. package/lib/typings/index.d.ts +10 -0
  133. package/lib/typings/index.js +27 -0
  134. package/lib/typings/index.js.map +1 -0
  135. package/lib/typings/misc.d.ts +78 -0
  136. package/lib/typings/misc.js +3 -0
  137. package/lib/typings/misc.js.map +1 -0
  138. package/lib/utils/ArrayUtil.d.ts +8 -0
  139. package/lib/utils/ArrayUtil.js +30 -0
  140. package/lib/utils/ArrayUtil.js.map +1 -0
  141. package/lib/utils/StringUtil.d.ts +11 -0
  142. package/lib/utils/StringUtil.js +28 -0
  143. package/lib/utils/StringUtil.js.map +1 -0
  144. package/lib/utils/classifyEndpoints.d.ts +62 -0
  145. package/lib/utils/classifyEndpoints.js +216 -0
  146. package/lib/utils/classifyEndpoints.js.map +1 -0
  147. package/lib/utils/endpointFilter.d.ts +26 -0
  148. package/lib/utils/endpointFilter.js +0 -0
  149. package/lib/utils/endpointFilter.js.map +1 -0
  150. package/lib/utils/extractFields.d.ts +85 -0
  151. package/lib/utils/extractFields.js +231 -0
  152. package/lib/utils/extractFields.js.map +1 -0
  153. package/lib/utils/index.d.ts +13 -0
  154. package/lib/utils/index.js +30 -0
  155. package/lib/utils/index.js.map +1 -0
  156. package/lib/utils/normalizeForNestia.d.ts +34 -0
  157. package/lib/utils/normalizeForNestia.js +133 -0
  158. package/lib/utils/normalizeForNestia.js.map +1 -0
  159. package/lib/utils/resourcePlan.d.ts +39 -0
  160. package/lib/utils/resourcePlan.js +95 -0
  161. package/lib/utils/resourcePlan.js.map +1 -0
  162. package/lib/utils/sliceDocument.d.ts +17 -0
  163. package/lib/utils/sliceDocument.js +114 -0
  164. package/lib/utils/sliceDocument.js.map +1 -0
  165. package/lib/utils/toEndpoints.d.ts +90 -0
  166. package/lib/utils/toEndpoints.js +227 -0
  167. package/lib/utils/toEndpoints.js.map +1 -0
  168. package/lib/verify/runWorkflows.d.ts +25 -0
  169. package/lib/verify/runWorkflows.js +366 -0
  170. package/lib/verify/runWorkflows.js.map +1 -0
  171. package/lib/verify/workflows.d.ts +53 -0
  172. package/lib/verify/workflows.js +107 -0
  173. package/lib/verify/workflows.js.map +1 -0
  174. package/package.json +82 -0
  175. package/prompts/AUTOVIEW_RENDER.md +398 -0
  176. package/prompts/AUTOVIEW_REVIEW.md +60 -0
  177. package/prompts/AUTOVIEW_SDK_STUDY.md +89 -0
  178. package/src/AutoViewAgent.ts +222 -0
  179. package/src/agent/emitMcpServer.integration.test.ts +168 -0
  180. package/src/agent/emitMcpServer.test.ts +51 -0
  181. package/src/agent/emitMcpServer.ts +178 -0
  182. package/src/agent/emitReport.ts +117 -0
  183. package/src/agent/toolSurface.test.ts +243 -0
  184. package/src/agent/toolSurface.ts +501 -0
  185. package/src/agent/verifyAgentTasks.test.ts +106 -0
  186. package/src/agent/verifyAgentTasks.ts +171 -0
  187. package/src/cli/main.ts +363 -0
  188. package/src/compiler/AutoViewInterfaceCompiler.ts +69 -0
  189. package/src/constants/AutoViewFrontendTemplate.ts +42 -0
  190. package/src/constants/AutoViewSystemPromptConstant.ts +6 -0
  191. package/src/context/IAutoViewAgentContext.ts +84 -0
  192. package/src/fromSwagger.test.ts +269 -0
  193. package/src/fromSwagger.ts +500 -0
  194. package/src/generateDeterministic.test.ts +39 -0
  195. package/src/generateDeterministic.ts +77 -0
  196. package/src/index.ts +30 -0
  197. package/src/orchestrate/orchestrateAutoView.ts +590 -0
  198. package/src/orchestrate/orchestrateAutoViewProductPlan.ts +121 -0
  199. package/src/orchestrate/orchestrateAutoViewRender.ts +1117 -0
  200. package/src/orchestrate/orchestrateAutoViewRenderDeterministic.ts +101 -0
  201. package/src/orchestrate/orchestrateAutoViewReview.ts +272 -0
  202. package/src/orchestrate/orchestrateAutoViewScaffold.ts +627 -0
  203. package/src/orchestrate/orchestrateAutoViewSdkStudy.ts +90 -0
  204. package/src/orchestrate/renderNavTs.test.ts +74 -0
  205. package/src/orchestrate/structures/IAutoViewProductPlan.ts +119 -0
  206. package/src/orchestrate/structures/IAutoViewProductPlanApplication.ts +41 -0
  207. package/src/orchestrate/structures/IAutoViewRenderApplication.ts +40 -0
  208. package/src/orchestrate/structures/IAutoViewReviewApplication.ts +42 -0
  209. package/src/orchestrate/structures/IAutoViewSdkMap.ts +72 -0
  210. package/src/orchestrate/structures/IAutoViewSdkStudyApplication.ts +40 -0
  211. package/src/orchestrate/utils/HistoryMessage.ts +41 -0
  212. package/src/orchestrate/utils/auditFrontendRuntime.test.ts +18 -0
  213. package/src/orchestrate/utils/auditFrontendRuntime.ts +454 -0
  214. package/src/orchestrate/utils/buildDeterministicPlan.test.ts +170 -0
  215. package/src/orchestrate/utils/buildDeterministicPlan.ts +289 -0
  216. package/src/orchestrate/utils/buildDeterministicSdkMap.test.ts +90 -0
  217. package/src/orchestrate/utils/buildDeterministicSdkMap.ts +169 -0
  218. package/src/orchestrate/utils/cacheNodeModules.ts +136 -0
  219. package/src/orchestrate/utils/describeEndpointPropsShape.test.ts +86 -0
  220. package/src/orchestrate/utils/describeEndpointPropsShape.ts +202 -0
  221. package/src/orchestrate/utils/describeEndpointRequestBodyShape.test.ts +87 -0
  222. package/src/orchestrate/utils/describeEndpointRequestBodyShape.ts +31 -0
  223. package/src/orchestrate/utils/describeEndpointResponseShape.test.ts +70 -0
  224. package/src/orchestrate/utils/describeEndpointResponseShape.ts +32 -0
  225. package/src/orchestrate/utils/executeCachedBatch.ts +59 -0
  226. package/src/orchestrate/utils/loadShoppingFixture.ts +52 -0
  227. package/src/orchestrate/utils/normalizeProductPlanPaths.ts +92 -0
  228. package/src/orchestrate/utils/renderJsonSchema.test.ts +162 -0
  229. package/src/orchestrate/utils/renderJsonSchema.ts +133 -0
  230. package/src/orchestrate/utils/renderResourcePage.test.ts +468 -0
  231. package/src/orchestrate/utils/renderResourcePage.ts +1624 -0
  232. package/src/orchestrate/utils/validateFrontendTypecheck.test.ts +32 -0
  233. package/src/orchestrate/utils/validateFrontendTypecheck.ts +335 -0
  234. package/src/preview/renderPreview.ts +273 -0
  235. package/src/typings/compiler.ts +47 -0
  236. package/src/typings/events.ts +155 -0
  237. package/src/typings/index.ts +10 -0
  238. package/src/typings/misc.ts +93 -0
  239. package/src/utils/ArrayUtil.ts +16 -0
  240. package/src/utils/StringUtil.ts +29 -0
  241. package/src/utils/classifyEndpoints.test.ts +86 -0
  242. package/src/utils/classifyEndpoints.ts +291 -0
  243. package/src/utils/endpointFilter.test.ts +50 -0
  244. package/src/utils/endpointFilter.ts +0 -0
  245. package/src/utils/extractFields.test.ts +82 -0
  246. package/src/utils/extractFields.ts +306 -0
  247. package/src/utils/index.ts +13 -0
  248. package/src/utils/normalizeForNestia.test.ts +93 -0
  249. package/src/utils/normalizeForNestia.ts +139 -0
  250. package/src/utils/resourcePlan.test.ts +104 -0
  251. package/src/utils/resourcePlan.ts +180 -0
  252. package/src/utils/sliceDocument.test.ts +85 -0
  253. package/src/utils/sliceDocument.ts +119 -0
  254. package/src/utils/toEndpoints.test.ts +251 -0
  255. package/src/utils/toEndpoints.ts +343 -0
  256. package/src/verify/runWorkflows.ts +403 -0
  257. package/src/verify/workflows.test.ts +117 -0
  258. package/src/verify/workflows.ts +154 -0
  259. package/template/CLAUDE.md +140 -0
  260. package/template/Dockerfile +31 -0
  261. package/template/PROMPT.md +80 -0
  262. package/template/SANDBOX.md +70 -0
  263. package/template/app/api/health/route.ts +10 -0
  264. package/template/app/globals.css +97 -0
  265. package/template/app/layout.tsx +30 -0
  266. package/template/app/page.tsx +19 -0
  267. package/template/components/AppShell.tsx +114 -0
  268. package/template/components/auto/CatalogGrid.tsx +159 -0
  269. package/template/components/auto/ConfirmButton.tsx +67 -0
  270. package/template/components/auto/EmbeddedCollection.tsx +144 -0
  271. package/template/components/auto/ResourceDashboard.tsx +104 -0
  272. package/template/components/auto/ResourceDetail.tsx +93 -0
  273. package/template/components/auto/ResourceForm.tsx +235 -0
  274. package/template/components/auto/ResourceIcon.tsx +88 -0
  275. package/template/components/auto/ResourceLanding.tsx +155 -0
  276. package/template/components/auto/ResourceTable.tsx +223 -0
  277. package/template/components/auto/formatValue.tsx +186 -0
  278. package/template/components/auto/types.ts +42 -0
  279. package/template/components/ui/badge.tsx +40 -0
  280. package/template/components/ui/button.tsx +57 -0
  281. package/template/components/ui/card.tsx +86 -0
  282. package/template/components/ui/dialog.tsx +119 -0
  283. package/template/components/ui/input.tsx +23 -0
  284. package/template/components/ui/label.tsx +24 -0
  285. package/template/components/ui/pagination.tsx +117 -0
  286. package/template/components/ui/select.tsx +92 -0
  287. package/template/components/ui/sheet.tsx +135 -0
  288. package/template/components/ui/skeleton.tsx +15 -0
  289. package/template/components/ui/table.tsx +120 -0
  290. package/template/components/ui/tabs.tsx +55 -0
  291. package/template/lib/utils.ts +35 -0
  292. package/template/next.config.mjs +52 -0
  293. package/template/package.json +46 -0
  294. package/template/postcss.config.js +6 -0
  295. package/template/scripts/start-shopping-backend.sh +56 -0
  296. package/template/tailwind.config.ts +96 -0
  297. package/template/tsconfig.json +29 -0
@@ -0,0 +1,157 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.emitMcpServer = emitMcpServer;
4
+ const toolSurface_1 = require("./toolSurface");
5
+ /**
6
+ * Emit a runnable MCP (Model Context Protocol) server from an OpenAPI document —
7
+ * the agent-facing counterpart of the generated frontend. The server exposes the
8
+ * shaped tool surface (read/write annotations + producer hints) and, on a tool
9
+ * call, executes the real API over HTTP against the configured backend.
10
+ *
11
+ * Returns a flat `path → content` project map (server + package.json + README),
12
+ * the same shape the frontend scaffold returns, so the CLI writes it the same
13
+ * way. Deterministic: same document → same server.
14
+ */
15
+ function emitMcpServer(document, options = { backend: null }) {
16
+ var _a, _b, _c;
17
+ const tools = (0, toolSurface_1.buildToolSurface)(document);
18
+ const coverage = (0, toolSurface_1.coverToolSurface)(tools);
19
+ const appName = ((_c = (_a = options.title) !== null && _a !== void 0 ? _a : (_b = document.info) === null || _b === void 0 ? void 0 : _b.title) !== null && _c !== void 0 ? _c : "API").trim() || "API";
20
+ // Only the fields the server needs at runtime (keep the bundle lean).
21
+ const runtimeTools = tools.map((t) => ({
22
+ name: t.name,
23
+ description: t.description,
24
+ inputSchema: t.inputSchema,
25
+ annotations: t.annotations,
26
+ operation: t.operation,
27
+ }));
28
+ return {
29
+ "server.mjs": renderServer(appName, options.backend, runtimeTools),
30
+ "package.json": renderPackageJson(appName),
31
+ "README.md": renderReadme(appName, options.backend, coverage),
32
+ };
33
+ }
34
+ function renderServer(appName, backend, tools) {
35
+ return `#!/usr/bin/env node
36
+ // MCP server generated by AutoView from the OpenAPI document of "${appName}".
37
+ // Exposes the API as agent-callable tools and executes calls against the live
38
+ // backend. Configure the backend with API_HOST / API_TOKEN env vars.
39
+
40
+ import { Server } from "@modelcontextprotocol/sdk/server/index.js";
41
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
42
+ import {
43
+ CallToolRequestSchema,
44
+ ListToolsRequestSchema,
45
+ } from "@modelcontextprotocol/sdk/types.js";
46
+
47
+ const TOOLS = ${JSON.stringify(tools, null, 2)};
48
+
49
+ const BASE = (process.env.API_HOST ?? ${JSON.stringify(backend !== null && backend !== void 0 ? backend : "")}).replace(/\\/$/, "");
50
+ const AUTH = process.env.API_TOKEN ?? "";
51
+
52
+ if (BASE.length === 0) {
53
+ console.error("Set API_HOST to the backend base URL (e.g. https://api.example.com).");
54
+ process.exit(1);
55
+ }
56
+
57
+ const server = new Server(
58
+ { name: ${JSON.stringify(appName + " (AutoView MCP)")}, version: "1.0.0" },
59
+ { capabilities: { tools: {} } },
60
+ );
61
+
62
+ server.setRequestHandler(ListToolsRequestSchema, async () => ({
63
+ tools: TOOLS.map((t) => ({
64
+ name: t.name,
65
+ description: t.description,
66
+ inputSchema: t.inputSchema,
67
+ annotations: t.annotations,
68
+ })),
69
+ }));
70
+
71
+ server.setRequestHandler(CallToolRequestSchema, async (req) => {
72
+ const tool = TOOLS.find((t) => t.name === req.params.name);
73
+ if (tool === undefined) {
74
+ return { content: [{ type: "text", text: "Unknown tool: " + req.params.name }], isError: true };
75
+ }
76
+ const args = req.params.arguments ?? {};
77
+ let path = tool.operation.path;
78
+ for (const p of tool.operation.pathParams) {
79
+ path = path.replace("{" + p + "}", encodeURIComponent(String(args[p] ?? "")));
80
+ }
81
+ const url = new URL(BASE + path);
82
+ if (tool.operation.hasQuery && args.query && typeof args.query === "object") {
83
+ for (const [k, v] of Object.entries(args.query)) {
84
+ if (v !== undefined && v !== null) url.searchParams.set(k, String(v));
85
+ }
86
+ }
87
+ const method = tool.operation.method;
88
+ try {
89
+ const res = await fetch(url, {
90
+ method,
91
+ headers: { "content-type": "application/json", ...(AUTH ? { authorization: AUTH } : {}) },
92
+ body: ["GET", "HEAD", "DELETE"].includes(method) ? undefined : JSON.stringify(args.body ?? {}),
93
+ });
94
+ const text = await res.text();
95
+ return { content: [{ type: "text", text: text.length > 0 ? text : "(empty) status " + res.status }], isError: !res.ok };
96
+ } catch (err) {
97
+ return { content: [{ type: "text", text: "Request failed: " + (err && err.message ? err.message : String(err)) }], isError: true };
98
+ }
99
+ });
100
+
101
+ await server.connect(new StdioServerTransport());
102
+ console.error(${JSON.stringify(appName)} + " MCP server ready (" + TOOLS.length + " tools) → " + BASE);
103
+ `;
104
+ }
105
+ function renderPackageJson(appName) {
106
+ const slug = appName.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "") || "api";
107
+ return JSON.stringify({
108
+ name: `${slug}-mcp`,
109
+ version: "1.0.0",
110
+ private: true,
111
+ type: "module",
112
+ bin: { [`${slug}-mcp`]: "./server.mjs" },
113
+ scripts: { start: "node server.mjs" },
114
+ dependencies: { "@modelcontextprotocol/sdk": "^1.0.0" },
115
+ }, null, 2);
116
+ }
117
+ function renderReadme(appName, backend, coverage) {
118
+ return [
119
+ `# ${appName} — MCP server`,
120
+ "",
121
+ "Generated by AutoView. Exposes the API as agent-callable tools (read/write",
122
+ "annotated, with producer hints) and executes calls against the live backend.",
123
+ "",
124
+ "## Run",
125
+ "",
126
+ "```bash",
127
+ "npm install",
128
+ `API_HOST=${backend !== null && backend !== void 0 ? backend : "https://api.example.com"} \\`,
129
+ ' API_TOKEN="Bearer <token>" \\',
130
+ " npm start",
131
+ "```",
132
+ "",
133
+ "## Wire into an agent (Claude Desktop / Cursor / Claude Code)",
134
+ "",
135
+ "```json",
136
+ JSON.stringify({
137
+ mcpServers: {
138
+ [appName.toLowerCase().replace(/[^a-z0-9]+/g, "-")]: {
139
+ command: "node",
140
+ args: ["server.mjs"],
141
+ env: { API_HOST: backend !== null && backend !== void 0 ? backend : "https://api.example.com", API_TOKEN: "Bearer <token>" },
142
+ },
143
+ },
144
+ }, null, 2),
145
+ "```",
146
+ "",
147
+ "## Surface",
148
+ "",
149
+ `- **${coverage.tools}** tools (${coverage.readTools} read, ${coverage.writeTools} write)`,
150
+ `- **${coverage.resolvedInputs}/${coverage.referenceInputs}** id inputs have a declared producer (navigable)`,
151
+ coverage.orphanInputs > 0
152
+ ? `- ⚠️ **${coverage.orphanInputs}** id inputs have NO producer in the API — an agent cannot obtain them from any tool (an API-design gap; see \`--report\`).`
153
+ : "- ✅ every id input is obtainable from another tool (fully navigable).",
154
+ "",
155
+ ].join("\n");
156
+ }
157
+ //# sourceMappingURL=emitMcpServer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"emitMcpServer.js","sourceRoot":"","sources":["../../src/agent/emitMcpServer.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BACf,IAAI,EAAE,CAAC,YAAY,CAAC;oBACpB,GAAG,EAAE,EAAE,QAAQ,EAAE,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,yBAAyB,EAAE,SAAS,EAAE,gBAAgB,EAAE;iBACrF;aACF;SACF,EACD,IAAI,EACJ,CAAC,CACF;QACD,KAAK;QACL,EAAE;QACF,YAAY;QACZ,EAAE;QACF,OAAO,QAAQ,CAAC,KAAK,aAAa,QAAQ,CAAC,SAAS,UAAU,QAAQ,CAAC,UAAU,SAAS;QAC1F,OAAO,QAAQ,CAAC,cAAc,IAAI,QAAQ,CAAC,eAAe,mDAAmD;QAC7G,QAAQ,CAAC,YAAY,GAAG,CAAC;YACvB,CAAC,CAAC,UAAU,QAAQ,CAAC,YAAY,6HAA6H;YAC9J,CAAC,CAAC,uEAAuE;QAC3E,EAAE;KACH,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { OpenApi } from "@typia/interface";
2
+ /**
3
+ * Consumability report — the deterministic, LLM-free verdict on whether an API
4
+ * can actually be driven as a product (by an agent or a generated UI).
5
+ *
6
+ * Unlike a contract test (which checks each endpoint in isolation), this checks
7
+ * the API as a *navigable graph*: every id input a tool needs should be
8
+ * obtainable from another tool. It is honest about its own limits — an id whose
9
+ * producing endpoint returns an un-introspectable inline schema is reported as
10
+ * "undetermined", not as a defect, so the report never falsely accuses an API.
11
+ *
12
+ * Returns Markdown. Pure and deterministic.
13
+ */
14
+ export declare function emitConsumabilityReport(document: OpenApi.IDocument): string;
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.emitConsumabilityReport = emitConsumabilityReport;
4
+ const toEndpoints_1 = require("../utils/toEndpoints");
5
+ const toolSurface_1 = require("./toolSurface");
6
+ /**
7
+ * Consumability report — the deterministic, LLM-free verdict on whether an API
8
+ * can actually be driven as a product (by an agent or a generated UI).
9
+ *
10
+ * Unlike a contract test (which checks each endpoint in isolation), this checks
11
+ * the API as a *navigable graph*: every id input a tool needs should be
12
+ * obtainable from another tool. It is honest about its own limits — an id whose
13
+ * producing endpoint returns an un-introspectable inline schema is reported as
14
+ * "undetermined", not as a defect, so the report never falsely accuses an API.
15
+ *
16
+ * Returns Markdown. Pure and deterministic.
17
+ */
18
+ function emitConsumabilityReport(document) {
19
+ var _a, _b;
20
+ const title = ((_b = (_a = document.info) === null || _a === void 0 ? void 0 : _a.title) !== null && _b !== void 0 ? _b : "API").trim() || "API";
21
+ const a = (0, toolSurface_1.analyzeConsumability)(document);
22
+ // Judgeable id inputs = those we can rule on: obtainable (resolved + nested)
23
+ // vs a genuine gap (orphan). userInput/untraceable are not entity-id gaps.
24
+ const obtainable = a.resolved + a.nested;
25
+ const denom = obtainable + a.orphan.length;
26
+ const navigable = denom > 0 ? Math.round((100 * obtainable) / denom) : 100;
27
+ const dropped = (0, toEndpoints_1.unsupportedOperations)(document);
28
+ const lines = [
29
+ `# Consumability report — ${title}`,
30
+ "",
31
+ "Can this API be driven as a product? Checked deterministically (no LLM) by",
32
+ "projecting the spec into an agent tool surface and verifying the call graph —",
33
+ "every id a tool needs should be obtainable from another tool.",
34
+ "",
35
+ "## Summary",
36
+ "",
37
+ `- **${a.tools}** operations (${a.readTools} read, ${a.writeTools} write); **${a.referenceInputs}** id inputs.`,
38
+ `- ✅ **${a.resolved}** inputs resolved — a list/search tool produces the id, and the surface tells the agent which one.`,
39
+ a.nested > 0
40
+ ? `- ✅ **${a.nested}** obtainable nested — the id appears inside a parent read's response (e.g. \`order\` → \`goods[].id\`); navigable, just not via a dedicated list tool.`
41
+ : null,
42
+ a.orphan.length === 0
43
+ ? "- ✅ **0** genuine orphan inputs."
44
+ : `- ⚠️ **${a.orphan.length}** orphan inputs — a required id NO endpoint can supply (design gap).`,
45
+ a.untraceable.length > 0
46
+ ? `- ❔ **${a.untraceable.length}** undetermined — the resource is read but no id could be traced in its (often inline) response; navigability not provable either way.`
47
+ : null,
48
+ a.userInputs.length > 0
49
+ ? `- 👤 **${a.userInputs.length}** caller-supplied keys (\`*_name\` / \`*_key\` / \`scope\` …) — not entity ids, so a missing producer is expected, not a gap.`
50
+ : null,
51
+ `- **Navigability (of judgeable inputs): ${navigable}%** (${obtainable}/${denom}).`,
52
+ dropped.length > 0
53
+ ? `- **${dropped.length}** operation(s) could not be exposed at all (unsupported shape).`
54
+ : null,
55
+ "",
56
+ ].filter((l) => l !== null);
57
+ if (a.orphan.length > 0) {
58
+ lines.push("## ⚠️ Orphan inputs (genuine design gaps)", "", "These tools require an id, but **no endpoint reads that resource** — nothing", "in the API can supply the value. An agent or UI cannot call them without an", "out-of-band id. Usually a missing list/detail endpoint, or an id named", "inconsistently with its resource.", "");
59
+ for (const o of a.orphan.slice(0, 50)) {
60
+ lines.push(`- \`${o.tool}\` needs \`${o.param}\` (a \`${o.resource}\` id) — no endpoint produces it.`);
61
+ }
62
+ if (a.orphan.length > 50)
63
+ lines.push(`- …and ${a.orphan.length - 50} more.`);
64
+ lines.push("");
65
+ }
66
+ if (a.untraceable.length > 0) {
67
+ lines.push("## ❔ Undetermined inputs", "", "The resource has a read endpoint, but its response is an inline schema this", "analysis does not model, so the producer link could not be traced. Not a", "reported defect — likely fine, just not machine-verified here.", "", `- ${a.untraceable.length} inputs across ${new Set(a.untraceable.map((u) => u.resource)).size} resources (e.g. ${[...new Set(a.untraceable.slice(0, 5).map((u) => u.resource))].join(", ")}).`, "");
68
+ }
69
+ if (a.userInputs.length > 0) {
70
+ lines.push("## 👤 Caller-supplied keys", "", "These path params are human-known keys (a name, a `scope`, a `template_key`),", "not entity ids chained from another endpoint. The caller already knows the", "value, so the absence of a producing tool is by design — not a gap.", "", `- ${a.userInputs.length} inputs across ${new Set(a.userInputs.map((u) => u.param)).size} key(s) (e.g. ${[...new Set(a.userInputs.slice(0, 6).map((u) => `\`${u.param}\``))].join(", ")}).`, "");
71
+ }
72
+ if (dropped.length > 0) {
73
+ lines.push("## Unexposed operations", "");
74
+ for (const d of dropped.slice(0, 20))
75
+ lines.push(`- \`${d.method} ${d.path}\` — ${d.reason}`);
76
+ if (dropped.length > 20)
77
+ lines.push(`- …and ${dropped.length - 20} more.`);
78
+ lines.push("");
79
+ }
80
+ lines.push("## Verdict", "", a.orphan.length === 0
81
+ ? "✅ No genuine consumability gaps found — every id a tool needs is obtainable from the API (within what could be analyzed)."
82
+ : `⚠️ ${a.orphan.length} input(s) cannot be supplied by the API. Add the missing list/detail endpoints (or align id field names) so every id is obtainable, then re-run.`, "");
83
+ return lines.join("\n");
84
+ }
85
+ //# sourceMappingURL=emitReport.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"emitReport.js","sourceRoot":"","sources":["../../src/agent/emitReport.ts"],"names":[],"mappings":";;AAiBA,0DAmGC;AAlHD,sDAA6D;AAC7D,+CAAqD;AAErD;;;;;;;;;;;GAWG;AACH,SAAgB,uBAAuB,CAAC,QAA2B;;IACjE,MAAM,KAAK,GAAG,CAAC,MAAA,MAAA,QAAQ,CAAC,IAAI,0CAAE,KAAK,mCAAI,KAAK,CAAC,CAAC,IAAI,EAAE,IAAI,KAAK,CAAC;IAC9D,MAAM,CAAC,GAAG,IAAA,kCAAoB,EAAC,QAAQ,CAAC,CAAC;IACzC,6EAA6E;IAC7E,2EAA2E;IAC3E,MAAM,UAAU,GAAG,CAAC,CAAC,QAAQ,GAAG,CAAC,CAAC,MAAM,CAAC;IACzC,MAAM,KAAK,GAAG,UAAU,GAAG,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC;IAC3C,MAAM,SAAS,GAAG,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,GAAG,UAAU,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;IAC3E,MAAM,OAAO,GAAG,IAAA,mCAAqB,EAAC,QAAQ,CAAC,CAAC;IAEhD,MAAM,KAAK,GAAa;QACtB,4BAA4B,KAAK,E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+ import { OpenApi } from "@typia/interface";
2
+ /**
3
+ * Agent tool surface — the deterministic projection of the API's semantic model
4
+ * (IR) into a set of agent-callable tools (MCP / function-calling shape).
5
+ *
6
+ * The same IR that drives the human frontend drives this: resource roles
7
+ * (read vs write), the resource hierarchy, and the producer→consumer chain (which
8
+ * tool's output supplies a given tool's id input). A naive OpenAPI→tools dump
9
+ * has none of that — it emits a flat bag of operations. This emits tools that
10
+ * carry:
11
+ *
12
+ * - `annotations.readOnlyHint` / `destructiveHint` — safety, so an agent (or its
13
+ * guardrails) can tell a read from a mutation without parsing prose.
14
+ * - per-input producer hints — "this `saleId` comes from the `sales.index`
15
+ * tool's `id` field" — so the chain is explicit, not inferred.
16
+ * - only renderable operations (path fragments like `/x#y` that nestia cannot
17
+ * express as a typed call are dropped — `toEndpoints` already excludes them).
18
+ *
19
+ * Pure and deterministic: same document → same tool surface.
20
+ */
21
+ export interface IAgentTool {
22
+ /** Dotted accessor, unique and a valid tool name (`shoppings.sales.index`). */
23
+ name: string;
24
+ description: string;
25
+ /** JSON Schema for the call arguments. */
26
+ inputSchema: {
27
+ type: "object";
28
+ properties: Record<string, unknown>;
29
+ required: string[];
30
+ };
31
+ /** MCP-style behavior hints. */
32
+ annotations: {
33
+ readOnlyHint: boolean;
34
+ destructiveHint: boolean;
35
+ idempotentHint: boolean;
36
+ };
37
+ /** Execution descriptor — how an MCP server / executor invokes the real API. */
38
+ operation: {
39
+ method: string;
40
+ path: string;
41
+ pathParams: string[];
42
+ hasQuery: boolean;
43
+ hasBody: boolean;
44
+ };
45
+ /**
46
+ * Producer links: for each id-like path param, the tool + field that produces
47
+ * its value. Empty when the surface could not resolve a producer.
48
+ */
49
+ producers: Array<{
50
+ param: string;
51
+ tool: string;
52
+ field: string;
53
+ }>;
54
+ }
55
+ /**
56
+ * Build the agent tool surface from an OpenAPI document.
57
+ */
58
+ export declare function buildToolSurface(document: OpenApi.IDocument): IAgentTool[];
59
+ /**
60
+ * Honest consumability analysis with a 4-way split per path-param input, so the
61
+ * report never accuses an API of a design gap it cannot actually prove:
62
+ *
63
+ * - `resolved` — a collection read (list/search) produces the id; the tool
64
+ * surface declares that producer. Directly navigable, and the agent is told
65
+ * exactly where the id comes from.
66
+ * - `nested` — the id is obtainable nested inside a parent read's response
67
+ * (`order` → `goods[].id`, `sale` → `units[].stocks[].id`), but no dedicated
68
+ * list tool produces it. Navigable, just not via a single tool — counted
69
+ * honestly, separate from `resolved` so the report matches the tool surface.
70
+ * - `untraceable`— the resource HAS a read endpoint, but no id could be found in
71
+ * its response (e.g. an inline schema this analysis can't fully introspect).
72
+ * Undetermined, not blamed.
73
+ * - `userInput` — the param is not an entity id but a human-known key
74
+ * (`repository_name`, `template_key`, a `scope`/`slug`), supplied by the
75
+ * caller — a missing producer is expected, NOT a defect.
76
+ * - `orphan` — an entity id (`*_id` / `uuid`) that NO endpoint produces. A
77
+ * genuine consumability defect.
78
+ */
79
+ export interface IConsumabilityAnalysis {
80
+ tools: number;
81
+ readTools: number;
82
+ writeTools: number;
83
+ referenceInputs: number;
84
+ resolved: number;
85
+ nested: number;
86
+ untraceable: Array<{
87
+ tool: string;
88
+ param: string;
89
+ resource: string;
90
+ }>;
91
+ userInputs: Array<{
92
+ tool: string;
93
+ param: string;
94
+ resource: string;
95
+ }>;
96
+ orphan: Array<{
97
+ tool: string;
98
+ param: string;
99
+ resource: string;
100
+ }>;
101
+ }
102
+ export declare function analyzeConsumability(document: OpenApi.IDocument): IConsumabilityAnalysis;
103
+ /** Coverage summary of a tool surface — how navigable it is for an agent. */
104
+ export interface IToolSurfaceCoverage {
105
+ tools: number;
106
+ /** Tools tagged read vs write. */
107
+ readTools: number;
108
+ writeTools: number;
109
+ /** id-like path-param inputs across the surface. */
110
+ referenceInputs: number;
111
+ /** reference inputs with a declared producer (the navigable fraction). */
112
+ resolvedInputs: number;
113
+ /** reference inputs with no producer — an agent must guess where they come from. */
114
+ orphanInputs: number;
115
+ /**
116
+ * The orphan inputs in detail: a required id with no tool in the API that
117
+ * produces it. An agent (or a human) cannot obtain this value from any
118
+ * endpoint — a consumability defect in the API design.
119
+ */
120
+ orphans: Array<{
121
+ tool: string;
122
+ param: string;
123
+ }>;
124
+ }
125
+ /**
126
+ * Deterministic structural coverage of a tool surface — the LLM-independent
127
+ * verification: is the tool graph navigable (every id input has a declared
128
+ * producer)? Reported as a report card, distinct from running an agent.
129
+ */
130
+ export declare function coverToolSurface(tools: IAgentTool[]): IToolSurfaceCoverage;