@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 CHANGED
@@ -12,9 +12,9 @@ async function main() {
12
12
  const transport = new StdioServerTransport();
13
13
  await server.connect(transport);
14
14
  // πŸ‘‡ 이 쀄이 핡심
15
- // process.stdin.resume();
15
+ process.stdin.resume();
16
16
  }
17
- // main().catch((err) => {
18
- // process.stderr.write(err.stack + "\n");
19
- // process.exit(1);
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(api) }],
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(swagger.paths) }],
28
+ content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
14
29
  };
15
30
  });
16
31
  }
@@ -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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@koseha/api-mcp",
3
- "version": "0.0.4",
3
+ "version": "0.0.6",
4
4
  "description": "An API MCP based on Swagger docs",
5
5
  "keywords": [],
6
6
  "homepage": "https://github.com/koseha/api-mcp#readme",