@vfarcic/dot-ai 0.4.4 → 0.4.5
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/mcp/server.d.ts +1 -4
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js +52 -121
- package/package.json +1 -1
package/dist/mcp/server.d.ts
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/**
|
|
3
|
-
* MCP Server
|
|
4
|
-
*
|
|
5
|
-
* This server exposes DevOps AI Toolkit functionality through the Model Context Protocol,
|
|
6
|
-
* enabling AI assistants like Claude Code to interact with Kubernetes deployment capabilities.
|
|
3
|
+
* Simple MCP Server for Testing
|
|
7
4
|
*/
|
|
8
5
|
export {};
|
|
9
6
|
//# sourceMappingURL=server.d.ts.map
|
package/dist/mcp/server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/mcp/server.ts"],"names":[],"mappings":";AAEA
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/mcp/server.ts"],"names":[],"mappings":";AAEA;;GAEG"}
|
package/dist/mcp/server.js
CHANGED
|
@@ -1,137 +1,68 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict";
|
|
3
3
|
/**
|
|
4
|
-
* MCP Server
|
|
5
|
-
*
|
|
6
|
-
* This server exposes DevOps AI Toolkit functionality through the Model Context Protocol,
|
|
7
|
-
* enabling AI assistants like Claude Code to interact with Kubernetes deployment capabilities.
|
|
4
|
+
* Simple MCP Server for Testing
|
|
8
5
|
*/
|
|
9
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
12
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
13
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
14
|
-
}
|
|
15
|
-
Object.defineProperty(o, k2, desc);
|
|
16
|
-
}) : (function(o, m, k, k2) {
|
|
17
|
-
if (k2 === undefined) k2 = k;
|
|
18
|
-
o[k2] = m[k];
|
|
19
|
-
}));
|
|
20
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
21
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
22
|
-
}) : function(o, v) {
|
|
23
|
-
o["default"] = v;
|
|
24
|
-
});
|
|
25
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
26
|
-
var ownKeys = function(o) {
|
|
27
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
28
|
-
var ar = [];
|
|
29
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
30
|
-
return ar;
|
|
31
|
-
};
|
|
32
|
-
return ownKeys(o);
|
|
33
|
-
};
|
|
34
|
-
return function (mod) {
|
|
35
|
-
if (mod && mod.__esModule) return mod;
|
|
36
|
-
var result = {};
|
|
37
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
38
|
-
__setModuleDefault(result, mod);
|
|
39
|
-
return result;
|
|
40
|
-
};
|
|
41
|
-
})();
|
|
42
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
|
-
const
|
|
44
|
-
const
|
|
7
|
+
const index_js_1 = require("@modelcontextprotocol/sdk/server/index.js");
|
|
8
|
+
const stdio_js_1 = require("@modelcontextprotocol/sdk/server/stdio.js");
|
|
9
|
+
const types_js_1 = require("@modelcontextprotocol/sdk/types.js");
|
|
45
10
|
async function main() {
|
|
46
11
|
try {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
if (!sessionDir) {
|
|
52
|
-
process.stderr.write('FATAL: DOT_AI_SESSION_DIR environment variable is required\n');
|
|
53
|
-
process.stderr.write('Configuration:\n');
|
|
54
|
-
process.stderr.write('- Set DOT_AI_SESSION_DIR in .mcp.json env section\n');
|
|
55
|
-
process.stderr.write('- Example: "DOT_AI_SESSION_DIR": "/tmp/dot-ai-sessions"\n');
|
|
56
|
-
process.stderr.write('- Ensure the directory exists and is writable\n');
|
|
57
|
-
process.exit(1);
|
|
58
|
-
}
|
|
59
|
-
// Validate session directory exists and is writable
|
|
60
|
-
try {
|
|
61
|
-
const fs = await Promise.resolve().then(() => __importStar(require('fs')));
|
|
62
|
-
const path = await Promise.resolve().then(() => __importStar(require('path')));
|
|
63
|
-
// Check if directory exists
|
|
64
|
-
if (!fs.existsSync(sessionDir)) {
|
|
65
|
-
process.stderr.write(`FATAL: Session directory does not exist: ${sessionDir}\n`);
|
|
66
|
-
process.stderr.write('Solution: Create the directory or update DOT_AI_SESSION_DIR\n');
|
|
67
|
-
process.exit(1);
|
|
68
|
-
}
|
|
69
|
-
// Check if it's actually a directory
|
|
70
|
-
const stat = fs.statSync(sessionDir);
|
|
71
|
-
if (!stat.isDirectory()) {
|
|
72
|
-
process.stderr.write(`FATAL: Session directory path is not a directory: ${sessionDir}\n`);
|
|
73
|
-
process.stderr.write('Solution: Use a valid directory path in DOT_AI_SESSION_DIR\n');
|
|
74
|
-
process.exit(1);
|
|
75
|
-
}
|
|
76
|
-
// Test write permissions
|
|
77
|
-
const testFile = path.join(sessionDir, '.mcp-test-write');
|
|
78
|
-
try {
|
|
79
|
-
fs.writeFileSync(testFile, 'test');
|
|
80
|
-
fs.unlinkSync(testFile);
|
|
81
|
-
process.stderr.write(`Session directory validated: ${sessionDir}\n`);
|
|
82
|
-
}
|
|
83
|
-
catch (writeError) {
|
|
84
|
-
process.stderr.write(`FATAL: Session directory is not writable: ${sessionDir}\n`);
|
|
85
|
-
process.stderr.write('Solution: Fix directory permissions or use a different directory\n');
|
|
86
|
-
process.exit(1);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
catch (error) {
|
|
90
|
-
process.stderr.write(`FATAL: Session directory validation failed: ${error}\n`);
|
|
91
|
-
process.exit(1);
|
|
92
|
-
}
|
|
93
|
-
// Initialize DotAI - it will read KUBECONFIG and ANTHROPIC_API_KEY from environment
|
|
94
|
-
const dotAI = new index_js_1.DotAI();
|
|
95
|
-
// Test cluster connectivity immediately on startup
|
|
96
|
-
process.stderr.write('Testing cluster connectivity...\n');
|
|
97
|
-
try {
|
|
98
|
-
await dotAI.initialize();
|
|
99
|
-
await dotAI.discovery.connect();
|
|
100
|
-
process.stderr.write('Cluster connectivity verified successfully\n');
|
|
101
|
-
}
|
|
102
|
-
catch (connectError) {
|
|
103
|
-
process.stderr.write(`FATAL: Failed to connect to Kubernetes cluster: ${connectError}\n`);
|
|
104
|
-
process.stderr.write('Troubleshooting:\n');
|
|
105
|
-
process.stderr.write('- Check KUBECONFIG environment variable\n');
|
|
106
|
-
process.stderr.write('- Verify cluster is running: kubectl cluster-info\n');
|
|
107
|
-
process.stderr.write('- Test kubectl connectivity: kubectl get nodes\n');
|
|
108
|
-
process.exit(1);
|
|
109
|
-
}
|
|
110
|
-
// Create and configure MCP server
|
|
111
|
-
const mcpServer = new mcp_js_1.MCPServer(dotAI, {
|
|
112
|
-
name: 'dot-ai',
|
|
12
|
+
process.stderr.write('Starting simple MCP server...\n');
|
|
13
|
+
// Create a simple MCP server
|
|
14
|
+
const server = new index_js_1.Server({
|
|
15
|
+
name: 'dot-ai-simple',
|
|
113
16
|
version: '0.1.0',
|
|
114
|
-
|
|
115
|
-
|
|
17
|
+
}, {
|
|
18
|
+
capabilities: {
|
|
19
|
+
tools: {},
|
|
20
|
+
},
|
|
116
21
|
});
|
|
117
|
-
//
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
22
|
+
// Add a simple hello world tool
|
|
23
|
+
server.setRequestHandler(types_js_1.ListToolsRequestSchema, async () => {
|
|
24
|
+
return {
|
|
25
|
+
tools: [
|
|
26
|
+
{
|
|
27
|
+
name: 'hello',
|
|
28
|
+
description: 'Say hello world',
|
|
29
|
+
inputSchema: {
|
|
30
|
+
type: 'object',
|
|
31
|
+
properties: {
|
|
32
|
+
name: {
|
|
33
|
+
type: 'string',
|
|
34
|
+
description: 'Name to greet',
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
};
|
|
126
41
|
});
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
42
|
+
server.setRequestHandler(types_js_1.CallToolRequestSchema, async (request) => {
|
|
43
|
+
const { name, arguments: args } = request.params;
|
|
44
|
+
if (name === 'hello') {
|
|
45
|
+
const userName = args?.name || 'World';
|
|
46
|
+
return {
|
|
47
|
+
content: [
|
|
48
|
+
{
|
|
49
|
+
type: 'text',
|
|
50
|
+
text: `Hello, ${userName}! MCP server is working from any directory.`,
|
|
51
|
+
},
|
|
52
|
+
],
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
throw new Error(`Unknown tool: ${name}`);
|
|
57
|
+
}
|
|
131
58
|
});
|
|
59
|
+
// Connect to stdio transport
|
|
60
|
+
const transport = new stdio_js_1.StdioServerTransport();
|
|
61
|
+
await server.connect(transport);
|
|
62
|
+
process.stderr.write('Simple MCP server started successfully\n');
|
|
132
63
|
}
|
|
133
64
|
catch (error) {
|
|
134
|
-
process.stderr.write(`Failed to start
|
|
65
|
+
process.stderr.write(`Failed to start simple MCP server: ${error}\n`);
|
|
135
66
|
process.exit(1);
|
|
136
67
|
}
|
|
137
68
|
}
|