@vfarcic/dot-ai 0.90.0 → 0.92.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 +33 -5
- package/dist/interfaces/mcp.d.ts +7 -1
- package/dist/interfaces/mcp.d.ts.map +1 -1
- package/dist/interfaces/mcp.js +69 -22
- package/dist/interfaces/openapi-generator.d.ts +110 -0
- package/dist/interfaces/openapi-generator.d.ts.map +1 -0
- package/dist/interfaces/openapi-generator.js +468 -0
- package/dist/interfaces/rest-api.d.ts +124 -0
- package/dist/interfaces/rest-api.d.ts.map +1 -0
- package/dist/interfaces/rest-api.js +341 -0
- package/dist/interfaces/rest-registry.d.ts +108 -0
- package/dist/interfaces/rest-registry.d.ts.map +1 -0
- package/dist/interfaces/rest-registry.js +187 -0
- package/dist/tools/index.d.ts +1 -0
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +6 -1
- package/dist/tools/remediate.d.ts +173 -0
- package/dist/tools/remediate.d.ts.map +1 -0
- package/dist/tools/remediate.js +1158 -0
- package/package.json +7 -6
- package/prompts/remediate-final-analysis.md +243 -0
- package/prompts/remediate-investigation.md +196 -0
- package/shared-prompts/deploy.md +23 -0
- package/shared-prompts/prd-create.md +1 -1
- package/shared-prompts/remediate.md +44 -0
- package/shared-prompts/setup.md +0 -23
package/README.md
CHANGED
|
@@ -16,6 +16,11 @@ DevOps AI Toolkit is an AI-powered development productivity platform that enhanc
|
|
|
16
16
|
- **Platform Engineers**: Create organizational deployment patterns that enhance AI recommendations with institutional knowledge and best practices, and scan cluster resources to enable semantic matching for dramatically improved recommendation accuracy
|
|
17
17
|
- **Security Engineers**: Define governance policies that integrate into deployment workflows with optional Kyverno enforcement
|
|
18
18
|
|
|
19
|
+
### Kubernetes Issue Remediation
|
|
20
|
+
- **DevOps Engineers**: Quickly diagnose and fix Kubernetes issues without deep troubleshooting expertise
|
|
21
|
+
- **SRE Teams**: Automate root cause analysis and generate executable remediation commands
|
|
22
|
+
- **Support Teams**: Handle incident response with AI-guided investigation and repair workflows
|
|
23
|
+
|
|
19
24
|
### Documentation Testing
|
|
20
25
|
- **Documentation Maintainers**: Automatically validate documentation accuracy and catch outdated content
|
|
21
26
|
- **Technical Writers**: Identify which sections need updates and prioritize work effectively
|
|
@@ -28,6 +33,7 @@ DevOps AI Toolkit is an AI-powered development productivity platform that enhanc
|
|
|
28
33
|
|
|
29
34
|
### AI Integration
|
|
30
35
|
- **AI Agents**: Integrate all capabilities with Claude Code, Cursor, or VS Code for conversational workflows
|
|
36
|
+
- **REST API**: Access all tools via standard HTTP endpoints for CI/CD pipelines, automation scripts, and traditional applications
|
|
31
37
|
|
|
32
38
|
## Key Features
|
|
33
39
|
|
|
@@ -61,6 +67,13 @@ Result: Finds sqls.devopstoolkit.live as perfect match ✨
|
|
|
61
67
|
|
|
62
68
|
**Get Started**: See the [Tools and Features Overview](./docs/mcp-tools-overview.md) for complete guide to all available tools including capability management, deployment recommendations, and workflow integration.
|
|
63
69
|
|
|
70
|
+
### Kubernetes Issue Remediation
|
|
71
|
+
🔍 **AI-Powered Root Cause Analysis**: Multi-step investigation loop identifies the real cause behind Kubernetes failures
|
|
72
|
+
🛠️ **Executable Remediation**: Generates specific kubectl commands with risk assessment and validation
|
|
73
|
+
⚡ **Dual Execution Modes**: Manual approval workflow or automatic execution based on confidence thresholds
|
|
74
|
+
🔒 **Safety Mechanisms**: Automatic fallback to manual mode when validation discovers additional issues
|
|
75
|
+
🎯 **Cross-Resource Intelligence**: Understands how pod issues may require fixes in different resource types (storage, networking, etc.)
|
|
76
|
+
|
|
64
77
|
### Documentation Testing & Validation
|
|
65
78
|
📖 **Automated Testing**: Validates documentation by executing commands and testing examples
|
|
66
79
|
🔍 **Two-Phase Validation**: Tests both functionality (does it work?) and semantic accuracy (are descriptions truthful?)
|
|
@@ -124,13 +137,11 @@ This video explains the platform engineering problem and demonstrates the Kubern
|
|
|
124
137
|
**For organizational pattern management:**
|
|
125
138
|
- **Vector DB service** (Qdrant) for pattern storage and semantic search
|
|
126
139
|
- **OpenAI API key** (required) for semantic pattern matching and vector operations
|
|
127
|
-
- See the [Pattern Management Guide](./docs/pattern-management-guide.md) for complete setup
|
|
128
140
|
|
|
129
141
|
**For policy management and governance:**
|
|
130
142
|
- **Vector DB service** (Qdrant) for policy storage and semantic search
|
|
131
143
|
- **OpenAI API key** (required) for semantic policy matching and vector operations
|
|
132
144
|
- **Optional**: Kyverno installed in cluster for active policy enforcement
|
|
133
|
-
- See the [Policy Management Guide](./docs/policy-management-guide.md) for complete setup
|
|
134
145
|
|
|
135
146
|
### Installation
|
|
136
147
|
|
|
@@ -222,7 +233,6 @@ Agent: ✅ Successfully deployed! Your production API is running with external a
|
|
|
222
233
|
```
|
|
223
234
|
User: I want to scan my cluster for resource capabilities to improve recommendations
|
|
224
235
|
|
|
225
|
-
Agent: I'll help you scan your cluster to discover semantic capabilities. This will dramatically improve recommendation accuracy.
|
|
226
236
|
[Uses manageOrgData with capabilities scanning]
|
|
227
237
|
|
|
228
238
|
Agent: Would you like to scan all cluster resources or specify a subset?
|
|
@@ -241,6 +251,26 @@ Agent: Let me get enhanced recommendations using your capability data.
|
|
|
241
251
|
Agent: Perfect! I found sqls.devopstoolkit.live as the top match - it's a managed database solution supporting PostgreSQL with multi-cloud capabilities and low complexity. Much better than the generic StatefulSet approach I would have suggested before!
|
|
242
252
|
```
|
|
243
253
|
|
|
254
|
+
**Example: Kubernetes Issue Remediation**
|
|
255
|
+
```
|
|
256
|
+
User: Something is wrong with my database in postgres-demo namespace
|
|
257
|
+
|
|
258
|
+
Agent: I'll investigate the database issue using AI-powered analysis.
|
|
259
|
+
[Uses remediate tool for systematic investigation]
|
|
260
|
+
|
|
261
|
+
Agent: 🔍 Root Cause (95% confidence): PostgreSQL pod can't start because the required PersistentVolumeClaim 'postgres-pvc' is missing.
|
|
262
|
+
|
|
263
|
+
🔧 Recommended Fix: Create missing PVC
|
|
264
|
+
- Risk Level: Low
|
|
265
|
+
- Command: kubectl apply [PVC manifest]
|
|
266
|
+
|
|
267
|
+
Choose execution: 1) Execute via MCP 2) Show commands
|
|
268
|
+
|
|
269
|
+
User: 1
|
|
270
|
+
|
|
271
|
+
Agent: ✅ Issue Resolved! Created postgres-pvc, pod transitioned to Running state. Database is operational!
|
|
272
|
+
```
|
|
273
|
+
|
|
244
274
|
**Example: Policy Management**
|
|
245
275
|
```
|
|
246
276
|
User: I want to create a policy requiring resource limits on all deployments
|
|
@@ -303,8 +333,6 @@ Agent: I'm executing the PRD creation workflow. Please describe the feature you
|
|
|
303
333
|
|
|
304
334
|
📖 **[Complete MCP Setup Guide →](docs/mcp-setup.md)** - Detailed configuration, troubleshooting, and examples
|
|
305
335
|
|
|
306
|
-
|
|
307
|
-
|
|
308
336
|
## Troubleshooting
|
|
309
337
|
|
|
310
338
|
### MCP Issues
|
package/dist/interfaces/mcp.d.ts
CHANGED
|
@@ -24,9 +24,15 @@ export declare class MCPServer {
|
|
|
24
24
|
private config;
|
|
25
25
|
private httpServer?;
|
|
26
26
|
private httpTransport?;
|
|
27
|
+
private restRegistry;
|
|
28
|
+
private restApiRouter;
|
|
27
29
|
constructor(dotAI: DotAI, config: MCPServerConfig);
|
|
28
30
|
/**
|
|
29
|
-
*
|
|
31
|
+
* Helper method to register a tool with both MCP server and REST registry
|
|
32
|
+
*/
|
|
33
|
+
private registerTool;
|
|
34
|
+
/**
|
|
35
|
+
* Register all tools with McpServer and REST registry
|
|
30
36
|
*/
|
|
31
37
|
private registerTools;
|
|
32
38
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp.d.ts","sourceRoot":"","sources":["../../src/interfaces/mcp.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAWH,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"mcp.d.ts","sourceRoot":"","sources":["../../src/interfaces/mcp.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAWH,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAgEtC,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IAC7B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,UAAU,GAAG,WAAW,CAAC;CACxC;AAED,qBAAa,SAAS;IACpB,OAAO,CAAC,MAAM,CAAY;IAC1B,OAAO,CAAC,KAAK,CAAQ;IACrB,OAAO,CAAC,WAAW,CAAkB;IACrC,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,gBAAgB,CAAa;IACrC,OAAO,CAAC,MAAM,CAAkB;IAChC,OAAO,CAAC,UAAU,CAAC,CAAkC;IACrD,OAAO,CAAC,aAAa,CAAC,CAAgC;IACtD,OAAO,CAAC,YAAY,CAAmB;IACvC,OAAO,CAAC,aAAa,CAAgB;gBAEzB,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,eAAe;IAsCjD;;OAEG;IACH,OAAO,CAAC,YAAY;IAsBpB;;OAEG;IACH,OAAO,CAAC,aAAa;IAqMrB;;OAEG;IACH,OAAO,CAAC,eAAe;IAqCvB,OAAO,CAAC,iBAAiB;IAInB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;YAkBd,mBAAmB;YAMnB,kBAAkB;YAiFlB,gBAAgB;IAexB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAgB3B,OAAO,IAAI,OAAO;CAGnB"}
|
package/dist/interfaces/mcp.js
CHANGED
|
@@ -22,7 +22,10 @@ const deploy_manifests_1 = require("../tools/deploy-manifests");
|
|
|
22
22
|
const version_1 = require("../tools/version");
|
|
23
23
|
const test_docs_1 = require("../tools/test-docs");
|
|
24
24
|
const organizational_data_1 = require("../tools/organizational-data");
|
|
25
|
+
const remediate_1 = require("../tools/remediate");
|
|
25
26
|
const prompts_1 = require("../tools/prompts");
|
|
27
|
+
const rest_registry_1 = require("./rest-registry");
|
|
28
|
+
const rest_api_1 = require("./rest-api");
|
|
26
29
|
class MCPServer {
|
|
27
30
|
server;
|
|
28
31
|
dotAI;
|
|
@@ -32,6 +35,8 @@ class MCPServer {
|
|
|
32
35
|
config;
|
|
33
36
|
httpServer;
|
|
34
37
|
httpTransport;
|
|
38
|
+
restRegistry;
|
|
39
|
+
restApiRouter;
|
|
35
40
|
constructor(dotAI, config) {
|
|
36
41
|
this.dotAI = dotAI;
|
|
37
42
|
this.config = config;
|
|
@@ -51,68 +56,93 @@ class MCPServer {
|
|
|
51
56
|
version: config.version,
|
|
52
57
|
author: config.author,
|
|
53
58
|
});
|
|
59
|
+
// Initialize REST API components
|
|
60
|
+
this.restRegistry = new rest_registry_1.RestToolRegistry(this.logger);
|
|
61
|
+
this.restApiRouter = new rest_api_1.RestApiRouter(this.restRegistry, this.dotAI, this.logger);
|
|
54
62
|
// Register all tools and prompts directly with McpServer
|
|
55
63
|
this.registerTools();
|
|
56
64
|
this.registerPrompts();
|
|
57
65
|
}
|
|
58
66
|
/**
|
|
59
|
-
*
|
|
67
|
+
* Helper method to register a tool with both MCP server and REST registry
|
|
68
|
+
*/
|
|
69
|
+
registerTool(name, description, inputSchema, handler, category, tags) {
|
|
70
|
+
// Register with MCP server
|
|
71
|
+
this.server.tool(name, description, inputSchema, handler);
|
|
72
|
+
// Register with REST registry
|
|
73
|
+
this.restRegistry.registerTool({
|
|
74
|
+
name,
|
|
75
|
+
description,
|
|
76
|
+
inputSchema,
|
|
77
|
+
handler,
|
|
78
|
+
category,
|
|
79
|
+
tags
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Register all tools with McpServer and REST registry
|
|
60
84
|
*/
|
|
61
85
|
registerTools() {
|
|
62
86
|
// Register recommend tool
|
|
63
|
-
this.
|
|
87
|
+
this.registerTool(recommend_1.RECOMMEND_TOOL_NAME, recommend_1.RECOMMEND_TOOL_DESCRIPTION, recommend_1.RECOMMEND_TOOL_INPUT_SCHEMA, async (args) => {
|
|
64
88
|
const requestId = this.generateRequestId();
|
|
65
89
|
this.logger.info(`Processing ${recommend_1.RECOMMEND_TOOL_NAME} tool request`, {
|
|
66
90
|
requestId,
|
|
67
91
|
});
|
|
68
92
|
return await (0, recommend_1.handleRecommendTool)(args, this.dotAI, this.logger, requestId);
|
|
69
|
-
});
|
|
93
|
+
}, 'AI Tools', ['recommendation', 'kubernetes', 'deployment']);
|
|
70
94
|
// Register chooseSolution tool
|
|
71
|
-
this.
|
|
95
|
+
this.registerTool(choose_solution_1.CHOOSESOLUTION_TOOL_NAME, choose_solution_1.CHOOSESOLUTION_TOOL_DESCRIPTION, choose_solution_1.CHOOSESOLUTION_TOOL_INPUT_SCHEMA, async (args) => {
|
|
72
96
|
const requestId = this.generateRequestId();
|
|
73
97
|
this.logger.info(`Processing ${choose_solution_1.CHOOSESOLUTION_TOOL_NAME} tool request`, { requestId });
|
|
74
98
|
return await (0, choose_solution_1.handleChooseSolutionTool)(args, this.dotAI, this.logger, requestId);
|
|
75
|
-
});
|
|
99
|
+
}, 'AI Tools', ['solution', 'kubernetes', 'configuration']);
|
|
76
100
|
// Register answerQuestion tool
|
|
77
|
-
this.
|
|
101
|
+
this.registerTool(answer_question_1.ANSWERQUESTION_TOOL_NAME, answer_question_1.ANSWERQUESTION_TOOL_DESCRIPTION, answer_question_1.ANSWERQUESTION_TOOL_INPUT_SCHEMA, async (args) => {
|
|
78
102
|
const requestId = this.generateRequestId();
|
|
79
103
|
this.logger.info(`Processing ${answer_question_1.ANSWERQUESTION_TOOL_NAME} tool request`, { requestId });
|
|
80
104
|
return await (0, answer_question_1.handleAnswerQuestionTool)(args, this.dotAI, this.logger, requestId);
|
|
81
|
-
});
|
|
105
|
+
}, 'AI Tools', ['configuration', 'questions', 'workflow']);
|
|
82
106
|
// Register generateManifests tool
|
|
83
|
-
this.
|
|
107
|
+
this.registerTool(generate_manifests_1.GENERATEMANIFESTS_TOOL_NAME, generate_manifests_1.GENERATEMANIFESTS_TOOL_DESCRIPTION, generate_manifests_1.GENERATEMANIFESTS_TOOL_INPUT_SCHEMA, async (args) => {
|
|
84
108
|
const requestId = this.generateRequestId();
|
|
85
109
|
this.logger.info(`Processing ${generate_manifests_1.GENERATEMANIFESTS_TOOL_NAME} tool request`, { requestId });
|
|
86
110
|
return await (0, generate_manifests_1.handleGenerateManifestsTool)(args, this.dotAI, this.logger, requestId);
|
|
87
|
-
});
|
|
111
|
+
}, 'Deployment', ['manifests', 'kubernetes', 'generation']);
|
|
88
112
|
// Register deployManifests tool
|
|
89
|
-
this.
|
|
113
|
+
this.registerTool(deploy_manifests_1.DEPLOYMANIFESTS_TOOL_NAME, deploy_manifests_1.DEPLOYMANIFESTS_TOOL_DESCRIPTION, deploy_manifests_1.DEPLOYMANIFESTS_TOOL_INPUT_SCHEMA, async (args) => {
|
|
90
114
|
const requestId = this.generateRequestId();
|
|
91
115
|
this.logger.info(`Processing ${deploy_manifests_1.DEPLOYMANIFESTS_TOOL_NAME} tool request`, { requestId });
|
|
92
116
|
return await (0, deploy_manifests_1.handleDeployManifestsTool)(args, this.dotAI, this.logger, requestId);
|
|
93
|
-
});
|
|
117
|
+
}, 'Deployment', ['deployment', 'kubernetes', 'kubectl']);
|
|
94
118
|
// Register version tool
|
|
95
|
-
this.
|
|
119
|
+
this.registerTool(version_1.VERSION_TOOL_NAME, version_1.VERSION_TOOL_DESCRIPTION, version_1.VERSION_TOOL_INPUT_SCHEMA, async (args) => {
|
|
96
120
|
const requestId = this.generateRequestId();
|
|
97
121
|
this.logger.info(`Processing ${version_1.VERSION_TOOL_NAME} tool request`, {
|
|
98
122
|
requestId,
|
|
99
123
|
});
|
|
100
124
|
return await (0, version_1.handleVersionTool)(args, this.logger, requestId);
|
|
101
|
-
});
|
|
125
|
+
}, 'System', ['version', 'diagnostics', 'status']);
|
|
102
126
|
// Register testDocs tool
|
|
103
|
-
this.
|
|
127
|
+
this.registerTool(test_docs_1.TESTDOCS_TOOL_NAME, test_docs_1.TESTDOCS_TOOL_DESCRIPTION, test_docs_1.TESTDOCS_TOOL_INPUT_SCHEMA, async (args) => {
|
|
104
128
|
const requestId = this.generateRequestId();
|
|
105
129
|
this.logger.info(`Processing ${test_docs_1.TESTDOCS_TOOL_NAME} tool request`, {
|
|
106
130
|
requestId,
|
|
107
131
|
});
|
|
108
132
|
return await (0, test_docs_1.handleTestDocsTool)(args, null, this.logger, requestId);
|
|
109
|
-
});
|
|
133
|
+
}, 'Documentation', ['testing', 'validation', 'docs']);
|
|
110
134
|
// Register organizational-data tool
|
|
111
|
-
this.
|
|
135
|
+
this.registerTool(organizational_data_1.ORGANIZATIONAL_DATA_TOOL_NAME, organizational_data_1.ORGANIZATIONAL_DATA_TOOL_DESCRIPTION, organizational_data_1.ORGANIZATIONAL_DATA_TOOL_INPUT_SCHEMA, async (args) => {
|
|
112
136
|
const requestId = this.generateRequestId();
|
|
113
137
|
this.logger.info(`Processing ${organizational_data_1.ORGANIZATIONAL_DATA_TOOL_NAME} tool request`, { requestId });
|
|
114
138
|
return await (0, organizational_data_1.handleOrganizationalDataTool)(args, this.dotAI, this.logger, requestId);
|
|
115
|
-
});
|
|
139
|
+
}, 'Management', ['patterns', 'policies', 'capabilities', 'data']);
|
|
140
|
+
// Register remediate tool
|
|
141
|
+
this.registerTool(remediate_1.REMEDIATE_TOOL_NAME, remediate_1.REMEDIATE_TOOL_DESCRIPTION, remediate_1.REMEDIATE_TOOL_INPUT_SCHEMA, async (args) => {
|
|
142
|
+
const requestId = this.generateRequestId();
|
|
143
|
+
this.logger.info(`Processing ${remediate_1.REMEDIATE_TOOL_NAME} tool request`, { requestId });
|
|
144
|
+
return await (0, remediate_1.handleRemediateTool)(args);
|
|
145
|
+
}, 'Troubleshooting', ['remediation', 'troubleshooting', 'kubernetes', 'analysis']);
|
|
116
146
|
this.logger.info('Registered all tools with McpServer', {
|
|
117
147
|
tools: [
|
|
118
148
|
recommend_1.RECOMMEND_TOOL_NAME,
|
|
@@ -123,8 +153,9 @@ class MCPServer {
|
|
|
123
153
|
version_1.VERSION_TOOL_NAME,
|
|
124
154
|
test_docs_1.TESTDOCS_TOOL_NAME,
|
|
125
155
|
organizational_data_1.ORGANIZATIONAL_DATA_TOOL_NAME,
|
|
156
|
+
remediate_1.REMEDIATE_TOOL_NAME,
|
|
126
157
|
],
|
|
127
|
-
totalTools:
|
|
158
|
+
totalTools: 9,
|
|
128
159
|
});
|
|
129
160
|
}
|
|
130
161
|
/**
|
|
@@ -174,7 +205,7 @@ class MCPServer {
|
|
|
174
205
|
await this.server.connect(transport);
|
|
175
206
|
}
|
|
176
207
|
async startHttpTransport() {
|
|
177
|
-
const port = parseInt(process.env.PORT
|
|
208
|
+
const port = process.env.PORT ? parseInt(process.env.PORT) : (this.config.port !== undefined ? this.config.port : 3456);
|
|
178
209
|
const host = process.env.HOST || this.config.host || '0.0.0.0';
|
|
179
210
|
const sessionMode = process.env.SESSION_MODE || this.config.sessionMode || 'stateful';
|
|
180
211
|
this.logger.info('Using HTTP/SSE transport', { port, host, sessionMode });
|
|
@@ -209,15 +240,31 @@ class MCPServer {
|
|
|
209
240
|
if (req.method === 'POST') {
|
|
210
241
|
body = await this.parseRequestBody(req);
|
|
211
242
|
}
|
|
212
|
-
//
|
|
243
|
+
// Check if this is a REST API request
|
|
244
|
+
if (this.restApiRouter.isApiRequest(req.url || '')) {
|
|
245
|
+
this.logger.debug('Routing to REST API handler', { url: req.url });
|
|
246
|
+
try {
|
|
247
|
+
await this.restApiRouter.handleRequest(req, res, body);
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
catch (error) {
|
|
251
|
+
this.logger.error('REST API request failed', error);
|
|
252
|
+
if (!res.headersSent) {
|
|
253
|
+
res.writeHead(500, { 'Content-Type': 'application/json' });
|
|
254
|
+
res.end(JSON.stringify({ error: 'REST API internal server error' }));
|
|
255
|
+
}
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
// Handle MCP protocol requests using the transport
|
|
213
260
|
try {
|
|
214
261
|
await this.httpTransport.handleRequest(req, res, body);
|
|
215
262
|
}
|
|
216
263
|
catch (error) {
|
|
217
|
-
this.logger.error('Error handling HTTP request', error);
|
|
264
|
+
this.logger.error('Error handling MCP HTTP request', error);
|
|
218
265
|
if (!res.headersSent) {
|
|
219
266
|
res.writeHead(500, { 'Content-Type': 'application/json' });
|
|
220
|
-
res.end(JSON.stringify({ error: '
|
|
267
|
+
res.end(JSON.stringify({ error: 'MCP internal server error' }));
|
|
221
268
|
}
|
|
222
269
|
}
|
|
223
270
|
});
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenAPI 3.0 Specification Generator
|
|
3
|
+
*
|
|
4
|
+
* Automatically generates OpenAPI 3.0 documentation from the tool registry.
|
|
5
|
+
* Creates comprehensive API documentation with proper schemas and examples.
|
|
6
|
+
*/
|
|
7
|
+
import { RestToolRegistry } from './rest-registry';
|
|
8
|
+
import { Logger } from '../core/error-handling';
|
|
9
|
+
/**
|
|
10
|
+
* OpenAPI 3.0 specification structure
|
|
11
|
+
*/
|
|
12
|
+
export interface OpenApiSpec {
|
|
13
|
+
openapi: string;
|
|
14
|
+
info: {
|
|
15
|
+
title: string;
|
|
16
|
+
description: string;
|
|
17
|
+
version: string;
|
|
18
|
+
contact?: {
|
|
19
|
+
name: string;
|
|
20
|
+
url: string;
|
|
21
|
+
email: string;
|
|
22
|
+
};
|
|
23
|
+
license?: {
|
|
24
|
+
name: string;
|
|
25
|
+
url: string;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
servers: Array<{
|
|
29
|
+
url: string;
|
|
30
|
+
description: string;
|
|
31
|
+
}>;
|
|
32
|
+
paths: Record<string, any>;
|
|
33
|
+
components?: {
|
|
34
|
+
schemas?: Record<string, any>;
|
|
35
|
+
responses?: Record<string, any>;
|
|
36
|
+
securitySchemes?: Record<string, any>;
|
|
37
|
+
};
|
|
38
|
+
tags?: Array<{
|
|
39
|
+
name: string;
|
|
40
|
+
description: string;
|
|
41
|
+
}>;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* OpenAPI generator configuration
|
|
45
|
+
*/
|
|
46
|
+
export interface OpenApiConfig {
|
|
47
|
+
title: string;
|
|
48
|
+
description: string;
|
|
49
|
+
version: string;
|
|
50
|
+
basePath: string;
|
|
51
|
+
apiVersion: string;
|
|
52
|
+
serverUrl?: string;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* OpenAPI 3.0 specification generator
|
|
56
|
+
*/
|
|
57
|
+
export declare class OpenApiGenerator {
|
|
58
|
+
private registry;
|
|
59
|
+
private logger;
|
|
60
|
+
private config;
|
|
61
|
+
private specCache?;
|
|
62
|
+
private lastCacheUpdate;
|
|
63
|
+
private cacheValidityMs;
|
|
64
|
+
constructor(registry: RestToolRegistry, logger: Logger, config?: Partial<OpenApiConfig>);
|
|
65
|
+
/**
|
|
66
|
+
* Generate complete OpenAPI 3.0 specification
|
|
67
|
+
*/
|
|
68
|
+
generateSpec(): OpenApiSpec;
|
|
69
|
+
/**
|
|
70
|
+
* Generate API info section
|
|
71
|
+
*/
|
|
72
|
+
private generateInfo;
|
|
73
|
+
/**
|
|
74
|
+
* Generate server definitions
|
|
75
|
+
*/
|
|
76
|
+
private generateServers;
|
|
77
|
+
/**
|
|
78
|
+
* Generate paths for all endpoints
|
|
79
|
+
*/
|
|
80
|
+
private generatePaths;
|
|
81
|
+
/**
|
|
82
|
+
* Generate component schemas
|
|
83
|
+
*/
|
|
84
|
+
private generateComponents;
|
|
85
|
+
/**
|
|
86
|
+
* Generate tags for grouping endpoints
|
|
87
|
+
*/
|
|
88
|
+
private generateTags;
|
|
89
|
+
/**
|
|
90
|
+
* Generate example request body for a tool
|
|
91
|
+
*/
|
|
92
|
+
private generateExampleForTool;
|
|
93
|
+
/**
|
|
94
|
+
* Generate example value for a property schema
|
|
95
|
+
*/
|
|
96
|
+
private generateExampleValue;
|
|
97
|
+
/**
|
|
98
|
+
* Invalidate the specification cache
|
|
99
|
+
*/
|
|
100
|
+
invalidateCache(): void;
|
|
101
|
+
/**
|
|
102
|
+
* Update configuration
|
|
103
|
+
*/
|
|
104
|
+
updateConfig(newConfig: Partial<OpenApiConfig>): void;
|
|
105
|
+
/**
|
|
106
|
+
* Get current configuration
|
|
107
|
+
*/
|
|
108
|
+
getConfig(): OpenApiConfig;
|
|
109
|
+
}
|
|
110
|
+
//# sourceMappingURL=openapi-generator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openapi-generator.d.ts","sourceRoot":"","sources":["../../src/interfaces/openapi-generator.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,gBAAgB,EAAY,MAAM,iBAAiB,CAAC;AAC7D,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAEhD;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE;QACJ,KAAK,EAAE,MAAM,CAAC;QACd,WAAW,EAAE,MAAM,CAAC;QACpB,OAAO,EAAE,MAAM,CAAC;QAChB,OAAO,CAAC,EAAE;YACR,IAAI,EAAE,MAAM,CAAC;YACb,GAAG,EAAE,MAAM,CAAC;YACZ,KAAK,EAAE,MAAM,CAAC;SACf,CAAC;QACF,OAAO,CAAC,EAAE;YACR,IAAI,EAAE,MAAM,CAAC;YACb,GAAG,EAAE,MAAM,CAAC;SACb,CAAC;KACH,CAAC;IACF,OAAO,EAAE,KAAK,CAAC;QACb,GAAG,EAAE,MAAM,CAAC;QACZ,WAAW,EAAE,MAAM,CAAC;KACrB,CAAC,CAAC;IACH,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC3B,UAAU,CAAC,EAAE;QACX,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QAC9B,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QAChC,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;KACvC,CAAC;IACF,IAAI,CAAC,EAAE,KAAK,CAAC;QACX,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,EAAE,MAAM,CAAC;KACrB,CAAC,CAAC;CACJ;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,QAAQ,CAAmB;IACnC,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,MAAM,CAAgB;IAC9B,OAAO,CAAC,SAAS,CAAC,CAAc;IAChC,OAAO,CAAC,eAAe,CAAa;IACpC,OAAO,CAAC,eAAe,CAAiB;gBAE5B,QAAQ,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAE,OAAO,CAAC,aAAa,CAAM;IAc3F;;OAEG;IACH,YAAY,IAAI,WAAW;IAsC3B;;OAEG;IACH,OAAO,CAAC,YAAY;IAmBpB;;OAEG;IACH,OAAO,CAAC,eAAe;IASvB;;OAEG;IACH,OAAO,CAAC,aAAa;IA6HrB;;OAEG;IACH,OAAO,CAAC,kBAAkB;IA+H1B;;OAEG;IACH,OAAO,CAAC,YAAY;IA+BpB;;OAEG;IACH,OAAO,CAAC,sBAAsB;IAoB9B;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAuD5B;;OAEG;IACH,eAAe,IAAI,IAAI;IAMvB;;OAEG;IACH,YAAY,CAAC,SAAS,EAAE,OAAO,CAAC,aAAa,CAAC,GAAG,IAAI;IAMrD;;OAEG;IACH,SAAS,IAAI,aAAa;CAG3B"}
|