mcp-openapi 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 (114) hide show
  1. package/README.md +351 -0
  2. package/dist/bin/mcp-openapi.d.ts +3 -0
  3. package/dist/bin/mcp-openapi.d.ts.map +1 -0
  4. package/dist/bin/mcp-openapi.js +26 -0
  5. package/dist/bin/mcp-openapi.js.map +1 -0
  6. package/dist/src/auth/api-key.d.ts +10 -0
  7. package/dist/src/auth/api-key.d.ts.map +1 -0
  8. package/dist/src/auth/api-key.js +23 -0
  9. package/dist/src/auth/api-key.js.map +1 -0
  10. package/dist/src/auth/auth-manager.d.ts +4 -0
  11. package/dist/src/auth/auth-manager.d.ts.map +1 -0
  12. package/dist/src/auth/auth-manager.js +36 -0
  13. package/dist/src/auth/auth-manager.js.map +1 -0
  14. package/dist/src/auth/bearer.d.ts +8 -0
  15. package/dist/src/auth/bearer.d.ts.map +1 -0
  16. package/dist/src/auth/bearer.js +16 -0
  17. package/dist/src/auth/bearer.js.map +1 -0
  18. package/dist/src/auth/index.d.ts +3 -0
  19. package/dist/src/auth/index.d.ts.map +1 -0
  20. package/dist/src/auth/index.js +2 -0
  21. package/dist/src/auth/index.js.map +1 -0
  22. package/dist/src/auth/oauth2.d.ts +14 -0
  23. package/dist/src/auth/oauth2.d.ts.map +1 -0
  24. package/dist/src/auth/oauth2.js +59 -0
  25. package/dist/src/auth/oauth2.js.map +1 -0
  26. package/dist/src/auth/types.d.ts +5 -0
  27. package/dist/src/auth/types.d.ts.map +1 -0
  28. package/dist/src/auth/types.js +2 -0
  29. package/dist/src/auth/types.js.map +1 -0
  30. package/dist/src/config/cli-args.d.ts +5 -0
  31. package/dist/src/config/cli-args.d.ts.map +1 -0
  32. package/dist/src/config/cli-args.js +154 -0
  33. package/dist/src/config/cli-args.js.map +1 -0
  34. package/dist/src/config/index.d.ts +4 -0
  35. package/dist/src/config/index.d.ts.map +1 -0
  36. package/dist/src/config/index.js +3 -0
  37. package/dist/src/config/index.js.map +1 -0
  38. package/dist/src/config/types.d.ts +46 -0
  39. package/dist/src/config/types.d.ts.map +1 -0
  40. package/dist/src/config/types.js +7 -0
  41. package/dist/src/config/types.js.map +1 -0
  42. package/dist/src/executor/http-client.d.ts +14 -0
  43. package/dist/src/executor/http-client.d.ts.map +1 -0
  44. package/dist/src/executor/http-client.js +59 -0
  45. package/dist/src/executor/http-client.js.map +1 -0
  46. package/dist/src/executor/index.d.ts +7 -0
  47. package/dist/src/executor/index.d.ts.map +1 -0
  48. package/dist/src/executor/index.js +4 -0
  49. package/dist/src/executor/index.js.map +1 -0
  50. package/dist/src/executor/request-builder.d.ts +15 -0
  51. package/dist/src/executor/request-builder.d.ts.map +1 -0
  52. package/dist/src/executor/request-builder.js +60 -0
  53. package/dist/src/executor/request-builder.js.map +1 -0
  54. package/dist/src/executor/response-mapper.d.ts +10 -0
  55. package/dist/src/executor/response-mapper.d.ts.map +1 -0
  56. package/dist/src/executor/response-mapper.js +54 -0
  57. package/dist/src/executor/response-mapper.js.map +1 -0
  58. package/dist/src/executor/types.d.ts +8 -0
  59. package/dist/src/executor/types.d.ts.map +1 -0
  60. package/dist/src/executor/types.js +2 -0
  61. package/dist/src/executor/types.js.map +1 -0
  62. package/dist/src/generator/index.d.ts +6 -0
  63. package/dist/src/generator/index.d.ts.map +1 -0
  64. package/dist/src/generator/index.js +4 -0
  65. package/dist/src/generator/index.js.map +1 -0
  66. package/dist/src/generator/param-builder.d.ts +17 -0
  67. package/dist/src/generator/param-builder.d.ts.map +1 -0
  68. package/dist/src/generator/param-builder.js +110 -0
  69. package/dist/src/generator/param-builder.js.map +1 -0
  70. package/dist/src/generator/tool-generator.d.ts +22 -0
  71. package/dist/src/generator/tool-generator.d.ts.map +1 -0
  72. package/dist/src/generator/tool-generator.js +66 -0
  73. package/dist/src/generator/tool-generator.js.map +1 -0
  74. package/dist/src/generator/tool-namer.d.ts +10 -0
  75. package/dist/src/generator/tool-namer.d.ts.map +1 -0
  76. package/dist/src/generator/tool-namer.js +44 -0
  77. package/dist/src/generator/tool-namer.js.map +1 -0
  78. package/dist/src/index.d.ts +7 -0
  79. package/dist/src/index.d.ts.map +1 -0
  80. package/dist/src/index.js +4 -0
  81. package/dist/src/index.js.map +1 -0
  82. package/dist/src/parser/index.d.ts +5 -0
  83. package/dist/src/parser/index.d.ts.map +1 -0
  84. package/dist/src/parser/index.js +4 -0
  85. package/dist/src/parser/index.js.map +1 -0
  86. package/dist/src/parser/openapi-parser.d.ts +3 -0
  87. package/dist/src/parser/openapi-parser.d.ts.map +1 -0
  88. package/dist/src/parser/openapi-parser.js +287 -0
  89. package/dist/src/parser/openapi-parser.js.map +1 -0
  90. package/dist/src/parser/schema-converter.d.ts +7 -0
  91. package/dist/src/parser/schema-converter.d.ts.map +1 -0
  92. package/dist/src/parser/schema-converter.js +86 -0
  93. package/dist/src/parser/schema-converter.js.map +1 -0
  94. package/dist/src/parser/spec-loader.d.ts +6 -0
  95. package/dist/src/parser/spec-loader.d.ts.map +1 -0
  96. package/dist/src/parser/spec-loader.js +53 -0
  97. package/dist/src/parser/spec-loader.js.map +1 -0
  98. package/dist/src/parser/types.d.ts +72 -0
  99. package/dist/src/parser/types.d.ts.map +1 -0
  100. package/dist/src/parser/types.js +2 -0
  101. package/dist/src/parser/types.js.map +1 -0
  102. package/dist/src/server.d.ts +9 -0
  103. package/dist/src/server.d.ts.map +1 -0
  104. package/dist/src/server.js +61 -0
  105. package/dist/src/server.js.map +1 -0
  106. package/dist/src/utils/errors.d.ts +19 -0
  107. package/dist/src/utils/errors.d.ts.map +1 -0
  108. package/dist/src/utils/errors.js +37 -0
  109. package/dist/src/utils/errors.js.map +1 -0
  110. package/dist/src/utils/logger.d.ts +8 -0
  111. package/dist/src/utils/logger.d.ts.map +1 -0
  112. package/dist/src/utils/logger.js +12 -0
  113. package/dist/src/utils/logger.js.map +1 -0
  114. package/package.json +54 -0
@@ -0,0 +1,154 @@
1
+ import { parseArgs } from "node:util";
2
+ import { readFile } from "node:fs/promises";
3
+ export function parseCliArgs(argv) {
4
+ const { values } = parseArgs({
5
+ args: argv.slice(2),
6
+ options: {
7
+ spec: { type: "string", short: "s" },
8
+ config: { type: "string", short: "c" },
9
+ "base-url": { type: "string" },
10
+ prefix: { type: "string" },
11
+ include: { type: "string" },
12
+ exclude: { type: "string" },
13
+ timeout: { type: "string" },
14
+ "max-retries": { type: "string" },
15
+ transport: { type: "string" },
16
+ port: { type: "string" },
17
+ // Auth options
18
+ "auth-type": { type: "string" },
19
+ "auth-token": { type: "string" },
20
+ "auth-name": { type: "string" },
21
+ "auth-value": { type: "string" },
22
+ "auth-in": { type: "string" },
23
+ "auth-client-id": { type: "string" },
24
+ "auth-client-secret": { type: "string" },
25
+ "auth-token-url": { type: "string" },
26
+ "auth-scopes": { type: "string" },
27
+ // Header options
28
+ header: { type: "string", multiple: true, short: "H" },
29
+ help: { type: "boolean", short: "h" },
30
+ version: { type: "boolean", short: "v" },
31
+ },
32
+ strict: false,
33
+ });
34
+ if (values.help) {
35
+ printHelp();
36
+ process.exit(0);
37
+ }
38
+ if (values.version) {
39
+ console.error("mcp-openapi v0.1.0");
40
+ process.exit(0);
41
+ }
42
+ const config = {
43
+ spec: values.spec ?? "",
44
+ };
45
+ if (values["base-url"])
46
+ config.baseUrl = values["base-url"];
47
+ if (values.prefix)
48
+ config.prefix = values.prefix;
49
+ if (values.include)
50
+ config.include = values.include.split(",");
51
+ if (values.exclude)
52
+ config.exclude = values.exclude.split(",");
53
+ if (values.timeout)
54
+ config.timeout = Number(values.timeout);
55
+ if (values["max-retries"])
56
+ config.maxRetries = Number(values["max-retries"]);
57
+ if (values.transport)
58
+ config.transport = values.transport;
59
+ if (values.port)
60
+ config.port = Number(values.port);
61
+ // Parse auth
62
+ const authType = values["auth-type"];
63
+ if (authType) {
64
+ config.auth = parseAuthArgs(authType, values);
65
+ }
66
+ // Parse custom headers
67
+ if (values.header) {
68
+ config.headers = {};
69
+ for (const h of values.header) {
70
+ const colonIdx = h.indexOf(":");
71
+ if (colonIdx > 0) {
72
+ config.headers[h.slice(0, colonIdx).trim()] = h.slice(colonIdx + 1).trim();
73
+ }
74
+ }
75
+ }
76
+ return config;
77
+ }
78
+ export async function loadConfigFile(path) {
79
+ const content = await readFile(path, "utf-8");
80
+ return JSON.parse(content);
81
+ }
82
+ export function mergeConfigs(fileConfig, cliConfig) {
83
+ // CLI takes precedence over file config
84
+ return {
85
+ ...fileConfig,
86
+ ...Object.fromEntries(Object.entries(cliConfig).filter(([, v]) => v !== undefined && v !== "")),
87
+ };
88
+ }
89
+ function parseAuthArgs(authType, values) {
90
+ switch (authType) {
91
+ case "bearer":
92
+ return {
93
+ type: "bearer",
94
+ token: values["auth-token"] ?? "",
95
+ };
96
+ case "api-key":
97
+ return {
98
+ type: "api-key",
99
+ name: values["auth-name"] ?? "Authorization",
100
+ value: values["auth-value"] ?? "",
101
+ in: (values["auth-in"] ?? "header"),
102
+ };
103
+ case "oauth2":
104
+ return {
105
+ type: "oauth2",
106
+ clientId: values["auth-client-id"] ?? "",
107
+ clientSecret: values["auth-client-secret"] ?? "",
108
+ tokenUrl: values["auth-token-url"] ?? "",
109
+ scopes: values["auth-scopes"]?.split(","),
110
+ };
111
+ default:
112
+ throw new Error(`Unknown auth type: ${authType}`);
113
+ }
114
+ }
115
+ function printHelp() {
116
+ console.error(`
117
+ mcp-openapi - Convert any OpenAPI/Swagger spec into MCP tools
118
+
119
+ USAGE:
120
+ npx @autorev/mcp-openapi --spec <url-or-path> [options]
121
+
122
+ OPTIONS:
123
+ -s, --spec <url|path> OpenAPI spec URL or local file path (required)
124
+ -c, --config <path> JSON config file path
125
+ --base-url <url> Override API base URL
126
+ --prefix <name> Prefix all tool names
127
+ --include <patterns> Comma-separated operationIds or path patterns
128
+ --exclude <patterns> Comma-separated operationIds or path patterns
129
+ --timeout <ms> Request timeout (default: 30000)
130
+ --max-retries <n> Max retries on 429/5xx (default: 3)
131
+ -H, --header <name:value> Custom header (can be used multiple times)
132
+
133
+ AUTH OPTIONS:
134
+ --auth-type bearer Bearer token auth
135
+ --auth-token <token> Bearer token (use $ENV_VAR for env reference)
136
+
137
+ --auth-type api-key API key auth
138
+ --auth-name <name> Header/query param name
139
+ --auth-value <value> API key value (use $ENV_VAR for env reference)
140
+ --auth-in <header|query>
141
+
142
+ --auth-type oauth2 OAuth2 client credentials
143
+ --auth-client-id <id>
144
+ --auth-client-secret <secret>
145
+ --auth-token-url <url>
146
+ --auth-scopes <scopes>
147
+
148
+ EXAMPLES:
149
+ npx @autorev/mcp-openapi --spec https://petstore3.swagger.io/api/v3/openapi.json
150
+ npx @autorev/mcp-openapi --spec ./api.yaml --auth-type bearer --auth-token '$API_KEY'
151
+ npx @autorev/mcp-openapi --spec ./api.json --prefix github --include 'listRepos,getRepo'
152
+ `);
153
+ }
154
+ //# sourceMappingURL=cli-args.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli-args.js","sourceRoot":"","sources":["../../../src/config/cli-args.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAG5C,MAAM,UAAU,YAAY,CAAC,IAAc;IAC1C,MAAM,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;QAC5B,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;QACnB,OAAO,EAAE;YACR,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,EAAE;YACpC,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,EAAE;YACtC,UAAU,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;YAC9B,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;YAC1B,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;YAC3B,OAAO,EAAE,EAAE,IAAI,EAAE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AK,EAAG,MAAM,CAAC,YAAY,CAAY,IAAI,EAAE;gBAC7C,EAAE,EAAE,CAAE,MAAM,CAAC,SAAS,CAAY,IAAI,QAAQ,CAAuB;aACrE,CAAC;QACH,KAAK,QAAQ;YACZ,OAAO;gBACN,IAAI,EAAE,QAAQ;gBACd,QAAQ,EAAG,MAAM,CAAC,gBAAgB,CAAY,IAAI,EAAE;gBACpD,YAAY,EAAG,MAAM,CAAC,oBAAoB,CAAY,IAAI,EAAE;gBAC5D,QAAQ,EAAG,MAAM,CAAC,gBAAgB,CAAY,IAAI,EAAE;gBACpD,MAAM,EAAG,MAAM,CAAC,aAAa,CAAY,EAAE,KAAK,CAAC,GAAG,CAAC;aACrD,CAAC;QACH;YACC,MAAM,IAAI,KAAK,CAAC,sBAAsB,QAAQ,EAAE,CAAC,CAAC;IACpD,CAAC;AACF,CAAC;AAED,SAAS,SAAS;IACjB,OAAO,CAAC,KAAK,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoCd,CAAC,CAAC;AACH,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { parseCliArgs, loadConfigFile, mergeConfigs } from "./cli-args.js";
2
+ export type { McpOpenApiConfig, AuthConfig } from "./types.js";
3
+ export { DEFAULT_CONFIG } from "./types.js";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/config/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC3E,YAAY,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { parseCliArgs, loadConfigFile, mergeConfigs } from "./cli-args.js";
2
+ export { DEFAULT_CONFIG } from "./types.js";
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/config/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE3E,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC"}
@@ -0,0 +1,46 @@
1
+ export interface McpOpenApiConfig {
2
+ /** URL or local file path to OpenAPI spec */
3
+ spec: string;
4
+ /** Base URL override (skips servers[] in spec) */
5
+ baseUrl?: string;
6
+ /** Auth configuration */
7
+ auth?: AuthConfig;
8
+ /** Include only these operationIds or path patterns */
9
+ include?: string[];
10
+ /** Exclude these operationIds or path patterns */
11
+ exclude?: string[];
12
+ /** Tool name prefix, e.g. "github" → "github_get_repos" */
13
+ prefix?: string;
14
+ /** Request timeout in ms (default: 30000) */
15
+ timeout?: number;
16
+ /** Max retries on 429/5xx (default: 3) */
17
+ maxRetries?: number;
18
+ /** Custom headers injected into every request */
19
+ headers?: Record<string, string>;
20
+ /** Transport: "stdio" | "sse" (default: "stdio") */
21
+ transport?: "stdio" | "sse";
22
+ /** SSE port (default: 3000) */
23
+ port?: number;
24
+ }
25
+ export type AuthConfig = {
26
+ type: "api-key";
27
+ name: string;
28
+ value: string;
29
+ in: "header" | "query";
30
+ } | {
31
+ type: "bearer";
32
+ token: string;
33
+ } | {
34
+ type: "oauth2";
35
+ clientId: string;
36
+ clientSecret: string;
37
+ tokenUrl: string;
38
+ scopes?: string[];
39
+ };
40
+ export declare const DEFAULT_CONFIG: {
41
+ timeout: number;
42
+ maxRetries: number;
43
+ transport: "stdio";
44
+ port: number;
45
+ };
46
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/config/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,gBAAgB;IAChC,6CAA6C;IAC7C,IAAI,EAAE,MAAM,CAAC;IACb,kDAAkD;IAClD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,yBAAyB;IACzB,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,uDAAuD;IACvD,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,kDAAkD;IAClD,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,2DAA2D;IAC3D,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,6CAA6C;IAC7C,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,0CAA0C;IAC1C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,iDAAiD;IACjD,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,oDAAoD;IACpD,SAAS,CAAC,EAAE,OAAO,GAAG,KAAK,CAAC;IAC5B,+BAA+B;IAC/B,IAAI,CAAC,EAAE,MAAM,CAAC;CACd;AAED,MAAM,MAAM,UAAU,GACnB;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,QAAQ,GAAG,OAAO,CAAA;CAAE,GACxE;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GACjC;IACA,IAAI,EAAE,QAAQ,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACjB,CAAC;AAEL,eAAO,MAAM,cAAc;;;;;CAKU,CAAC"}
@@ -0,0 +1,7 @@
1
+ export const DEFAULT_CONFIG = {
2
+ timeout: 30_000,
3
+ maxRetries: 3,
4
+ transport: "stdio",
5
+ port: 3000,
6
+ };
7
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/config/types.ts"],"names":[],"mappings":"AAoCA,MAAM,CAAC,MAAM,cAAc,GAAG;IAC7B,OAAO,EAAE,MAAM;IACf,UAAU,EAAE,CAAC;IACb,SAAS,EAAE,OAAgB;IAC3B,IAAI,EAAE,IAAI;CAC0B,CAAC"}
@@ -0,0 +1,14 @@
1
+ import type { PreparedRequest } from "./types.js";
2
+ export interface HttpResponse {
3
+ status: number;
4
+ statusText: string;
5
+ headers: Record<string, string>;
6
+ body: string;
7
+ contentType: string;
8
+ }
9
+ export interface HttpClientOptions {
10
+ timeout: number;
11
+ maxRetries: number;
12
+ }
13
+ export declare function executeRequest(request: PreparedRequest, options?: HttpClientOptions): Promise<HttpResponse>;
14
+ //# sourceMappingURL=http-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-client.d.ts","sourceRoot":"","sources":["../../../src/executor/http-client.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD,MAAM,WAAW,YAAY;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,iBAAiB;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;CACnB;AAOD,wBAAsB,cAAc,CACnC,OAAO,EAAE,eAAe,EACxB,OAAO,GAAE,iBAAmC,GAC1C,OAAO,CAAC,YAAY,CAAC,CA4DvB"}
@@ -0,0 +1,59 @@
1
+ import { HttpRequestError } from "../utils/errors.js";
2
+ import { logger } from "../utils/logger.js";
3
+ const DEFAULT_OPTIONS = {
4
+ timeout: 30_000,
5
+ maxRetries: 3,
6
+ };
7
+ export async function executeRequest(request, options = DEFAULT_OPTIONS) {
8
+ let lastError;
9
+ for (let attempt = 0; attempt <= options.maxRetries; attempt++) {
10
+ try {
11
+ const response = await fetch(request.url, {
12
+ method: request.method,
13
+ headers: request.headers,
14
+ body: request.body ? JSON.stringify(request.body) : undefined,
15
+ signal: AbortSignal.timeout(options.timeout),
16
+ });
17
+ const contentType = response.headers.get("content-type") ?? "";
18
+ const body = await response.text();
19
+ const responseHeaders = {};
20
+ response.headers.forEach((value, key) => {
21
+ responseHeaders[key] = value;
22
+ });
23
+ // Retry on 429 and 5xx
24
+ if (response.status === 429 || response.status >= 500) {
25
+ if (attempt < options.maxRetries) {
26
+ const retryAfter = response.headers.get("retry-after");
27
+ const delay = retryAfter
28
+ ? Number.parseInt(retryAfter, 10) * 1000
29
+ : Math.min(1000 * 2 ** attempt, 10_000);
30
+ logger.debug(`Retrying request (attempt ${attempt + 1}/${options.maxRetries}), waiting ${delay}ms`);
31
+ await sleep(delay);
32
+ continue;
33
+ }
34
+ }
35
+ return {
36
+ status: response.status,
37
+ statusText: response.statusText,
38
+ headers: responseHeaders,
39
+ body,
40
+ contentType,
41
+ };
42
+ }
43
+ catch (error) {
44
+ lastError =
45
+ error instanceof Error ? error : new Error(String(error));
46
+ if (attempt < options.maxRetries) {
47
+ const delay = Math.min(1000 * 2 ** attempt, 10_000);
48
+ logger.debug(`Request failed (attempt ${attempt + 1}/${options.maxRetries}): ${lastError.message}`);
49
+ await sleep(delay);
50
+ continue;
51
+ }
52
+ }
53
+ }
54
+ throw new HttpRequestError(`Request failed after ${options.maxRetries + 1} attempts: ${lastError?.message ?? "Unknown error"}`);
55
+ }
56
+ function sleep(ms) {
57
+ return new Promise((resolve) => setTimeout(resolve, ms));
58
+ }
59
+ //# sourceMappingURL=http-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-client.js","sourceRoot":"","sources":["../../../src/executor/http-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAgB5C,MAAM,e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,SAAS,KAAK,CAAC,EAAU;IACxB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;AAC1D,CAAC"}
@@ -0,0 +1,7 @@
1
+ export { buildRequest } from "./request-builder.js";
2
+ export { executeRequest } from "./http-client.js";
3
+ export type { HttpResponse, HttpClientOptions } from "./http-client.js";
4
+ export { mapResponse } from "./response-mapper.js";
5
+ export type { McpToolResult } from "./response-mapper.js";
6
+ export type { PreparedRequest } from "./types.js";
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/executor/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,YAAY,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACxE,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,YAAY,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC1D,YAAY,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { buildRequest } from "./request-builder.js";
2
+ export { executeRequest } from "./http-client.js";
3
+ export { mapResponse } from "./response-mapper.js";
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/executor/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC"}
@@ -0,0 +1,15 @@
1
+ import type { ParameterMapping } from "../generator/param-builder.js";
2
+ import type { PreparedRequest } from "./types.js";
3
+ export interface EndpointRef {
4
+ method: string;
5
+ path: string;
6
+ baseUrl: string;
7
+ contentType: string;
8
+ parameterMap: ParameterMapping[];
9
+ }
10
+ /**
11
+ * Convert flat MCP tool call arguments into a structured HTTP request
12
+ * using the parameter mapping from tool generation.
13
+ */
14
+ export declare function buildRequest(args: Record<string, unknown>, endpointRef: EndpointRef, customHeaders?: Record<string, string>): PreparedRequest;
15
+ //# sourceMappingURL=request-builder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request-builder.d.ts","sourceRoot":"","sources":["../../../src/executor/request-builder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD,MAAM,WAAW,WAAW;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,gBAAgB,EAAE,CAAC;CACjC;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAC3B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,WAAW,EAAE,WAAW,EACxB,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GACpC,eAAe,CAkDjB"}
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Convert flat MCP tool call arguments into a structured HTTP request
3
+ * using the parameter mapping from tool generation.
4
+ */
5
+ export function buildRequest(args, endpointRef, customHeaders) {
6
+ let path = endpointRef.path;
7
+ const query = {};
8
+ const headers = {
9
+ ...customHeaders,
10
+ };
11
+ const bodyParts = {};
12
+ let hasBody = false;
13
+ for (const mapping of endpointRef.parameterMap) {
14
+ const value = args[mapping.toolParamName];
15
+ if (value === undefined)
16
+ continue;
17
+ switch (mapping.source) {
18
+ case "path":
19
+ path = path.replace(`{${mapping.originalName}}`, String(value));
20
+ break;
21
+ case "query":
22
+ query[mapping.originalName] = String(value);
23
+ break;
24
+ case "header":
25
+ headers[mapping.originalName] = String(value);
26
+ break;
27
+ case "body":
28
+ if (mapping.originalName === "body") {
29
+ // Nested body object — use as-is
30
+ Object.assign(bodyParts, value);
31
+ }
32
+ else {
33
+ bodyParts[mapping.originalName] = value;
34
+ }
35
+ hasBody = true;
36
+ break;
37
+ }
38
+ }
39
+ // Build URL with query string
40
+ const url = buildUrl(endpointRef.baseUrl, path, query);
41
+ // Set content type for body requests
42
+ if (hasBody) {
43
+ headers["Content-Type"] = endpointRef.contentType;
44
+ }
45
+ return {
46
+ url,
47
+ method: endpointRef.method,
48
+ headers,
49
+ query,
50
+ body: hasBody ? bodyParts : undefined,
51
+ };
52
+ }
53
+ function buildUrl(baseUrl, path, query) {
54
+ const url = new URL(path, baseUrl);
55
+ for (const [key, value] of Object.entries(query)) {
56
+ url.searchParams.set(key, value);
57
+ }
58
+ return url.toString();
59
+ }
60
+ //# sourceMappingURL=request-builder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request-builder.js","sourceRoot":"","sources":["../../../src/executor/request-builder.ts"],"names":[],"mappings":"AAWA;;;GAGG;AACH,MAAM,UAAU,YAAY,CAC3B,IAA6B,EAC7B,WAAwB,EACxB,aAAsC;IAEtC,IAAI,IAAI,GAAG,WAAW,CAAC,IAAI,CAAC;IAC5B,MAAM,KAAK,GAA2B,EAAE,CAAC;IACzC,MAAM,OAAO,GAA2B;QACvC,GAAG,aAAa;KAChB,CAAC;IACF,MAAM,SAAS,GAA4B,EAAE,CAAC;IAC9C,IAAI,OAAO,GAAG,KAAK,CAAC;IAEpB,KAAK,MAAM,OAAO,IAAI,WAAW,CAAC,YAAY,EAAE,CAAC;QAChD,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;QAC1C,IAAI,KAAK,KAAK,SAAS;YAAE,SAAS;QAElC,QAAQ,OAAO,CAAC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AAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAClD,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IAClC,CAAC;IACD,OAAO,GAAG,CAAC,QAAQ,EAAE,CAAC;AACvB,CAAC"}
@@ -0,0 +1,10 @@
1
+ import type { HttpResponse } from "./http-client.js";
2
+ export interface McpToolResult {
3
+ content: Array<{
4
+ type: "text";
5
+ text: string;
6
+ }>;
7
+ isError?: boolean;
8
+ }
9
+ export declare function mapResponse(response: HttpResponse): McpToolResult;
10
+ //# sourceMappingURL=response-mapper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"response-mapper.d.ts","sourceRoot":"","sources":["../../../src/executor/response-mapper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAErD,MAAM,WAAW,aAAa;IAC7B,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC/C,OAAO,CAAC,EAAE,OAAO,CAAC;CAClB;AAID,wBAAgB,WAAW,CAAC,QAAQ,EAAE,YAAY,GAAG,aAAa,CAkDjE"}
@@ -0,0 +1,54 @@
1
+ const MAX_RESPONSE_LENGTH = 50_000; // ~50KB text limit for LLM context friendliness
2
+ export function mapResponse(response) {
3
+ // HTTP error
4
+ if (response.status >= 400) {
5
+ const body = truncate(response.body, 2000);
6
+ return {
7
+ content: [
8
+ {
9
+ type: "text",
10
+ text: `HTTP Error ${response.status} ${response.statusText}\n\n${body}`,
11
+ },
12
+ ],
13
+ isError: true,
14
+ };
15
+ }
16
+ // JSON response — pretty print
17
+ if (response.contentType.includes("application/json")) {
18
+ try {
19
+ const parsed = JSON.parse(response.body);
20
+ const formatted = JSON.stringify(parsed, null, 2);
21
+ return {
22
+ content: [{ type: "text", text: truncate(formatted, MAX_RESPONSE_LENGTH) }],
23
+ };
24
+ }
25
+ catch {
26
+ // Not valid JSON despite content type — return raw
27
+ return {
28
+ content: [{ type: "text", text: truncate(response.body, MAX_RESPONSE_LENGTH) }],
29
+ };
30
+ }
31
+ }
32
+ // Text response
33
+ if (response.contentType.includes("text/") ||
34
+ response.contentType.includes("xml")) {
35
+ return {
36
+ content: [{ type: "text", text: truncate(response.body, MAX_RESPONSE_LENGTH) }],
37
+ };
38
+ }
39
+ // Binary response
40
+ return {
41
+ content: [
42
+ {
43
+ type: "text",
44
+ text: `[Binary response: ${response.contentType}, ${response.body.length} bytes, HTTP ${response.status}]`,
45
+ },
46
+ ],
47
+ };
48
+ }
49
+ function truncate(text, maxLength) {
50
+ if (text.length <= maxLength)
51
+ return text;
52
+ return `${text.slice(0, maxLength)}\n\n... [truncated, ${text.length - maxLength} characters omitted]`;
53
+ }
54
+ //# sourceMappingURL=response-mapper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"response-mapper.js","sourceRoot":"","sources":["../../../src/executor/response-mapper.ts"],"names":[],"mappings":"AAOA,MAAM,mBAAmB,GAAG,MAAM,CAAC,CAAC,gDAAgD;AAEpF,MAAM,UAAU,WAAW,CAAC,QAAsB;IACjD,aAAa;IACb,IAAI,QAAQ,CAAC,MAAM,IAAI,GAAG,EAAE,CAAC;QAC5B,MAAM,IAAI,GAAG,QAAQ,CAAC,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QAC3C,OAAO;YACN,OAAO,EAAE;gBACR;oBACC,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,cAAc,QAAQ,CAAC,MAAM,IAAI,QAAQ,CAAC,UAAU,OAAO,IAAI,EAAE;iBACvE;aACD;YACD,OAAO,EAAE,IAAI;SACb,CAAC;IACH,CAAC;IAED,+BAA+B;IAC/B,IAAI,QAAQ,CAAC,WAAW,CAAC,QAAQ,CAAC,kBAAkB,CAAC,EAAE,C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,CAAC,CAAC,EAAE,SAAS,CAAC,uBAAuB,IAAI,CAAC,MAAM,GAAG,SAAS,sBAAsB,CAAC;AACxG,CAAC"}
@@ -0,0 +1,8 @@
1
+ export interface PreparedRequest {
2
+ url: string;
3
+ method: string;
4
+ headers: Record<string, string>;
5
+ query: Record<string, string>;
6
+ body?: unknown;
7
+ }
8
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/executor/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe;IAC/B,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9B,IAAI,CAAC,EAAE,OAAO,CAAC;CACf"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/executor/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,6 @@
1
+ export { generateTools } from "./tool-generator.js";
2
+ export type { GeneratedTool, GenerateOptions } from "./tool-generator.js";
3
+ export type { ParameterMapping, BuiltParams } from "./param-builder.js";
4
+ export { generateToolName, resolveCollisions } from "./tool-namer.js";
5
+ export { buildParams } from "./param-builder.js";
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/generator/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,YAAY,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC1E,YAAY,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACxE,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACtE,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { generateTools } from "./tool-generator.js";
2
+ export { generateToolName, resolveCollisions } from "./tool-namer.js";
3
+ export { buildParams } from "./param-builder.js";
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/generator/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGpD,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACtE,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC"}
@@ -0,0 +1,17 @@
1
+ import type { JsonSchema, NormalizedEndpoint } from "../parser/types.js";
2
+ export interface ParameterMapping {
3
+ toolParamName: string;
4
+ source: "path" | "query" | "header" | "body";
5
+ originalName: string;
6
+ required: boolean;
7
+ }
8
+ export interface BuiltParams {
9
+ inputSchema: JsonSchema;
10
+ parameterMap: ParameterMapping[];
11
+ }
12
+ /**
13
+ * Flatten path, query, header, and body parameters into a single
14
+ * MCP tool inputSchema. Handles name collisions with prefixing.
15
+ */
16
+ export declare function buildParams(endpoint: NormalizedEndpoint): BuiltParams;
17
+ //# sourceMappingURL=param-builder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"param-builder.d.ts","sourceRoot":"","sources":["../../../src/generator/param-builder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,kBAAkB,EAAuB,MAAM,oBAAoB,CAAC;AAE9F,MAAM,WAAW,gBAAgB;IAChC,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,CAAC;IAC7C,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,WAAW;IAC3B,WAAW,EAAE,UAAU,CAAC;IACxB,YAAY,EAAE,gBAAgB,EAAE,CAAC;CACjC;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,kBAAkB,GAAG,WAAW,CAgGrE"}