vme-mcp-server 0.1.10 → 0.1.13
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 +38 -8
- package/dist/README.md +69 -13
- package/dist/lib/api-utils.js +41 -32
- package/dist/lib/capability-cache.js +4 -8
- package/dist/lib/capability-discovery.js +12 -16
- package/dist/lib/intent-recognition.js +3 -7
- package/dist/lib/name-resolver.js +4 -8
- package/dist/lib/session.js +9 -14
- package/dist/lib/vm-parsing.js +2 -7
- package/dist/server.js +83 -33
- package/dist/server_old.js +18 -23
- package/dist/tools/check-capability.js +4 -8
- package/dist/tools/create-vm.js +24 -28
- package/dist/tools/discover-capabilities.js +4 -8
- package/dist/tools/export-training-data.js +8 -12
- package/dist/tools/get-cache-status.js +5 -9
- package/dist/tools/get-resources.js +4 -8
- package/dist/tools/index.js +35 -56
- package/dist/tools/parse-intent.js +7 -11
- package/dist/tools/provide-feedback.js +5 -9
- package/dist/tools/query-resources.js +4 -8
- package/dist/types/interfaces.js +1 -2
- package/package.json +3 -3
package/dist/server.js
CHANGED
@@ -1,65 +1,115 @@
|
|
1
1
|
#!/usr/bin/env node
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
};
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
const
|
14
|
-
const
|
15
|
-
|
2
|
+
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
3
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
4
|
+
import { CallToolRequestSchema, ListToolsRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
|
5
|
+
import dotenv from "dotenv";
|
6
|
+
import { existsSync } from "fs";
|
7
|
+
import { join } from "path";
|
8
|
+
import { homedir } from "os";
|
9
|
+
import { readFileSync } from "fs";
|
10
|
+
import { allTools, toolHandlers } from "./tools/index.js";
|
11
|
+
// Parse command line arguments
|
12
|
+
function parseArgs() {
|
13
|
+
const args = process.argv.slice(2);
|
14
|
+
const result = {};
|
15
|
+
for (let i = 0; i < args.length; i++) {
|
16
|
+
const arg = args[i];
|
17
|
+
if ((arg === '--endpoint' || arg === '-e') && i + 1 < args.length) {
|
18
|
+
result.endpoint = args[i + 1];
|
19
|
+
i++; // Skip next arg since we consumed it
|
20
|
+
}
|
21
|
+
else if ((arg === '--token' || arg === '-t') && i + 1 < args.length) {
|
22
|
+
result.token = args[i + 1];
|
23
|
+
i++; // Skip next arg since we consumed it
|
24
|
+
}
|
25
|
+
else if (arg === '--help' || arg === '-h') {
|
26
|
+
console.log(`VME MCP Server - Natural Language Infrastructure Management
|
27
|
+
|
28
|
+
Usage: vme-mcp-server [options]
|
29
|
+
|
30
|
+
Options:
|
31
|
+
-e, --endpoint <url> VME API endpoint URL
|
32
|
+
-t, --token <token> VME API bearer token
|
33
|
+
-h, --help Show this help message
|
34
|
+
|
35
|
+
Environment Variables:
|
36
|
+
VME_ENDPOINT VME API endpoint URL
|
37
|
+
VME_TOKEN VME API bearer token
|
38
|
+
|
39
|
+
Note: Command line arguments take precedence over environment variables.
|
40
|
+
If no configuration is provided, the server will look for .env files.`);
|
41
|
+
process.exit(0);
|
42
|
+
}
|
43
|
+
}
|
44
|
+
return result;
|
45
|
+
}
|
46
|
+
// Get version from package.json
|
47
|
+
function getPackageVersion() {
|
48
|
+
const packagePath = new URL('../package.json', import.meta.url);
|
49
|
+
const packageJson = JSON.parse(readFileSync(packagePath, 'utf8'));
|
50
|
+
return packageJson.version;
|
51
|
+
}
|
16
52
|
// Load environment variables from multiple locations for global install support
|
17
|
-
function loadEnvironmentConfig() {
|
53
|
+
function loadEnvironmentConfig(cliArgs) {
|
18
54
|
// Priority order for .env file locations:
|
19
55
|
const envPaths = [
|
20
56
|
// 1. Current working directory (for local development)
|
21
|
-
|
57
|
+
join(process.cwd(), '.env'),
|
22
58
|
// 2. Home directory (for global installs)
|
23
|
-
|
59
|
+
join(homedir(), '.env'),
|
24
60
|
// 3. XDG config directory (Linux/Mac standard)
|
25
|
-
|
61
|
+
join(homedir(), '.config', 'vme-mcp-server', '.env'),
|
26
62
|
// 4. User's Documents folder (Windows-friendly)
|
27
|
-
|
63
|
+
join(homedir(), 'Documents', '.env.vme-mcp-server')
|
28
64
|
];
|
29
65
|
// Try to load .env from the first available location
|
30
66
|
for (const envPath of envPaths) {
|
31
|
-
if (
|
32
|
-
|
67
|
+
if (existsSync(envPath)) {
|
68
|
+
dotenv.config({ path: envPath });
|
33
69
|
console.error(`VME MCP: Loaded config from ${envPath}`);
|
34
|
-
|
70
|
+
break;
|
35
71
|
}
|
36
72
|
}
|
37
|
-
//
|
38
|
-
|
73
|
+
// Command line arguments take highest priority - override any env vars
|
74
|
+
if (cliArgs.endpoint) {
|
75
|
+
process.env.VME_ENDPOINT = cliArgs.endpoint;
|
76
|
+
console.error('VME MCP: Using endpoint from command line argument');
|
77
|
+
}
|
78
|
+
if (cliArgs.token) {
|
79
|
+
process.env.VME_TOKEN = cliArgs.token;
|
80
|
+
console.error('VME MCP: Using token from command line argument');
|
81
|
+
}
|
82
|
+
// If no configuration found at all, warn the user
|
83
|
+
if (!process.env.VME_ENDPOINT || !process.env.VME_TOKEN) {
|
84
|
+
console.error('VME MCP: Warning - Missing VME_ENDPOINT or VME_TOKEN configuration');
|
85
|
+
console.error('VME MCP: Use --endpoint and --token arguments or set environment variables');
|
86
|
+
}
|
39
87
|
}
|
40
|
-
|
88
|
+
// Parse CLI arguments and load configuration
|
89
|
+
const cliArgs = parseArgs();
|
90
|
+
loadEnvironmentConfig(cliArgs);
|
41
91
|
// Disable TLS verification for VME API (if needed)
|
42
92
|
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
|
43
93
|
// Create VME MCP server with modular architecture
|
44
|
-
const server = new
|
94
|
+
const server = new Server({
|
45
95
|
name: "vme-mcp-server",
|
46
|
-
version:
|
96
|
+
version: getPackageVersion(),
|
47
97
|
}, {
|
48
98
|
capabilities: {
|
49
99
|
tools: {},
|
50
100
|
},
|
51
101
|
});
|
52
102
|
// Register all tools using the modular tool definitions
|
53
|
-
server.setRequestHandler(
|
103
|
+
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
54
104
|
return {
|
55
|
-
tools:
|
105
|
+
tools: allTools,
|
56
106
|
};
|
57
107
|
});
|
58
108
|
// Handle tool calls using the modular tool handlers
|
59
|
-
server.setRequestHandler(
|
109
|
+
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
60
110
|
const { name, arguments: args } = request.params;
|
61
111
|
// Look up the handler for this tool
|
62
|
-
const handler =
|
112
|
+
const handler = toolHandlers[name];
|
63
113
|
if (!handler) {
|
64
114
|
throw new Error(`Unknown tool: ${name}`);
|
65
115
|
}
|
@@ -68,9 +118,9 @@ server.setRequestHandler(types_js_1.CallToolRequestSchema, async (request) => {
|
|
68
118
|
});
|
69
119
|
// Start the server
|
70
120
|
async function main() {
|
71
|
-
const transport = new
|
121
|
+
const transport = new StdioServerTransport();
|
72
122
|
await server.connect(transport);
|
73
|
-
console.error(
|
123
|
+
console.error(`VME MCP Server v${getPackageVersion()} running on stdio with modular architecture`);
|
74
124
|
}
|
75
125
|
main().catch((error) => {
|
76
126
|
console.error("Failed to start server:", error);
|
package/dist/server_old.js
CHANGED
@@ -1,15 +1,10 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
const axios_1 = __importDefault(require("axios"));
|
9
|
-
const dotenv_1 = __importDefault(require("dotenv"));
|
10
|
-
const fs_1 = require("fs");
|
11
|
-
const path_1 = require("path");
|
12
|
-
dotenv_1.default.config();
|
1
|
+
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
2
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
3
|
+
import axios from "axios";
|
4
|
+
import dotenv from "dotenv";
|
5
|
+
import { writeFileSync, readFileSync, existsSync, mkdirSync } from "fs";
|
6
|
+
import { join } from "path";
|
7
|
+
dotenv.config();
|
13
8
|
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
|
14
9
|
// AI Training Data Collection Configuration
|
15
10
|
const AI_TRAINING_ENABLED = process.env.ENABLE_AI_TRAINING_DATA === 'true';
|
@@ -22,9 +17,9 @@ function logInteraction(interaction) {
|
|
22
17
|
}
|
23
18
|
try {
|
24
19
|
// Ensure logs directory exists
|
25
|
-
const logsDir =
|
26
|
-
if (!
|
27
|
-
|
20
|
+
const logsDir = join(process.cwd(), 'ai-training-logs');
|
21
|
+
if (!existsSync(logsDir)) {
|
22
|
+
mkdirSync(logsDir, { recursive: true });
|
28
23
|
}
|
29
24
|
// Filter fields based on user preferences
|
30
25
|
const filteredInteraction = {
|
@@ -50,9 +45,9 @@ function logInteraction(interaction) {
|
|
50
45
|
filteredInteraction.timing = interaction.timing;
|
51
46
|
}
|
52
47
|
// Append to daily log file (JSONL format)
|
53
|
-
const logFile =
|
48
|
+
const logFile = join(logsDir, `interactions-${new Date().toISOString().split('T')[0]}.jsonl`);
|
54
49
|
const logEntry = JSON.stringify(filteredInteraction) + '\n';
|
55
|
-
|
50
|
+
writeFileSync(logFile, logEntry, { flag: 'a' });
|
56
51
|
}
|
57
52
|
catch (error) {
|
58
53
|
// Fail silently to not disrupt user experience
|
@@ -63,7 +58,7 @@ function logInteraction(interaction) {
|
|
63
58
|
function generateSessionId() {
|
64
59
|
return `session-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
65
60
|
}
|
66
|
-
const api =
|
61
|
+
const api = axios.create({
|
67
62
|
baseURL: process.env.VME_API_BASE_URL,
|
68
63
|
headers: {
|
69
64
|
Authorization: `Bearer ${process.env.VME_API_TOKEN}`,
|
@@ -500,7 +495,7 @@ async function getResources(type, intent, role) {
|
|
500
495
|
};
|
501
496
|
}
|
502
497
|
}
|
503
|
-
const server = new
|
498
|
+
const server = new Server({
|
504
499
|
name: "vm-create-server",
|
505
500
|
version: "1.0.0"
|
506
501
|
}, {
|
@@ -679,8 +674,8 @@ const server = new index_js_1.Server({
|
|
679
674
|
}
|
680
675
|
const { format = "jsonl", days = 7 } = req.arguments;
|
681
676
|
try {
|
682
|
-
const logsDir =
|
683
|
-
if (!
|
677
|
+
const logsDir = join(process.cwd(), 'ai-training-logs');
|
678
|
+
if (!existsSync(logsDir)) {
|
684
679
|
return {
|
685
680
|
toolResult: JSON.stringify({
|
686
681
|
message: "No training data found",
|
@@ -698,7 +693,7 @@ const server = new index_js_1.Server({
|
|
698
693
|
for (const file of logFiles) {
|
699
694
|
const fileDate = new Date(file.replace('interactions-', '').replace('.jsonl', ''));
|
700
695
|
if (fileDate >= cutoffDate) {
|
701
|
-
const content =
|
696
|
+
const content = readFileSync(join(logsDir, file), 'utf-8');
|
702
697
|
const lines = content.trim().split('\n').filter(line => line.trim());
|
703
698
|
for (const line of lines) {
|
704
699
|
try {
|
@@ -929,5 +924,5 @@ const server = new index_js_1.Server({
|
|
929
924
|
}
|
930
925
|
}
|
931
926
|
});
|
932
|
-
const transport = new
|
927
|
+
const transport = new StdioServerTransport();
|
933
928
|
server.connect(transport);
|
@@ -1,8 +1,5 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
exports.handleCheckCapability = exports.checkCapabilityTool = void 0;
|
4
|
-
const capability_discovery_js_1 = require("../lib/capability-discovery.js");
|
5
|
-
exports.checkCapabilityTool = {
|
1
|
+
import { capabilityDiscovery } from "../lib/capability-discovery.js";
|
2
|
+
export const checkCapabilityTool = {
|
6
3
|
name: "check_capability",
|
7
4
|
description: "Check if a specific capability is available using natural language queries",
|
8
5
|
inputSchema: {
|
@@ -21,7 +18,7 @@ exports.checkCapabilityTool = {
|
|
21
18
|
required: ["question"]
|
22
19
|
}
|
23
20
|
};
|
24
|
-
async function handleCheckCapability(args) {
|
21
|
+
export async function handleCheckCapability(args) {
|
25
22
|
try {
|
26
23
|
const { question, capability_type } = args;
|
27
24
|
if (!question || typeof question !== 'string') {
|
@@ -39,7 +36,7 @@ async function handleCheckCapability(args) {
|
|
39
36
|
};
|
40
37
|
}
|
41
38
|
// Use the capability discovery engine to check the capability
|
42
|
-
const result = await
|
39
|
+
const result = await capabilityDiscovery.checkCapability(question, capability_type);
|
43
40
|
// Prepare comprehensive response
|
44
41
|
const response = {
|
45
42
|
question: question,
|
@@ -81,4 +78,3 @@ async function handleCheckCapability(args) {
|
|
81
78
|
};
|
82
79
|
}
|
83
80
|
}
|
84
|
-
exports.handleCheckCapability = handleCheckCapability;
|
package/dist/tools/create-vm.js
CHANGED
@@ -1,10 +1,7 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
const
|
5
|
-
const api_utils_js_1 = require("../lib/api-utils.js");
|
6
|
-
const name_resolver_js_1 = require("../lib/name-resolver.js");
|
7
|
-
exports.createVMTool = {
|
1
|
+
import { parseVMNames, calculateNodeAssignments } from "../lib/vm-parsing.js";
|
2
|
+
import { api, getClusterNodes } from "../lib/api-utils.js";
|
3
|
+
import { nameResolver } from "../lib/name-resolver.js";
|
4
|
+
export const createVMTool = {
|
8
5
|
name: "create_vm",
|
9
6
|
description: "Provision a new virtual machine. ⚡ TIP: Run discover_capabilities first to see available groups, zones, templates, and sizes in your environment.",
|
10
7
|
inputSchema: {
|
@@ -46,7 +43,7 @@ exports.createVMTool = {
|
|
46
43
|
required: ["name", "group", "template", "size"]
|
47
44
|
}
|
48
45
|
};
|
49
|
-
async function handleCreateVM(args) {
|
46
|
+
export async function handleCreateVM(args) {
|
50
47
|
const { name, group, cloud, zone, template, size, distribution, count } = args;
|
51
48
|
// Allow both 'cloud' and 'zone' parameters interchangeably
|
52
49
|
const location = cloud || zone;
|
@@ -67,16 +64,16 @@ async function handleCreateVM(args) {
|
|
67
64
|
};
|
68
65
|
}
|
69
66
|
// Parse VM names and determine distribution strategy
|
70
|
-
const vmNames =
|
71
|
-
const nodes = await
|
67
|
+
const vmNames = parseVMNames(name, count);
|
68
|
+
const nodes = await getClusterNodes();
|
72
69
|
// Calculate node assignments
|
73
|
-
const nodeAssignments =
|
70
|
+
const nodeAssignments = calculateNodeAssignments(vmNames, nodes, distribution);
|
74
71
|
// Resolve any node names to IDs
|
75
72
|
for (const assignment of nodeAssignments) {
|
76
73
|
if (assignment.nodeNameToResolve) {
|
77
74
|
// Query servers to find node with matching name
|
78
75
|
try {
|
79
|
-
const servers = await
|
76
|
+
const servers = await api.get("/servers");
|
80
77
|
if (servers.data.servers) {
|
81
78
|
const foundServer = servers.data.servers.find((server) => server.name?.toLowerCase() === assignment.nodeNameToResolve?.toLowerCase());
|
82
79
|
if (foundServer) {
|
@@ -96,28 +93,28 @@ async function handleCreateVM(args) {
|
|
96
93
|
}
|
97
94
|
}
|
98
95
|
// Use name resolver to get IDs from actual VME environment
|
99
|
-
const groupId = await
|
100
|
-
const cloudId = await
|
101
|
-
const imageId = await
|
102
|
-
const servicePlanId = await
|
103
|
-
const instanceTypeId = await
|
96
|
+
const groupId = await nameResolver.resolveNameToId('group', group);
|
97
|
+
const cloudId = await nameResolver.resolveNameToId('zone', location);
|
98
|
+
const imageId = await nameResolver.resolveNameToId('virtualImage', template);
|
99
|
+
const servicePlanId = await nameResolver.resolveNameToId('servicePlan', size);
|
100
|
+
const instanceTypeId = await nameResolver.resolveNameToId('instanceType', 'HPE VM'); // Default for VME
|
104
101
|
// Validate all required IDs were resolved
|
105
102
|
if (!groupId || !cloudId || !servicePlanId || !imageId) {
|
106
103
|
const errors = [];
|
107
104
|
if (!groupId) {
|
108
|
-
const availableGroups = await
|
105
|
+
const availableGroups = await nameResolver.getAvailableNames('group');
|
109
106
|
errors.push(`Group '${group}' not found. Available: ${availableGroups.join(', ')}`);
|
110
107
|
}
|
111
108
|
if (!cloudId) {
|
112
|
-
const availableZones = await
|
109
|
+
const availableZones = await nameResolver.getAvailableNames('zone');
|
113
110
|
errors.push(`Zone/Cloud '${location}' not found. Available: ${availableZones.join(', ')}`);
|
114
111
|
}
|
115
112
|
if (!servicePlanId) {
|
116
|
-
const availablePlans = await
|
113
|
+
const availablePlans = await nameResolver.getAvailableNames('servicePlan');
|
117
114
|
errors.push(`Size '${size}' could not be resolved to service plan. Available: ${availablePlans.join(', ')}`);
|
118
115
|
}
|
119
116
|
if (!imageId) {
|
120
|
-
const availableImages = await
|
117
|
+
const availableImages = await nameResolver.getAvailableNames('virtualImage');
|
121
118
|
errors.push(`Template '${template}' could not be resolved to OS image. Available: ${availableImages.join(', ')}`);
|
122
119
|
}
|
123
120
|
return {
|
@@ -143,10 +140,10 @@ async function handleCreateVM(args) {
|
|
143
140
|
try {
|
144
141
|
// Try to get real resource pool, datastore, network IDs from VME
|
145
142
|
const [resourcePools, datastores, networks, layouts] = await Promise.allSettled([
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
143
|
+
api.get('/resource-pools').catch(() => null),
|
144
|
+
api.get('/datastores').catch(() => null),
|
145
|
+
api.get('/networks').catch(() => null),
|
146
|
+
api.get('/layouts').catch(() => null)
|
150
147
|
]);
|
151
148
|
// Use first available resource pool
|
152
149
|
if (resourcePools.status === 'fulfilled' && resourcePools.value?.data?.resourcePools?.[0]) {
|
@@ -189,7 +186,7 @@ async function handleCreateVM(args) {
|
|
189
186
|
zoneId: cloudId,
|
190
187
|
instance: {
|
191
188
|
name: assignment.name,
|
192
|
-
cloud: await
|
189
|
+
cloud: await nameResolver.getAvailableNames('zone').then(zones => zones[0]) || 'tc-lab',
|
193
190
|
hostName: assignment.name,
|
194
191
|
type: 'mvm',
|
195
192
|
instanceType: {
|
@@ -230,7 +227,7 @@ async function handleCreateVM(args) {
|
|
230
227
|
layoutSize: 1
|
231
228
|
};
|
232
229
|
try {
|
233
|
-
const response = await
|
230
|
+
const response = await api.post("/instances", payload);
|
234
231
|
const vm = response.data?.instance;
|
235
232
|
const nodeInfo = assignment.kvmHostId ? ` on node ${assignment.kvmHostId}` : ' (auto-placed)';
|
236
233
|
results.push(`VM '${vm.name}' created (ID: ${vm.id})${nodeInfo}`);
|
@@ -274,4 +271,3 @@ async function handleCreateVM(args) {
|
|
274
271
|
isError: errors.length > 0 && results.length === 0
|
275
272
|
};
|
276
273
|
}
|
277
|
-
exports.handleCreateVM = handleCreateVM;
|
@@ -1,8 +1,5 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
exports.handleDiscoverCapabilities = exports.discoverCapabilitiesTool = void 0;
|
4
|
-
const capability_discovery_js_1 = require("../lib/capability-discovery.js");
|
5
|
-
exports.discoverCapabilitiesTool = {
|
1
|
+
import { capabilityDiscovery } from "../lib/capability-discovery.js";
|
2
|
+
export const discoverCapabilitiesTool = {
|
6
3
|
name: "discover_capabilities",
|
7
4
|
description: "⚡ RECOMMENDED FIRST STEP: Discover VME infrastructure capabilities to learn available resources. Run this tool at least once per session to cache environment data for optimal performance with other tools.",
|
8
5
|
inputSchema: {
|
@@ -28,12 +25,12 @@ exports.discoverCapabilitiesTool = {
|
|
28
25
|
required: []
|
29
26
|
}
|
30
27
|
};
|
31
|
-
async function handleDiscoverCapabilities(args) {
|
28
|
+
export async function handleDiscoverCapabilities(args) {
|
32
29
|
try {
|
33
30
|
const { domain = "all", refresh = false, include_limits = true } = args;
|
34
31
|
// Convert single domain to array for discovery engine
|
35
32
|
const domains = domain === "all" ? ["all"] : [domain];
|
36
|
-
const capabilities = await
|
33
|
+
const capabilities = await capabilityDiscovery.discoverCapabilities(domains, refresh);
|
37
34
|
// Filter out license limits if not requested
|
38
35
|
if (!include_limits && capabilities.platform) {
|
39
36
|
delete capabilities.platform.license_limits;
|
@@ -76,4 +73,3 @@ async function handleDiscoverCapabilities(args) {
|
|
76
73
|
};
|
77
74
|
}
|
78
75
|
}
|
79
|
-
exports.handleDiscoverCapabilities = handleDiscoverCapabilities;
|
@@ -1,9 +1,6 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
const fs_1 = require("fs");
|
5
|
-
const path_1 = require("path");
|
6
|
-
exports.exportTrainingDataTool = {
|
1
|
+
import { readFileSync, existsSync, readdirSync } from "fs";
|
2
|
+
import { join } from "path";
|
3
|
+
export const exportTrainingDataTool = {
|
7
4
|
name: "export_training_data",
|
8
5
|
description: "Export AI training data for model improvement (requires ENABLE_AI_TRAINING_DATA=true)",
|
9
6
|
inputSchema: {
|
@@ -22,7 +19,7 @@ exports.exportTrainingDataTool = {
|
|
22
19
|
required: []
|
23
20
|
}
|
24
21
|
};
|
25
|
-
async function handleExportTrainingData(args) {
|
22
|
+
export async function handleExportTrainingData(args) {
|
26
23
|
const AI_TRAINING_ENABLED = process.env.ENABLE_AI_TRAINING_DATA === 'true';
|
27
24
|
if (!AI_TRAINING_ENABLED) {
|
28
25
|
return {
|
@@ -40,8 +37,8 @@ async function handleExportTrainingData(args) {
|
|
40
37
|
}
|
41
38
|
const { format = "jsonl", days = 7 } = args;
|
42
39
|
try {
|
43
|
-
const logsDir =
|
44
|
-
if (!
|
40
|
+
const logsDir = join(process.cwd(), 'ai-training-logs');
|
41
|
+
if (!existsSync(logsDir)) {
|
45
42
|
return {
|
46
43
|
content: [
|
47
44
|
{
|
@@ -59,11 +56,11 @@ async function handleExportTrainingData(args) {
|
|
59
56
|
const cutoffDate = new Date(Date.now() - (days * 24 * 60 * 60 * 1000));
|
60
57
|
const allData = [];
|
61
58
|
// Read log files and aggregate data
|
62
|
-
const logFiles =
|
59
|
+
const logFiles = readdirSync(logsDir).filter((file) => file.startsWith('interactions-') && file.endsWith('.jsonl'));
|
63
60
|
for (const file of logFiles) {
|
64
61
|
const fileDate = new Date(file.replace('interactions-', '').replace('.jsonl', ''));
|
65
62
|
if (fileDate >= cutoffDate) {
|
66
|
-
const content =
|
63
|
+
const content = readFileSync(join(logsDir, file), 'utf-8');
|
67
64
|
const lines = content.trim().split('\n').filter(line => line.trim());
|
68
65
|
for (const line of lines) {
|
69
66
|
try {
|
@@ -112,4 +109,3 @@ async function handleExportTrainingData(args) {
|
|
112
109
|
};
|
113
110
|
}
|
114
111
|
}
|
115
|
-
exports.handleExportTrainingData = handleExportTrainingData;
|
@@ -1,8 +1,5 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
exports.handleGetCacheStatus = exports.getCacheStatusTool = void 0;
|
4
|
-
const capability_cache_js_1 = require("../lib/capability-cache.js");
|
5
|
-
exports.getCacheStatusTool = {
|
1
|
+
import { capabilityCache } from "../lib/capability-cache.js";
|
2
|
+
export const getCacheStatusTool = {
|
6
3
|
name: "get_cache_status",
|
7
4
|
description: "Show freshness and status of cached capability data for transparency and debugging",
|
8
5
|
inputSchema: {
|
@@ -22,11 +19,11 @@ exports.getCacheStatusTool = {
|
|
22
19
|
required: []
|
23
20
|
}
|
24
21
|
};
|
25
|
-
async function handleGetCacheStatus(args) {
|
22
|
+
export async function handleGetCacheStatus(args) {
|
26
23
|
try {
|
27
24
|
const { field, include_statistics = false } = args;
|
28
25
|
// Get cache status for specific field or all fields
|
29
|
-
const cacheStatuses =
|
26
|
+
const cacheStatuses = capabilityCache.getCacheStatus(field);
|
30
27
|
// Calculate summary statistics
|
31
28
|
const totalFields = cacheStatuses.length;
|
32
29
|
const freshFields = cacheStatuses.filter(s => s.is_fresh).length;
|
@@ -54,7 +51,7 @@ async function handleGetCacheStatus(args) {
|
|
54
51
|
};
|
55
52
|
// Include statistics if requested
|
56
53
|
if (include_statistics) {
|
57
|
-
const stats =
|
54
|
+
const stats = capabilityCache.getStatistics();
|
58
55
|
response.statistics = {
|
59
56
|
cache_hits: stats.hits,
|
60
57
|
cache_misses: stats.misses,
|
@@ -87,7 +84,6 @@ async function handleGetCacheStatus(args) {
|
|
87
84
|
};
|
88
85
|
}
|
89
86
|
}
|
90
|
-
exports.handleGetCacheStatus = handleGetCacheStatus;
|
91
87
|
// Helper function to format duration in human-readable format
|
92
88
|
function formatDuration(seconds) {
|
93
89
|
if (seconds < 60) {
|
@@ -1,8 +1,5 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
exports.handleGetResources = exports.getResourcesTool = void 0;
|
4
|
-
const api_utils_js_1 = require("../lib/api-utils.js");
|
5
|
-
exports.getResourcesTool = {
|
1
|
+
import { getResources } from "../lib/api-utils.js";
|
2
|
+
export const getResourcesTool = {
|
6
3
|
name: "get_resources",
|
7
4
|
description: "Discover and explore available VME infrastructure resources with intelligent filtering. ⚡ TIP: Use discover_capabilities for comprehensive environment discovery first.",
|
8
5
|
inputSchema: {
|
@@ -24,9 +21,9 @@ exports.getResourcesTool = {
|
|
24
21
|
required: []
|
25
22
|
}
|
26
23
|
};
|
27
|
-
async function handleGetResources(args) {
|
24
|
+
export async function handleGetResources(args) {
|
28
25
|
const { type, intent, role } = args;
|
29
|
-
const resources = await
|
26
|
+
const resources = await getResources(type, intent, role);
|
30
27
|
return {
|
31
28
|
content: [
|
32
29
|
{
|
@@ -37,4 +34,3 @@ async function handleGetResources(args) {
|
|
37
34
|
isError: !!resources.error
|
38
35
|
};
|
39
36
|
}
|
40
|
-
exports.handleGetResources = handleGetResources;
|