@koseha/api-mcp 0.0.4 β 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +5 -5
- package/dist/tools/getApiDetail.tool.js +50 -2
- package/dist/tools/getApiList.tool.js +16 -1
- package/dist/tools/index.js +0 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -12,9 +12,9 @@ async function main() {
|
|
|
12
12
|
const transport = new StdioServerTransport();
|
|
13
13
|
await server.connect(transport);
|
|
14
14
|
// π μ΄ μ€μ΄ ν΅μ¬
|
|
15
|
-
|
|
15
|
+
process.stdin.resume();
|
|
16
16
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
main().catch((err) => {
|
|
18
|
+
process.stderr.write(err.stack + "\n");
|
|
19
|
+
process.exit(1);
|
|
20
|
+
});
|
|
@@ -20,9 +20,57 @@ export function registerGetApiDetail(server) {
|
|
|
20
20
|
};
|
|
21
21
|
}
|
|
22
22
|
const swagger = await loadSwagger();
|
|
23
|
-
const api = swagger.paths[requestUrl][httpMethod];
|
|
23
|
+
const api = swagger.paths?.[requestUrl]?.[httpMethod];
|
|
24
|
+
if (!api) {
|
|
25
|
+
return {
|
|
26
|
+
content: [{ type: "text", text: "ν΄λΉ APIλ₯Ό μ°Ύμ μ μμ΅λλ€." }],
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
// parameters λ³ν
|
|
30
|
+
const parameters = (api.parameters || []).map((param) => ({
|
|
31
|
+
name: param.name,
|
|
32
|
+
in: param.in,
|
|
33
|
+
required: param.required || false,
|
|
34
|
+
schema: {
|
|
35
|
+
type: param.schema?.type || null,
|
|
36
|
+
format: param.schema?.format || null,
|
|
37
|
+
enum: param.schema?.enum || null,
|
|
38
|
+
},
|
|
39
|
+
}));
|
|
40
|
+
// requestBody λ³ν
|
|
41
|
+
let requestBody = null;
|
|
42
|
+
if (api.requestBody?.content) {
|
|
43
|
+
const jsonContent = api.requestBody.content["application/json"];
|
|
44
|
+
if (jsonContent?.schema) {
|
|
45
|
+
const schema = jsonContent.schema;
|
|
46
|
+
requestBody = {
|
|
47
|
+
required: schema.required || [],
|
|
48
|
+
type: schema.type || "object",
|
|
49
|
+
properties: schema.properties || {},
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
// responses λ³ν (200 μλ΅μ schema μΆμΆ)
|
|
54
|
+
let responses = null;
|
|
55
|
+
if (api.responses?.["200"]?.content?.["application/json"]?.schema) {
|
|
56
|
+
const schema = api.responses["200"].content["application/json"].schema;
|
|
57
|
+
responses = {
|
|
58
|
+
type: schema.type || "object",
|
|
59
|
+
properties: schema.properties || {},
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
const result = {};
|
|
63
|
+
if (parameters.length > 0) {
|
|
64
|
+
result.parameters = parameters;
|
|
65
|
+
}
|
|
66
|
+
if (requestBody) {
|
|
67
|
+
result.requestBody = requestBody;
|
|
68
|
+
}
|
|
69
|
+
if (responses) {
|
|
70
|
+
result.responses = responses;
|
|
71
|
+
}
|
|
24
72
|
return {
|
|
25
|
-
content: [{ type: "text", text: JSON.stringify(
|
|
73
|
+
content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
|
|
26
74
|
};
|
|
27
75
|
});
|
|
28
76
|
}
|
|
@@ -9,8 +9,23 @@ export function registerGetApiList(server) {
|
|
|
9
9
|
}, async () => {
|
|
10
10
|
const swagger = await loadSwagger();
|
|
11
11
|
// paths β list κ°κ³΅
|
|
12
|
+
const result = {};
|
|
13
|
+
for (const [path, methods] of Object.entries(swagger.paths || {})) {
|
|
14
|
+
if (!methods || typeof methods !== "object")
|
|
15
|
+
continue;
|
|
16
|
+
result[path] = {};
|
|
17
|
+
for (const [method, operation] of Object.entries(methods)) {
|
|
18
|
+
if (typeof operation === "object" && operation !== null) {
|
|
19
|
+
result[path][method] = {
|
|
20
|
+
tags: operation.tags,
|
|
21
|
+
operationId: operation.operationId,
|
|
22
|
+
summary: operation.summary,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
12
27
|
return {
|
|
13
|
-
content: [{ type: "text", text: JSON.stringify(
|
|
28
|
+
content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
|
|
14
29
|
};
|
|
15
30
|
});
|
|
16
31
|
}
|
package/dist/tools/index.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* λͺ¨λ Tool λ±λ‘
|
|
3
3
|
*/
|
|
4
|
-
import { registerAddTool } from "./add.tool.js";
|
|
5
4
|
import { registerGetApiList } from "./getApiList.tool.js";
|
|
6
5
|
import { registerGetApiDetail } from "./getApiDetail.tool.js";
|
|
7
6
|
export function registerTools(server) {
|
|
8
|
-
registerAddTool(server);
|
|
9
7
|
registerGetApiList(server);
|
|
10
8
|
registerGetApiDetail(server);
|
|
11
9
|
}
|