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.
- package/README.md +351 -0
- package/dist/bin/mcp-openapi.d.ts +3 -0
- package/dist/bin/mcp-openapi.d.ts.map +1 -0
- package/dist/bin/mcp-openapi.js +26 -0
- package/dist/bin/mcp-openapi.js.map +1 -0
- package/dist/src/auth/api-key.d.ts +10 -0
- package/dist/src/auth/api-key.d.ts.map +1 -0
- package/dist/src/auth/api-key.js +23 -0
- package/dist/src/auth/api-key.js.map +1 -0
- package/dist/src/auth/auth-manager.d.ts +4 -0
- package/dist/src/auth/auth-manager.d.ts.map +1 -0
- package/dist/src/auth/auth-manager.js +36 -0
- package/dist/src/auth/auth-manager.js.map +1 -0
- package/dist/src/auth/bearer.d.ts +8 -0
- package/dist/src/auth/bearer.d.ts.map +1 -0
- package/dist/src/auth/bearer.js +16 -0
- package/dist/src/auth/bearer.js.map +1 -0
- package/dist/src/auth/index.d.ts +3 -0
- package/dist/src/auth/index.d.ts.map +1 -0
- package/dist/src/auth/index.js +2 -0
- package/dist/src/auth/index.js.map +1 -0
- package/dist/src/auth/oauth2.d.ts +14 -0
- package/dist/src/auth/oauth2.d.ts.map +1 -0
- package/dist/src/auth/oauth2.js +59 -0
- package/dist/src/auth/oauth2.js.map +1 -0
- package/dist/src/auth/types.d.ts +5 -0
- package/dist/src/auth/types.d.ts.map +1 -0
- package/dist/src/auth/types.js +2 -0
- package/dist/src/auth/types.js.map +1 -0
- package/dist/src/config/cli-args.d.ts +5 -0
- package/dist/src/config/cli-args.d.ts.map +1 -0
- package/dist/src/config/cli-args.js +154 -0
- package/dist/src/config/cli-args.js.map +1 -0
- package/dist/src/config/index.d.ts +4 -0
- package/dist/src/config/index.d.ts.map +1 -0
- package/dist/src/config/index.js +3 -0
- package/dist/src/config/index.js.map +1 -0
- package/dist/src/config/types.d.ts +46 -0
- package/dist/src/config/types.d.ts.map +1 -0
- package/dist/src/config/types.js +7 -0
- package/dist/src/config/types.js.map +1 -0
- package/dist/src/executor/http-client.d.ts +14 -0
- package/dist/src/executor/http-client.d.ts.map +1 -0
- package/dist/src/executor/http-client.js +59 -0
- package/dist/src/executor/http-client.js.map +1 -0
- package/dist/src/executor/index.d.ts +7 -0
- package/dist/src/executor/index.d.ts.map +1 -0
- package/dist/src/executor/index.js +4 -0
- package/dist/src/executor/index.js.map +1 -0
- package/dist/src/executor/request-builder.d.ts +15 -0
- package/dist/src/executor/request-builder.d.ts.map +1 -0
- package/dist/src/executor/request-builder.js +60 -0
- package/dist/src/executor/request-builder.js.map +1 -0
- package/dist/src/executor/response-mapper.d.ts +10 -0
- package/dist/src/executor/response-mapper.d.ts.map +1 -0
- package/dist/src/executor/response-mapper.js +54 -0
- package/dist/src/executor/response-mapper.js.map +1 -0
- package/dist/src/executor/types.d.ts +8 -0
- package/dist/src/executor/types.d.ts.map +1 -0
- package/dist/src/executor/types.js +2 -0
- package/dist/src/executor/types.js.map +1 -0
- package/dist/src/generator/index.d.ts +6 -0
- package/dist/src/generator/index.d.ts.map +1 -0
- package/dist/src/generator/index.js +4 -0
- package/dist/src/generator/index.js.map +1 -0
- package/dist/src/generator/param-builder.d.ts +17 -0
- package/dist/src/generator/param-builder.d.ts.map +1 -0
- package/dist/src/generator/param-builder.js +110 -0
- package/dist/src/generator/param-builder.js.map +1 -0
- package/dist/src/generator/tool-generator.d.ts +22 -0
- package/dist/src/generator/tool-generator.d.ts.map +1 -0
- package/dist/src/generator/tool-generator.js +66 -0
- package/dist/src/generator/tool-generator.js.map +1 -0
- package/dist/src/generator/tool-namer.d.ts +10 -0
- package/dist/src/generator/tool-namer.d.ts.map +1 -0
- package/dist/src/generator/tool-namer.js +44 -0
- package/dist/src/generator/tool-namer.js.map +1 -0
- package/dist/src/index.d.ts +7 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +4 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/parser/index.d.ts +5 -0
- package/dist/src/parser/index.d.ts.map +1 -0
- package/dist/src/parser/index.js +4 -0
- package/dist/src/parser/index.js.map +1 -0
- package/dist/src/parser/openapi-parser.d.ts +3 -0
- package/dist/src/parser/openapi-parser.d.ts.map +1 -0
- package/dist/src/parser/openapi-parser.js +287 -0
- package/dist/src/parser/openapi-parser.js.map +1 -0
- package/dist/src/parser/schema-converter.d.ts +7 -0
- package/dist/src/parser/schema-converter.d.ts.map +1 -0
- package/dist/src/parser/schema-converter.js +86 -0
- package/dist/src/parser/schema-converter.js.map +1 -0
- package/dist/src/parser/spec-loader.d.ts +6 -0
- package/dist/src/parser/spec-loader.d.ts.map +1 -0
- package/dist/src/parser/spec-loader.js +53 -0
- package/dist/src/parser/spec-loader.js.map +1 -0
- package/dist/src/parser/types.d.ts +72 -0
- package/dist/src/parser/types.d.ts.map +1 -0
- package/dist/src/parser/types.js +2 -0
- package/dist/src/parser/types.js.map +1 -0
- package/dist/src/server.d.ts +9 -0
- package/dist/src/server.d.ts.map +1 -0
- package/dist/src/server.js +61 -0
- package/dist/src/server.js.map +1 -0
- package/dist/src/utils/errors.d.ts +19 -0
- package/dist/src/utils/errors.d.ts.map +1 -0
- package/dist/src/utils/errors.js +37 -0
- package/dist/src/utils/errors.js.map +1 -0
- package/dist/src/utils/logger.d.ts +8 -0
- package/dist/src/utils/logger.d.ts.map +1 -0
- package/dist/src/utils/logger.js +12 -0
- package/dist/src/utils/logger.js.map +1 -0
- package/package.json +54 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema-converter.d.ts","sourceRoot":"","sources":["../../../src/parser/schema-converter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,UAAU,CAoElF"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convert OAS-specific schema extensions into pure JSON Schema
|
|
3
|
+
* that MCP tools can accept.
|
|
4
|
+
*/
|
|
5
|
+
export function convertToJsonSchema(oasSchema) {
|
|
6
|
+
if (!oasSchema || typeof oasSchema !== "object") {
|
|
7
|
+
return { type: "string" };
|
|
8
|
+
}
|
|
9
|
+
const schema = {};
|
|
10
|
+
// Copy basic properties
|
|
11
|
+
if (oasSchema.type)
|
|
12
|
+
schema.type = String(oasSchema.type);
|
|
13
|
+
if (oasSchema.description)
|
|
14
|
+
schema.description = String(oasSchema.description);
|
|
15
|
+
if (oasSchema.format)
|
|
16
|
+
schema.format = String(oasSchema.format);
|
|
17
|
+
if (oasSchema.default !== undefined)
|
|
18
|
+
schema.default = oasSchema.default;
|
|
19
|
+
if (Array.isArray(oasSchema.enum))
|
|
20
|
+
schema.enum = oasSchema.enum;
|
|
21
|
+
// Handle nullable (OAS 3.0 extension)
|
|
22
|
+
if (oasSchema.nullable === true && schema.type) {
|
|
23
|
+
// JSON Schema doesn't have nullable, express as type array or leave as-is for MCP
|
|
24
|
+
}
|
|
25
|
+
// Handle properties (object type)
|
|
26
|
+
if (oasSchema.properties && typeof oasSchema.properties === "object") {
|
|
27
|
+
schema.type = "object";
|
|
28
|
+
schema.properties = {};
|
|
29
|
+
for (const [key, value] of Object.entries(oasSchema.properties)) {
|
|
30
|
+
if (value && typeof value === "object") {
|
|
31
|
+
schema.properties[key] = convertToJsonSchema(value);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
// Handle required
|
|
36
|
+
if (Array.isArray(oasSchema.required)) {
|
|
37
|
+
schema.required = oasSchema.required.filter((r) => typeof r === "string");
|
|
38
|
+
}
|
|
39
|
+
// Handle items (array type)
|
|
40
|
+
if (oasSchema.items && typeof oasSchema.items === "object") {
|
|
41
|
+
schema.type = "array";
|
|
42
|
+
schema.items = convertToJsonSchema(oasSchema.items);
|
|
43
|
+
}
|
|
44
|
+
// Handle allOf — merge into single schema
|
|
45
|
+
if (Array.isArray(oasSchema.allOf)) {
|
|
46
|
+
return mergeAllOf(oasSchema.allOf);
|
|
47
|
+
}
|
|
48
|
+
// Handle oneOf/anyOf — pick first as best effort
|
|
49
|
+
if (Array.isArray(oasSchema.oneOf) && oasSchema.oneOf.length > 0) {
|
|
50
|
+
const first = oasSchema.oneOf[0];
|
|
51
|
+
if (first && typeof first === "object") {
|
|
52
|
+
return convertToJsonSchema(first);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
if (Array.isArray(oasSchema.anyOf) && oasSchema.anyOf.length > 0) {
|
|
56
|
+
const first = oasSchema.anyOf[0];
|
|
57
|
+
if (first && typeof first === "object") {
|
|
58
|
+
return convertToJsonSchema(first);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
// Default to string if no type detected
|
|
62
|
+
if (!schema.type && !schema.properties && !schema.items) {
|
|
63
|
+
schema.type = "string";
|
|
64
|
+
}
|
|
65
|
+
return schema;
|
|
66
|
+
}
|
|
67
|
+
function mergeAllOf(schemas) {
|
|
68
|
+
const merged = { type: "object", properties: {}, required: [] };
|
|
69
|
+
for (const sub of schemas) {
|
|
70
|
+
const converted = convertToJsonSchema(sub);
|
|
71
|
+
if (converted.properties) {
|
|
72
|
+
Object.assign(merged.properties, converted.properties);
|
|
73
|
+
}
|
|
74
|
+
if (converted.required) {
|
|
75
|
+
merged.required.push(...converted.required);
|
|
76
|
+
}
|
|
77
|
+
if (converted.description && !merged.description) {
|
|
78
|
+
merged.description = converted.description;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
if (merged.required.length === 0) {
|
|
82
|
+
delete merged.required;
|
|
83
|
+
}
|
|
84
|
+
return merged;
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=schema-converter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema-converter.js","sourceRoot":"","sources":["../../../src/parser/schema-converter.ts"],"names":[],"mappings":"AAEA;;;GAGG;AAC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sourceRoot":"","sources":["../../../src/parser/spec-loader.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,UAAU;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC;CACxB;AAeD,wBAAsB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAKjE"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
import { SpecLoadError } from "../utils/errors.js";
|
|
3
|
+
import { logger } from "../utils/logger.js";
|
|
4
|
+
function isUrl(input) {
|
|
5
|
+
return input.startsWith("http://") || input.startsWith("https://");
|
|
6
|
+
}
|
|
7
|
+
function detectFormat(input, content) {
|
|
8
|
+
if (input.endsWith(".json"))
|
|
9
|
+
return "json";
|
|
10
|
+
if (input.endsWith(".yaml") || input.endsWith(".yml"))
|
|
11
|
+
return "yaml";
|
|
12
|
+
// Try to detect from content
|
|
13
|
+
const trimmed = content.trimStart();
|
|
14
|
+
if (trimmed.startsWith("{") || trimmed.startsWith("["))
|
|
15
|
+
return "json";
|
|
16
|
+
return "yaml";
|
|
17
|
+
}
|
|
18
|
+
export async function loadSpec(input) {
|
|
19
|
+
if (isUrl(input)) {
|
|
20
|
+
return loadFromUrl(input);
|
|
21
|
+
}
|
|
22
|
+
return loadFromFile(input);
|
|
23
|
+
}
|
|
24
|
+
async function loadFromUrl(url) {
|
|
25
|
+
logger.info(`Fetching spec from ${url}`);
|
|
26
|
+
try {
|
|
27
|
+
const response = await fetch(url, {
|
|
28
|
+
headers: { Accept: "application/json, application/yaml, text/yaml, */*" },
|
|
29
|
+
signal: AbortSignal.timeout(30_000),
|
|
30
|
+
});
|
|
31
|
+
if (!response.ok) {
|
|
32
|
+
throw new SpecLoadError(`Failed to fetch spec: ${response.status} ${response.statusText}`);
|
|
33
|
+
}
|
|
34
|
+
const content = await response.text();
|
|
35
|
+
return { content, format: detectFormat(url, content) };
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
if (error instanceof SpecLoadError)
|
|
39
|
+
throw error;
|
|
40
|
+
throw new SpecLoadError(`Failed to fetch spec from ${url}: ${error instanceof Error ? error.message : String(error)}`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
async function loadFromFile(filePath) {
|
|
44
|
+
logger.info(`Reading spec from ${filePath}`);
|
|
45
|
+
try {
|
|
46
|
+
const content = await readFile(filePath, "utf-8");
|
|
47
|
+
return { content, format: detectFormat(filePath, content) };
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
throw new SpecLoadError(`Failed to read spec file ${filePath}: ${error instanceof Error ? error.message : String(error)}`);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=spec-loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spec-loader.js","sourceRoot":"","sources":["../../../src/parser/spec-loader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAO5C,SAAS,KAAK,CAAC,KAAa;IAC3B,OAAO,KAAK,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,KAAK,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;AACpE,CAAC;AAED,SAAS,YAAY,CAAC,KAAa,EAAE,OAAe;IACnD,IAAI,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC;QAAE,OAAO,MAAM,CAAC;IAC3C,IAAI,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC;QAAE,OAAO,MAAM,CAAC;IACrE,6BAA6B;IAC7B,MAAM,OAAO,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC;IACpC,IAAI,OA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AED,KAAK,UAAU,YAAY,CAAC,QAAgB;IAC3C,MAAM,CAAC,IAAI,CAAC,qBAAqB,QAAQ,EAAE,CAAC,CAAC;IAC7C,IAAI,CAAC;QACJ,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QAClD,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,YAAY,CAAC,QAAQ,EAAE,OAAO,CAAC,EAAE,CAAC;IAC7D,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,MAAM,IAAI,aAAa,CACtB,4BAA4B,QAAQ,KAAK,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CACjG,CAAC;IACH,CAAC;AACF,CAAC"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/** JSON Schema subset that MCP tools accept */
|
|
2
|
+
export type JsonSchema = {
|
|
3
|
+
type?: string;
|
|
4
|
+
properties?: Record<string, JsonSchema>;
|
|
5
|
+
required?: string[];
|
|
6
|
+
items?: JsonSchema;
|
|
7
|
+
description?: string;
|
|
8
|
+
enum?: unknown[];
|
|
9
|
+
default?: unknown;
|
|
10
|
+
format?: string;
|
|
11
|
+
[key: string]: unknown;
|
|
12
|
+
};
|
|
13
|
+
export interface NormalizedSpec {
|
|
14
|
+
info: {
|
|
15
|
+
title: string;
|
|
16
|
+
version: string;
|
|
17
|
+
description?: string;
|
|
18
|
+
};
|
|
19
|
+
servers: Array<{
|
|
20
|
+
url: string;
|
|
21
|
+
}>;
|
|
22
|
+
endpoints: NormalizedEndpoint[];
|
|
23
|
+
securitySchemes: Record<string, SecurityScheme>;
|
|
24
|
+
}
|
|
25
|
+
export interface NormalizedEndpoint {
|
|
26
|
+
method: "get" | "post" | "put" | "patch" | "delete" | "head" | "options";
|
|
27
|
+
path: string;
|
|
28
|
+
operationId: string;
|
|
29
|
+
summary?: string;
|
|
30
|
+
description?: string;
|
|
31
|
+
parameters: NormalizedParameter[];
|
|
32
|
+
requestBody?: NormalizedRequestBody;
|
|
33
|
+
responses: Record<string, NormalizedResponse>;
|
|
34
|
+
security?: SecurityRequirement[];
|
|
35
|
+
tags?: string[];
|
|
36
|
+
deprecated?: boolean;
|
|
37
|
+
}
|
|
38
|
+
export interface NormalizedParameter {
|
|
39
|
+
name: string;
|
|
40
|
+
in: "path" | "query" | "header" | "cookie";
|
|
41
|
+
required: boolean;
|
|
42
|
+
description?: string;
|
|
43
|
+
schema: JsonSchema;
|
|
44
|
+
}
|
|
45
|
+
export interface NormalizedRequestBody {
|
|
46
|
+
required: boolean;
|
|
47
|
+
description?: string;
|
|
48
|
+
contentType: string;
|
|
49
|
+
schema: JsonSchema;
|
|
50
|
+
}
|
|
51
|
+
export interface NormalizedResponse {
|
|
52
|
+
description?: string;
|
|
53
|
+
contentType?: string;
|
|
54
|
+
schema?: JsonSchema;
|
|
55
|
+
}
|
|
56
|
+
export type SecurityScheme = {
|
|
57
|
+
type: "apiKey";
|
|
58
|
+
name: string;
|
|
59
|
+
in: "header" | "query" | "cookie";
|
|
60
|
+
} | {
|
|
61
|
+
type: "http";
|
|
62
|
+
scheme: string;
|
|
63
|
+
bearerFormat?: string;
|
|
64
|
+
} | {
|
|
65
|
+
type: "oauth2";
|
|
66
|
+
flows: Record<string, {
|
|
67
|
+
tokenUrl?: string;
|
|
68
|
+
scopes: Record<string, string>;
|
|
69
|
+
}>;
|
|
70
|
+
};
|
|
71
|
+
export type SecurityRequirement = Record<string, string[]>;
|
|
72
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/parser/types.ts"],"names":[],"mappings":"AAAA,+CAA+C;AAC/C,MAAM,MAAM,UAAU,GAAG;IACxB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,E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C;IACb,EAAE,EAAE,MAAM,GAAG,OAAO,GAAG,QAAQ,GAAG,QAAQ,CAAC;IAC3C,QAAQ,EAAE,OAAO,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,UAAU,CAAC;CACnB;AAED,MAAM,WAAW,qBAAqB;IACrC,QAAQ,EAAE,OAAO,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,UAAU,CAAC;CACnB;AAED,MAAM,WAAW,kBAAkB;IAClC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,UAAU,CAAC;CACpB;AAED,MAAM,MAAM,cAAc,GACvB;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,QAAQ,GAAG,OAAO,GAAG,QAAQ,CAAA;CAAE,GACnE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE,GACvD;IACA,IAAI,EAAE,QAAQ,CAAC;IACf,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;KAAE,CAAC,CAAC;CAC5E,CAAC;AAEL,MAAM,MAAM,mBAAmB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/parser/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
import type { McpOpenApiConfig } from "./config/types.js";
|
|
3
|
+
export declare function createServer(config: McpOpenApiConfig): Promise<{
|
|
4
|
+
server: McpServer;
|
|
5
|
+
tools: import("./index.js").GeneratedTool[];
|
|
6
|
+
spec: import("./index.js").NormalizedSpec;
|
|
7
|
+
}>;
|
|
8
|
+
export declare function startServer(config: McpOpenApiConfig): Promise<void>;
|
|
9
|
+
//# sourceMappingURL=server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAGpE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAS1D,wBAAsB,YAAY,CAAC,MAAM,EAAE,gBAAgB;;;;GAiE1D;AAED,wBAAsB,WAAW,CAAC,MAAM,EAAE,gBAAgB,iBAOzD"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
3
|
+
import { createAuthProvider } from "./auth/index.js";
|
|
4
|
+
import { DEFAULT_CONFIG } from "./config/types.js";
|
|
5
|
+
import { buildRequest } from "./executor/request-builder.js";
|
|
6
|
+
import { executeRequest } from "./executor/http-client.js";
|
|
7
|
+
import { mapResponse } from "./executor/response-mapper.js";
|
|
8
|
+
import { generateTools } from "./generator/tool-generator.js";
|
|
9
|
+
import { parseSpec } from "./parser/openapi-parser.js";
|
|
10
|
+
import { logger } from "./utils/logger.js";
|
|
11
|
+
export async function createServer(config) {
|
|
12
|
+
const mergedConfig = { ...DEFAULT_CONFIG, ...config };
|
|
13
|
+
// Parse the OpenAPI spec
|
|
14
|
+
const spec = await parseSpec(config.spec);
|
|
15
|
+
// Generate MCP tools
|
|
16
|
+
const tools = generateTools(spec, {
|
|
17
|
+
baseUrl: mergedConfig.baseUrl,
|
|
18
|
+
prefix: mergedConfig.prefix,
|
|
19
|
+
include: mergedConfig.include,
|
|
20
|
+
exclude: mergedConfig.exclude,
|
|
21
|
+
});
|
|
22
|
+
if (tools.length === 0) {
|
|
23
|
+
logger.warn("No tools generated from the spec. Check your include/exclude filters.");
|
|
24
|
+
}
|
|
25
|
+
// Create auth provider
|
|
26
|
+
const authProvider = createAuthProvider(mergedConfig.auth);
|
|
27
|
+
// Create MCP server
|
|
28
|
+
const server = new McpServer({
|
|
29
|
+
name: `mcp-openapi: ${spec.info.title}`,
|
|
30
|
+
version: spec.info.version,
|
|
31
|
+
});
|
|
32
|
+
// Register each tool
|
|
33
|
+
for (const tool of tools) {
|
|
34
|
+
server.tool(tool.name, tool.description, tool.inputSchema.properties
|
|
35
|
+
? tool.inputSchema
|
|
36
|
+
: { properties: {} }, async (args) => {
|
|
37
|
+
// Build HTTP request from tool call args
|
|
38
|
+
let request = buildRequest(args, tool.endpointRef, mergedConfig.headers);
|
|
39
|
+
// Apply auth
|
|
40
|
+
if (authProvider) {
|
|
41
|
+
request = await authProvider.apply(request);
|
|
42
|
+
}
|
|
43
|
+
// Execute HTTP request
|
|
44
|
+
const response = await executeRequest(request, {
|
|
45
|
+
timeout: mergedConfig.timeout,
|
|
46
|
+
maxRetries: mergedConfig.maxRetries,
|
|
47
|
+
});
|
|
48
|
+
// Map to MCP result
|
|
49
|
+
return mapResponse(response);
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
logger.info(`Registered ${tools.length} tools from ${spec.info.title} v${spec.info.version}`);
|
|
53
|
+
return { server, tools, spec };
|
|
54
|
+
}
|
|
55
|
+
export async function startServer(config) {
|
|
56
|
+
const { server } = await createServer(config);
|
|
57
|
+
const transport = new StdioServerTransport();
|
|
58
|
+
await server.connect(transport);
|
|
59
|
+
logger.info("MCP server running on stdio");
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":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AAE,MAAM,EAAE,GAAG,MAAM,YAAY,CAAC,MAAM,CAAC,CAAC;IAE9C,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;IAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAEhC,MAAM,CAAC,IAAI,CAAC,6BAA6B,CAAC,CAAC;AAC5C,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare class McpOpenApiError extends Error {
|
|
2
|
+
readonly code: string;
|
|
3
|
+
constructor(message: string, code: string);
|
|
4
|
+
}
|
|
5
|
+
export declare class SpecLoadError extends McpOpenApiError {
|
|
6
|
+
constructor(message: string);
|
|
7
|
+
}
|
|
8
|
+
export declare class SpecParseError extends McpOpenApiError {
|
|
9
|
+
constructor(message: string);
|
|
10
|
+
}
|
|
11
|
+
export declare class AuthError extends McpOpenApiError {
|
|
12
|
+
constructor(message: string);
|
|
13
|
+
}
|
|
14
|
+
export declare class HttpRequestError extends McpOpenApiError {
|
|
15
|
+
readonly statusCode?: number | undefined;
|
|
16
|
+
readonly responseBody?: string | undefined;
|
|
17
|
+
constructor(message: string, statusCode?: number | undefined, responseBody?: string | undefined);
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/utils/errors.ts"],"names":[],"mappings":"AAAA,qBAAa,eAAgB,SAAQ,KAAK;aAGxB,IAAI,EAAE,MAAM;gBAD5B,OAAO,EAAE,MAAM,EACC,IAAI,EAAE,MAAM;CAK7B;AAED,qBAAa,aAAc,SAAQ,eAAe;gBACrC,OAAO,EAAE,MAAM;CAI3B;AAED,qBAAa,cAAe,SAAQ,eAAe;gBACtC,OAAO,EAAE,MAAM;CAI3B;AAED,qBAAa,SAAU,SAAQ,eAAe;gBACjC,OAAO,EAAE,MAAM;CAI3B;AAED,qBAAa,gBAAiB,SAAQ,eAAe;aAGnC,UAAU,CAAC,EAAE,MAAM;aACnB,YAAY,CAAC,EAAE,MAAM;gBAFrC,OAAO,EAAE,MAAM,EACC,UAAU,CAAC,EAAE,MAAM,YAAA,EACnB,YAAY,CAAC,EAAE,MAAM,YAAA;CAKtC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export class McpOpenApiError extends Error {
|
|
2
|
+
code;
|
|
3
|
+
constructor(message, code) {
|
|
4
|
+
super(message);
|
|
5
|
+
this.code = code;
|
|
6
|
+
this.name = "McpOpenApiError";
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
export class SpecLoadError extends McpOpenApiError {
|
|
10
|
+
constructor(message) {
|
|
11
|
+
super(message, "SPEC_LOAD_ERROR");
|
|
12
|
+
this.name = "SpecLoadError";
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
export class SpecParseError extends McpOpenApiError {
|
|
16
|
+
constructor(message) {
|
|
17
|
+
super(message, "SPEC_PARSE_ERROR");
|
|
18
|
+
this.name = "SpecParseError";
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
export class AuthError extends McpOpenApiError {
|
|
22
|
+
constructor(message) {
|
|
23
|
+
super(message, "AUTH_ERROR");
|
|
24
|
+
this.name = "AuthError";
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
export class HttpRequestError extends McpOpenApiError {
|
|
28
|
+
statusCode;
|
|
29
|
+
responseBody;
|
|
30
|
+
constructor(message, statusCode, responseBody) {
|
|
31
|
+
super(message, "HTTP_REQUEST_ERROR");
|
|
32
|
+
this.statusCode = statusCode;
|
|
33
|
+
this.responseBody = responseBody;
|
|
34
|
+
this.name = "HttpRequestError";
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/utils/errors.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,eAAgB,SAAQ,KAAK;IAGxB;IAFjB,YACC,OAAe,EACC,IAAY;QAE5B,KAAK,CAAC,OAAO,CAAC,CAAC;QAFC,SAAI,GAAJ,IAAI,CAAQ;QAG5B,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;IAC/B,CAAC;CACD;AAED,MAAM,OAAO,aAAc,SAAQ,eAAe;IACjD,YAAY,OAAe;QAC1B,KAAK,CAAC,OAAO,EAAE,iBAAiB,CAAC,CAAC;QAClC,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;IAC7B,CAAC;CACD;AAED,MAAM,OAAO,cAAe,SAAQ,eAAe;IAClD,YAAY,OAAe;QAC1B,KAAK,CAAC,OAAO,EAAE,kBAAkB,CAAC,CAAC;QACnC,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;IAC9B,CAAC;CACD;AAED,MAAM,OAAO,SAAU,SAAQ,eAAe;IAC7C,YAAY,OAAe;QAC1B,KAAK,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;QAC7B,IAAI,CAAC,IAAI,GAAG,WAAW,CAAC;IACzB,CAAC;CACD;AAED,MAAM,OAAO,gBAAiB,SAAQ,eAAe;IAGnC;IACA;IAHjB,YACC,OAAe,EACC,UAAmB,EACnB,YAAqB;QAErC,KAAK,CAAC,OAAO,EAAE,oBAAoB,CAAC,CAAC;QAHrB,eAAU,GAAV,UAAU,CAAS;QACnB,iBAAY,GAAZ,YAAY,CAAS;QAGrC,IAAI,CAAC,IAAI,GAAG,kBAAkB,CAAC;IAChC,CAAC;CACD"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** Logs to stderr only — stdout is reserved for MCP stdio transport */
|
|
2
|
+
export declare const logger: {
|
|
3
|
+
info: (msg: string, ...args: unknown[]) => void;
|
|
4
|
+
warn: (msg: string, ...args: unknown[]) => void;
|
|
5
|
+
error: (msg: string, ...args: unknown[]) => void;
|
|
6
|
+
debug: (msg: string, ...args: unknown[]) => void;
|
|
7
|
+
};
|
|
8
|
+
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../../src/utils/logger.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,eAAO,MAAM,MAAM;gBACN,MAAM,WAAW,OAAO,EAAE;gBAE1B,MAAM,WAAW,OAAO,EAAE;iBAEzB,MAAM,WAAW,OAAO,EAAE;iBAE1B,MAAM,WAAW,OAAO,EAAE;CAKvC,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** Logs to stderr only — stdout is reserved for MCP stdio transport */
|
|
2
|
+
export const logger = {
|
|
3
|
+
info: (msg, ...args) => console.error(`[mcp-openapi] ${msg}`, ...args),
|
|
4
|
+
warn: (msg, ...args) => console.error(`[mcp-openapi] WARN: ${msg}`, ...args),
|
|
5
|
+
error: (msg, ...args) => console.error(`[mcp-openapi] ERROR: ${msg}`, ...args),
|
|
6
|
+
debug: (msg, ...args) => {
|
|
7
|
+
if (process.env.DEBUG) {
|
|
8
|
+
console.error(`[mcp-openapi] DEBUG: ${msg}`, ...args);
|
|
9
|
+
}
|
|
10
|
+
},
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../../src/utils/logger.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,MAAM,CAAC,MAAM,MAAM,GAAG;IACrB,IAAI,EAAE,CAAC,GAAW,EAAE,GAAG,IAAe,EAAE,EAAE,CACzC,OAAO,CAAC,KAAK,CAAC,iBAAiB,GAAG,EAAE,EAAE,GAAG,IAAI,CAAC;IAC/C,IAAI,EAAE,CAAC,GAAW,EAAE,GAAG,IAAe,EAAE,EAAE,CACzC,OAAO,CAAC,KAAK,CAAC,uBAAuB,GAAG,EAAE,EAAE,GAAG,IAAI,CAAC;IACrD,KAAK,EAAE,CAAC,GAAW,EAAE,GAAG,IAAe,EAAE,EAAE,CAC1C,OAAO,CAAC,KAAK,CAAC,wBAAwB,GAAG,EAAE,EAAE,GAAG,IAAI,CAAC;IACtD,KAAK,EAAE,CAAC,GAAW,EAAE,GAAG,IAAe,EAAE,EAAE;QAC1C,IAAI,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC;YACvB,OAAO,CAAC,KAAK,CAAC,wBAAwB,GAAG,EAAE,EAAE,GAAG,IAAI,CAAC,CAAC;QACvD,CAAC;IACF,CAAC;CACD,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "mcp-openapi",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "LLM-aware OpenAPI/Swagger to MCP tools converter. Point at any API spec, get instant MCP tools.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"mcp-openapi": "./dist/bin/mcp-openapi.js"
|
|
8
|
+
},
|
|
9
|
+
"exports": {
|
|
10
|
+
".": "./dist/src/index.js"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"dist",
|
|
14
|
+
"README.md"
|
|
15
|
+
],
|
|
16
|
+
"scripts": {
|
|
17
|
+
"build": "tsc",
|
|
18
|
+
"dev": "tsc --watch",
|
|
19
|
+
"test": "vitest run",
|
|
20
|
+
"test:watch": "vitest",
|
|
21
|
+
"lint": "biome check .",
|
|
22
|
+
"prepublishOnly": "pnpm build"
|
|
23
|
+
},
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"@modelcontextprotocol/sdk": "^1.12.0",
|
|
26
|
+
"@apidevtools/swagger-parser": "^10.1.0",
|
|
27
|
+
"yaml": "^2.6.0",
|
|
28
|
+
"openapi-types": "^12.1.3"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"typescript": "^5.7.0",
|
|
32
|
+
"vitest": "^3.0.0",
|
|
33
|
+
"@types/node": "^22.0.0"
|
|
34
|
+
},
|
|
35
|
+
"engines": {
|
|
36
|
+
"node": ">=18.0.0"
|
|
37
|
+
},
|
|
38
|
+
"keywords": [
|
|
39
|
+
"mcp",
|
|
40
|
+
"openapi",
|
|
41
|
+
"swagger",
|
|
42
|
+
"model-context-protocol",
|
|
43
|
+
"ai",
|
|
44
|
+
"llm",
|
|
45
|
+
"api",
|
|
46
|
+
"tools"
|
|
47
|
+
],
|
|
48
|
+
"license": "MIT",
|
|
49
|
+
"repository": {
|
|
50
|
+
"type": "git",
|
|
51
|
+
"url": "https://github.com/Docat0209/auto-revenue",
|
|
52
|
+
"directory": "packages/mcp-servers/openapi"
|
|
53
|
+
}
|
|
54
|
+
}
|