@flink-app/api-docs-plugin 0.12.1-alpha.45 → 0.12.1-alpha.47
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/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flink-app/api-docs-plugin",
|
|
3
|
-
"version": "0.12.1-alpha.
|
|
3
|
+
"version": "0.12.1-alpha.47",
|
|
4
4
|
"description": "Flink plugin that generates API documentation based on JSON schemas",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "echo \"Error: no test specified\"",
|
|
7
|
-
"
|
|
7
|
+
"build": "npm run build:react && tsc && npm run copy:assets",
|
|
8
8
|
"build:react": "cd react-app && npm run build",
|
|
9
9
|
"copy:assets": "mkdir -p dist/react-app && cp -r react-app/dist/* dist/react-app/",
|
|
10
10
|
"watch": "tsc-watch",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"types": "dist/index.d.ts",
|
|
22
22
|
"main": "dist/index.js",
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@flink-app/flink": "^0.12.1-alpha.
|
|
24
|
+
"@flink-app/flink": "^0.12.1-alpha.47",
|
|
25
25
|
"@types/express": "^4.17.12",
|
|
26
26
|
"@types/node": "22.13.10",
|
|
27
27
|
"express": "^4.18.2",
|
|
@@ -29,5 +29,5 @@
|
|
|
29
29
|
"tsc-watch": "^4.2.9",
|
|
30
30
|
"typescript": "5.4.5"
|
|
31
31
|
},
|
|
32
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "a98a0af7f11e4a97f68da4d0d67677df7d2a2749"
|
|
33
33
|
}
|
package/dist/mcp-server.d.ts
DELETED
package/dist/mcp-server.js
DELETED
|
@@ -1,250 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.createMcpHandler = void 0;
|
|
40
|
-
// Helper function to simplify schema conversion
|
|
41
|
-
function flattenProperties(properties, required, parent) {
|
|
42
|
-
if (required === void 0) { required = []; }
|
|
43
|
-
if (parent === void 0) { parent = ""; }
|
|
44
|
-
var result = [];
|
|
45
|
-
for (var _i = 0, _a = Object.entries(properties || {}); _i < _a.length; _i++) {
|
|
46
|
-
var _b = _a[_i], key = _b[0], value = _b[1];
|
|
47
|
-
var path = parent ? "".concat(parent, ".").concat(key) : key;
|
|
48
|
-
result.push({
|
|
49
|
-
name: path,
|
|
50
|
-
type: value.type,
|
|
51
|
-
description: value.description,
|
|
52
|
-
required: required.includes(key),
|
|
53
|
-
});
|
|
54
|
-
if (value.type === "object" && value.properties) {
|
|
55
|
-
result = result.concat(flattenProperties(value.properties, value.required || [], path));
|
|
56
|
-
}
|
|
57
|
-
if (value.type === "array" && value.items && value.items.type === "object" && value.items.properties) {
|
|
58
|
-
result = result.concat(flattenProperties(value.items.properties, value.items.required || [], "".concat(path, "[]")));
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
return result;
|
|
62
|
-
}
|
|
63
|
-
// For creating an Express endpoint that handles MCP requests
|
|
64
|
-
function createMcpHandler(app) {
|
|
65
|
-
var _this = this;
|
|
66
|
-
return function (req, res) { return __awaiter(_this, void 0, void 0, function () {
|
|
67
|
-
var endpoints, _a, method, params, tools, _b, name_1, args, endpoint, response_1;
|
|
68
|
-
return __generator(this, function (_c) {
|
|
69
|
-
try {
|
|
70
|
-
endpoints = app.handlers.map(function (handler) {
|
|
71
|
-
var _a, _b, _c, _d, _e, _f;
|
|
72
|
-
return ({
|
|
73
|
-
path: handler.routeProps.path,
|
|
74
|
-
method: handler.routeProps.method.toUpperCase(),
|
|
75
|
-
description: (_b = (_a = handler.schema) === null || _a === void 0 ? void 0 : _a.reqSchema) === null || _b === void 0 ? void 0 : _b.description,
|
|
76
|
-
queryParams: handler.queryMetadata,
|
|
77
|
-
pathParams: handler.paramsMetadata,
|
|
78
|
-
requestBody: ((_d = (_c = handler.schema) === null || _c === void 0 ? void 0 : _c.reqSchema) === null || _d === void 0 ? void 0 : _d.properties)
|
|
79
|
-
? flattenProperties(handler.schema.reqSchema.properties, handler.schema.reqSchema.required || [])
|
|
80
|
-
: undefined,
|
|
81
|
-
responseBody: ((_f = (_e = handler.schema) === null || _e === void 0 ? void 0 : _e.resSchema) === null || _f === void 0 ? void 0 : _f.properties)
|
|
82
|
-
? flattenProperties(handler.schema.resSchema.properties, handler.schema.resSchema.required || [])
|
|
83
|
-
: undefined,
|
|
84
|
-
});
|
|
85
|
-
});
|
|
86
|
-
// For WebSocket upgrade requests
|
|
87
|
-
if (req.headers.upgrade === "websocket") {
|
|
88
|
-
// Handle WebSocket upgrade (requires additional WebSocket setup)
|
|
89
|
-
res.status(426).send("WebSocket support not yet implemented");
|
|
90
|
-
return [2 /*return*/];
|
|
91
|
-
}
|
|
92
|
-
// For regular HTTP requests to the MCP endpoint
|
|
93
|
-
if (req.method === "GET") {
|
|
94
|
-
res.json({
|
|
95
|
-
name: "api-docs-mcp-server",
|
|
96
|
-
version: "1.0.0",
|
|
97
|
-
description: "MCP server providing API documentation tools",
|
|
98
|
-
tools: endpoints.length,
|
|
99
|
-
endpoints: endpoints.map(function (e) { return ({
|
|
100
|
-
path: e.path,
|
|
101
|
-
method: e.method,
|
|
102
|
-
description: e.description,
|
|
103
|
-
}); }),
|
|
104
|
-
});
|
|
105
|
-
return [2 /*return*/];
|
|
106
|
-
}
|
|
107
|
-
// Handle MCP protocol messages over HTTP POST
|
|
108
|
-
if (req.method === "POST") {
|
|
109
|
-
_a = req.body, method = _a.method, params = _a.params;
|
|
110
|
-
// Handle tools/list
|
|
111
|
-
if (method === "tools/list") {
|
|
112
|
-
tools = endpoints.map(function (endpoint) { return ({
|
|
113
|
-
name: "".concat(endpoint.method.toLowerCase(), "_").concat(endpoint.path.replace(/[/:]/g, "_")),
|
|
114
|
-
description: endpoint.description || "".concat(endpoint.method, " ").concat(endpoint.path),
|
|
115
|
-
inputSchema: generateInputSchema(endpoint),
|
|
116
|
-
}); });
|
|
117
|
-
res.json({ tools: tools });
|
|
118
|
-
return [2 /*return*/];
|
|
119
|
-
}
|
|
120
|
-
// Handle tools/call
|
|
121
|
-
if (method === "tools/call") {
|
|
122
|
-
_b = params || {}, name_1 = _b.name, args = _b.arguments;
|
|
123
|
-
endpoint = endpoints.find(function (e) { return "".concat(e.method.toLowerCase(), "_").concat(e.path.replace(/[/:]/g, "_")) === name_1; });
|
|
124
|
-
if (!endpoint) {
|
|
125
|
-
res.json({
|
|
126
|
-
content: [
|
|
127
|
-
{
|
|
128
|
-
type: "text",
|
|
129
|
-
text: "Tool not found: ".concat(name_1),
|
|
130
|
-
},
|
|
131
|
-
],
|
|
132
|
-
});
|
|
133
|
-
return [2 /*return*/];
|
|
134
|
-
}
|
|
135
|
-
response_1 = "Endpoint Details:\n";
|
|
136
|
-
response_1 += "Path: ".concat(endpoint.path, "\n");
|
|
137
|
-
response_1 += "Method: ".concat(endpoint.method, "\n");
|
|
138
|
-
if (endpoint.description) {
|
|
139
|
-
response_1 += "Description: ".concat(endpoint.description, "\n");
|
|
140
|
-
}
|
|
141
|
-
if (endpoint.pathParams && endpoint.pathParams.length > 0) {
|
|
142
|
-
response_1 += "\nPath Parameters:\n";
|
|
143
|
-
endpoint.pathParams.forEach(function (param) {
|
|
144
|
-
response_1 += "- ".concat(param.name, ": ").concat(param.description || "No description", "\n");
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
if (endpoint.queryParams && endpoint.queryParams.length > 0) {
|
|
148
|
-
response_1 += "\nQuery Parameters:\n";
|
|
149
|
-
endpoint.queryParams.forEach(function (param) {
|
|
150
|
-
response_1 += "- ".concat(param.name).concat(param.required ? " (required)" : "", ": ").concat(param.type || "string", " - ").concat(param.description || "No description", "\n");
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
if (endpoint.requestBody && endpoint.requestBody.length > 0) {
|
|
154
|
-
response_1 += "\nRequest Body Schema:\n";
|
|
155
|
-
response_1 += JSON.stringify(endpoint.requestBody, null, 2);
|
|
156
|
-
}
|
|
157
|
-
if (endpoint.responseBody && endpoint.responseBody.length > 0) {
|
|
158
|
-
response_1 += "\nResponse Body Schema:\n";
|
|
159
|
-
response_1 += JSON.stringify(endpoint.responseBody, null, 2);
|
|
160
|
-
}
|
|
161
|
-
res.json({
|
|
162
|
-
content: [
|
|
163
|
-
{
|
|
164
|
-
type: "text",
|
|
165
|
-
text: response_1,
|
|
166
|
-
},
|
|
167
|
-
],
|
|
168
|
-
});
|
|
169
|
-
return [2 /*return*/];
|
|
170
|
-
}
|
|
171
|
-
res.status(400).json({
|
|
172
|
-
error: "Unknown method",
|
|
173
|
-
details: "Method ".concat(method, " is not supported"),
|
|
174
|
-
});
|
|
175
|
-
return [2 /*return*/];
|
|
176
|
-
}
|
|
177
|
-
res.status(405).send("Method not allowed");
|
|
178
|
-
}
|
|
179
|
-
catch (error) {
|
|
180
|
-
console.error("MCP handler error:", error);
|
|
181
|
-
res.status(500).send("Internal server error");
|
|
182
|
-
}
|
|
183
|
-
return [2 /*return*/];
|
|
184
|
-
});
|
|
185
|
-
}); };
|
|
186
|
-
}
|
|
187
|
-
exports.createMcpHandler = createMcpHandler;
|
|
188
|
-
function generateInputSchema(endpoint) {
|
|
189
|
-
var inputSchema = {
|
|
190
|
-
type: "object",
|
|
191
|
-
properties: {},
|
|
192
|
-
required: [],
|
|
193
|
-
};
|
|
194
|
-
// Add path parameters
|
|
195
|
-
if (endpoint.pathParams && endpoint.pathParams.length > 0) {
|
|
196
|
-
endpoint.pathParams.forEach(function (param) {
|
|
197
|
-
inputSchema.properties[param.name] = {
|
|
198
|
-
type: "string",
|
|
199
|
-
description: param.description || "Path parameter: ".concat(param.name),
|
|
200
|
-
};
|
|
201
|
-
inputSchema.required.push(param.name);
|
|
202
|
-
});
|
|
203
|
-
}
|
|
204
|
-
// Add query parameters
|
|
205
|
-
if (endpoint.queryParams && endpoint.queryParams.length > 0) {
|
|
206
|
-
endpoint.queryParams.forEach(function (param) {
|
|
207
|
-
inputSchema.properties[param.name] = {
|
|
208
|
-
type: param.type || "string",
|
|
209
|
-
description: param.description || "Query parameter: ".concat(param.name),
|
|
210
|
-
};
|
|
211
|
-
if (param.required) {
|
|
212
|
-
inputSchema.required.push(param.name);
|
|
213
|
-
}
|
|
214
|
-
});
|
|
215
|
-
}
|
|
216
|
-
// Add request body
|
|
217
|
-
if (endpoint.requestBody && endpoint.requestBody.length > 0) {
|
|
218
|
-
var requestBodySchema_1 = {
|
|
219
|
-
type: "object",
|
|
220
|
-
properties: {},
|
|
221
|
-
required: [],
|
|
222
|
-
};
|
|
223
|
-
// Convert flat properties back to nested structure for schema
|
|
224
|
-
endpoint.requestBody.forEach(function (prop) {
|
|
225
|
-
var parts = prop.name.split(".");
|
|
226
|
-
var current = requestBodySchema_1.properties;
|
|
227
|
-
for (var i = 0; i < parts.length - 1; i++) {
|
|
228
|
-
var part = parts[i];
|
|
229
|
-
if (!current[part]) {
|
|
230
|
-
current[part] = {
|
|
231
|
-
type: "object",
|
|
232
|
-
properties: {},
|
|
233
|
-
};
|
|
234
|
-
}
|
|
235
|
-
current = current[part].properties;
|
|
236
|
-
}
|
|
237
|
-
var lastPart = parts[parts.length - 1];
|
|
238
|
-
current[lastPart] = {
|
|
239
|
-
type: prop.type,
|
|
240
|
-
description: prop.description,
|
|
241
|
-
};
|
|
242
|
-
if (prop.required) {
|
|
243
|
-
requestBodySchema_1.required.push(parts[0]);
|
|
244
|
-
}
|
|
245
|
-
});
|
|
246
|
-
inputSchema.properties.body = requestBodySchema_1;
|
|
247
|
-
inputSchema.required.push("body");
|
|
248
|
-
}
|
|
249
|
-
return inputSchema;
|
|
250
|
-
}
|