@robinmordasiewicz/f5xc-api-mcp 3.0.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/CHANGELOG.md +74 -0
- package/README.md +234 -0
- package/dist/auth/credential-manager.d.ts +116 -0
- package/dist/auth/credential-manager.d.ts.map +1 -0
- package/dist/auth/credential-manager.js +208 -0
- package/dist/auth/credential-manager.js.map +1 -0
- package/dist/auth/http-client.d.ts +81 -0
- package/dist/auth/http-client.d.ts.map +1 -0
- package/dist/auth/http-client.js +197 -0
- package/dist/auth/http-client.js.map +1 -0
- package/dist/auth/index.d.ts +8 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +6 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/generator/index.d.ts +7 -0
- package/dist/generator/index.d.ts.map +1 -0
- package/dist/generator/index.js +7 -0
- package/dist/generator/index.js.map +1 -0
- package/dist/generator/naming/acronyms.d.ts +81 -0
- package/dist/generator/naming/acronyms.d.ts.map +1 -0
- package/dist/generator/naming/acronyms.js +253 -0
- package/dist/generator/naming/acronyms.js.map +1 -0
- package/dist/generator/naming/index.d.ts +6 -0
- package/dist/generator/naming/index.d.ts.map +1 -0
- package/dist/generator/naming/index.js +6 -0
- package/dist/generator/naming/index.js.map +1 -0
- package/dist/generator/naming/volterra-mapping.d.ts +102 -0
- package/dist/generator/naming/volterra-mapping.d.ts.map +1 -0
- package/dist/generator/naming/volterra-mapping.js +259 -0
- package/dist/generator/naming/volterra-mapping.js.map +1 -0
- package/dist/generator/openapi-parser.d.ts +339 -0
- package/dist/generator/openapi-parser.d.ts.map +1 -0
- package/dist/generator/openapi-parser.js +463 -0
- package/dist/generator/openapi-parser.js.map +1 -0
- package/dist/generator/tool-generator.d.ts +74 -0
- package/dist/generator/tool-generator.d.ts.map +1 -0
- package/dist/generator/tool-generator.js +387 -0
- package/dist/generator/tool-generator.js.map +1 -0
- package/dist/generator/transformers/index.d.ts +7 -0
- package/dist/generator/transformers/index.d.ts.map +1 -0
- package/dist/generator/transformers/index.js +7 -0
- package/dist/generator/transformers/index.js.map +1 -0
- package/dist/generator/transformers/normalize-examples.d.ts +48 -0
- package/dist/generator/transformers/normalize-examples.d.ts.map +1 -0
- package/dist/generator/transformers/normalize-examples.js +66 -0
- package/dist/generator/transformers/normalize-examples.js.map +1 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +70 -0
- package/dist/index.js.map +1 -0
- package/dist/prompts/index.d.ts +6 -0
- package/dist/prompts/index.d.ts.map +1 -0
- package/dist/prompts/index.js +5 -0
- package/dist/prompts/index.js.map +1 -0
- package/dist/prompts/workflows.d.ts +59 -0
- package/dist/prompts/workflows.d.ts.map +1 -0
- package/dist/prompts/workflows.js +585 -0
- package/dist/prompts/workflows.js.map +1 -0
- package/dist/resources/handlers.d.ts +72 -0
- package/dist/resources/handlers.d.ts.map +1 -0
- package/dist/resources/handlers.js +279 -0
- package/dist/resources/handlers.js.map +1 -0
- package/dist/resources/index.d.ts +8 -0
- package/dist/resources/index.d.ts.map +1 -0
- package/dist/resources/index.js +6 -0
- package/dist/resources/index.js.map +1 -0
- package/dist/resources/templates.d.ts +86 -0
- package/dist/resources/templates.d.ts.map +1 -0
- package/dist/resources/templates.js +248 -0
- package/dist/resources/templates.js.map +1 -0
- package/dist/server.d.ts +78 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +426 -0
- package/dist/server.js.map +1 -0
- package/dist/tools/discovery/consolidate.d.ts +97 -0
- package/dist/tools/discovery/consolidate.d.ts.map +1 -0
- package/dist/tools/discovery/consolidate.js +200 -0
- package/dist/tools/discovery/consolidate.js.map +1 -0
- package/dist/tools/discovery/describe.d.ts +132 -0
- package/dist/tools/discovery/describe.d.ts.map +1 -0
- package/dist/tools/discovery/describe.js +206 -0
- package/dist/tools/discovery/describe.js.map +1 -0
- package/dist/tools/discovery/execute.d.ts +98 -0
- package/dist/tools/discovery/execute.d.ts.map +1 -0
- package/dist/tools/discovery/execute.js +251 -0
- package/dist/tools/discovery/execute.js.map +1 -0
- package/dist/tools/discovery/index-loader.d.ts +28 -0
- package/dist/tools/discovery/index-loader.d.ts.map +1 -0
- package/dist/tools/discovery/index-loader.js +69 -0
- package/dist/tools/discovery/index-loader.js.map +1 -0
- package/dist/tools/discovery/index.d.ts +185 -0
- package/dist/tools/discovery/index.d.ts.map +1 -0
- package/dist/tools/discovery/index.js +177 -0
- package/dist/tools/discovery/index.js.map +1 -0
- package/dist/tools/discovery/search.d.ts +41 -0
- package/dist/tools/discovery/search.d.ts.map +1 -0
- package/dist/tools/discovery/search.js +155 -0
- package/dist/tools/discovery/search.js.map +1 -0
- package/dist/tools/discovery/types.d.ts +70 -0
- package/dist/tools/discovery/types.d.ts.map +1 -0
- package/dist/tools/discovery/types.js +9 -0
- package/dist/tools/discovery/types.js.map +1 -0
- package/dist/tools/generated/ai_intelligence/index.d.ts +8 -0
- package/dist/tools/generated/ai_intelligence/index.d.ts.map +1 -0
- package/dist/tools/generated/ai_intelligence/index.js +282 -0
- package/dist/tools/generated/ai_intelligence/index.js.map +1 -0
- package/dist/tools/generated/api_security/index.d.ts +8 -0
- package/dist/tools/generated/api_security/index.d.ts.map +1 -0
- package/dist/tools/generated/api_security/index.js +1852 -0
- package/dist/tools/generated/api_security/index.js.map +1 -0
- package/dist/tools/generated/applications/index.d.ts +8 -0
- package/dist/tools/generated/applications/index.d.ts.map +1 -0
- package/dist/tools/generated/applications/index.js +1589 -0
- package/dist/tools/generated/applications/index.js.map +1 -0
- package/dist/tools/generated/bigip/index.d.ts +8 -0
- package/dist/tools/generated/bigip/index.d.ts.map +1 -0
- package/dist/tools/generated/bigip/index.js +1173 -0
- package/dist/tools/generated/bigip/index.js.map +1 -0
- package/dist/tools/generated/billing/index.d.ts +8 -0
- package/dist/tools/generated/billing/index.d.ts.map +1 -0
- package/dist/tools/generated/billing/index.js +759 -0
- package/dist/tools/generated/billing/index.js.map +1 -0
- package/dist/tools/generated/cdn/index.d.ts +8 -0
- package/dist/tools/generated/cdn/index.d.ts.map +1 -0
- package/dist/tools/generated/cdn/index.js +841 -0
- package/dist/tools/generated/cdn/index.js.map +1 -0
- package/dist/tools/generated/config/index.d.ts +8 -0
- package/dist/tools/generated/config/index.d.ts.map +1 -0
- package/dist/tools/generated/config/index.js +316 -0
- package/dist/tools/generated/config/index.js.map +1 -0
- package/dist/tools/generated/identity/index.d.ts +8 -0
- package/dist/tools/generated/identity/index.d.ts.map +1 -0
- package/dist/tools/generated/identity/index.js +5371 -0
- package/dist/tools/generated/identity/index.js.map +1 -0
- package/dist/tools/generated/infrastructure/index.d.ts +8 -0
- package/dist/tools/generated/infrastructure/index.d.ts.map +1 -0
- package/dist/tools/generated/infrastructure/index.js +5342 -0
- package/dist/tools/generated/infrastructure/index.js.map +1 -0
- package/dist/tools/generated/infrastructure_protection/index.d.ts +8 -0
- package/dist/tools/generated/infrastructure_protection/index.d.ts.map +1 -0
- package/dist/tools/generated/infrastructure_protection/index.js +2919 -0
- package/dist/tools/generated/infrastructure_protection/index.js.map +1 -0
- package/dist/tools/generated/integrations/index.d.ts +8 -0
- package/dist/tools/generated/integrations/index.d.ts.map +1 -0
- package/dist/tools/generated/integrations/index.js +1995 -0
- package/dist/tools/generated/integrations/index.js.map +1 -0
- package/dist/tools/generated/load_balancer/index.d.ts +8 -0
- package/dist/tools/generated/load_balancer/index.d.ts.map +1 -0
- package/dist/tools/generated/load_balancer/index.js +2269 -0
- package/dist/tools/generated/load_balancer/index.js.map +1 -0
- package/dist/tools/generated/networking/index.d.ts +8 -0
- package/dist/tools/generated/networking/index.d.ts.map +1 -0
- package/dist/tools/generated/networking/index.js +11289 -0
- package/dist/tools/generated/networking/index.js.map +1 -0
- package/dist/tools/generated/nginx/index.d.ts +8 -0
- package/dist/tools/generated/nginx/index.d.ts.map +1 -0
- package/dist/tools/generated/nginx/index.js +680 -0
- package/dist/tools/generated/nginx/index.js.map +1 -0
- package/dist/tools/generated/observability/index.d.ts +8 -0
- package/dist/tools/generated/observability/index.d.ts.map +1 -0
- package/dist/tools/generated/observability/index.js +6140 -0
- package/dist/tools/generated/observability/index.js.map +1 -0
- package/dist/tools/generated/operations/index.d.ts +8 -0
- package/dist/tools/generated/operations/index.d.ts.map +1 -0
- package/dist/tools/generated/operations/index.js +1759 -0
- package/dist/tools/generated/operations/index.js.map +1 -0
- package/dist/tools/generated/security/index.d.ts +8 -0
- package/dist/tools/generated/security/index.d.ts.map +1 -0
- package/dist/tools/generated/security/index.js +9111 -0
- package/dist/tools/generated/security/index.js.map +1 -0
- package/dist/tools/generated/service_mesh/index.d.ts +8 -0
- package/dist/tools/generated/service_mesh/index.d.ts.map +1 -0
- package/dist/tools/generated/service_mesh/index.js +1628 -0
- package/dist/tools/generated/service_mesh/index.js.map +1 -0
- package/dist/tools/generated/shape_security/index.d.ts +8 -0
- package/dist/tools/generated/shape_security/index.d.ts.map +1 -0
- package/dist/tools/generated/shape_security/index.js +4121 -0
- package/dist/tools/generated/shape_security/index.js.map +1 -0
- package/dist/tools/generated/subscriptions/index.d.ts +8 -0
- package/dist/tools/generated/subscriptions/index.d.ts.map +1 -0
- package/dist/tools/generated/subscriptions/index.js +778 -0
- package/dist/tools/generated/subscriptions/index.js.map +1 -0
- package/dist/tools/generated/tenant_management/index.d.ts +8 -0
- package/dist/tools/generated/tenant_management/index.d.ts.map +1 -0
- package/dist/tools/generated/tenant_management/index.js +2292 -0
- package/dist/tools/generated/tenant_management/index.js.map +1 -0
- package/dist/tools/generated/vpn/index.d.ts +8 -0
- package/dist/tools/generated/vpn/index.d.ts.map +1 -0
- package/dist/tools/generated/vpn/index.js +1183 -0
- package/dist/tools/generated/vpn/index.js.map +1 -0
- package/dist/tools/index.d.ts +7 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +6 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/registry.d.ts +27 -0
- package/dist/tools/registry.d.ts.map +1 -0
- package/dist/tools/registry.js +83 -0
- package/dist/tools/registry.js.map +1 -0
- package/dist/utils/error-handling.d.ts +109 -0
- package/dist/utils/error-handling.d.ts.map +1 -0
- package/dist/utils/error-handling.js +239 -0
- package/dist/utils/error-handling.js.map +1 -0
- package/dist/utils/index.d.ts +7 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +6 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/logging.d.ts +75 -0
- package/dist/utils/logging.d.ts.map +1 -0
- package/dist/utils/logging.js +131 -0
- package/dist/utils/logging.js.map +1 -0
- package/manifest.json +143 -0
- package/package.json +95 -0
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool Execution Dispatcher
|
|
3
|
+
*
|
|
4
|
+
* Routes tool execution requests to the appropriate handler.
|
|
5
|
+
* This provides a unified interface for executing any discovered tool.
|
|
6
|
+
*/
|
|
7
|
+
import { getToolByName } from "../registry.js";
|
|
8
|
+
import { toolExists } from "./index-loader.js";
|
|
9
|
+
import { CredentialManager, AuthMode } from "../../auth/credential-manager.js";
|
|
10
|
+
import { createHttpClient } from "../../auth/http-client.js";
|
|
11
|
+
import { logger } from "../../utils/logging.js";
|
|
12
|
+
/**
|
|
13
|
+
* Build path with parameters substituted
|
|
14
|
+
*/
|
|
15
|
+
function buildPath(pathTemplate, pathParams) {
|
|
16
|
+
let path = pathTemplate;
|
|
17
|
+
for (const [key, value] of Object.entries(pathParams)) {
|
|
18
|
+
// Handle both {param} and {metadata.param} style placeholders
|
|
19
|
+
path = path.replace(`{${key}}`, encodeURIComponent(value));
|
|
20
|
+
}
|
|
21
|
+
// Check for any remaining unsubstituted parameters
|
|
22
|
+
const remaining = path.match(/\{[^}]+\}/g);
|
|
23
|
+
if (remaining) {
|
|
24
|
+
throw new Error(`Missing path parameters: ${remaining.join(", ")}`);
|
|
25
|
+
}
|
|
26
|
+
return path;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Build query string from parameters
|
|
30
|
+
*/
|
|
31
|
+
function buildQueryString(queryParams) {
|
|
32
|
+
const parts = [];
|
|
33
|
+
for (const [key, value] of Object.entries(queryParams)) {
|
|
34
|
+
if (Array.isArray(value)) {
|
|
35
|
+
for (const v of value) {
|
|
36
|
+
parts.push(`${encodeURIComponent(key)}=${encodeURIComponent(v)}`);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
parts.push(`${encodeURIComponent(key)}=${encodeURIComponent(value)}`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return parts.length > 0 ? `?${parts.join("&")}` : "";
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Generate f5xcctl equivalent command
|
|
47
|
+
*/
|
|
48
|
+
function generateF5xcctlCommand(tool, params) {
|
|
49
|
+
const { operation, resource } = tool;
|
|
50
|
+
const pathParams = params.pathParams ?? {};
|
|
51
|
+
// Build resource identifier
|
|
52
|
+
const namespace = pathParams.namespace ?? pathParams["metadata.namespace"] ?? "{namespace}";
|
|
53
|
+
const name = pathParams.name ?? pathParams["metadata.name"] ?? "{name}";
|
|
54
|
+
// Map operation to f5xcctl verb
|
|
55
|
+
const verbMap = {
|
|
56
|
+
create: "create",
|
|
57
|
+
get: "get",
|
|
58
|
+
list: "list",
|
|
59
|
+
update: "replace",
|
|
60
|
+
delete: "delete",
|
|
61
|
+
};
|
|
62
|
+
const verb = verbMap[operation] ?? operation;
|
|
63
|
+
// Build command
|
|
64
|
+
const resourceType = resource.replace(/-/g, "_");
|
|
65
|
+
if (operation === "list") {
|
|
66
|
+
return `f5xcctl ${verb} ${resourceType} --namespace ${namespace}`;
|
|
67
|
+
}
|
|
68
|
+
else if (operation === "create") {
|
|
69
|
+
return `f5xcctl ${verb} ${resourceType} --namespace ${namespace} -f config.yaml`;
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
return `f5xcctl ${verb} ${resourceType} ${name} --namespace ${namespace}`;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Generate curl command example
|
|
77
|
+
*/
|
|
78
|
+
function generateCurlCommand(tool, params, apiUrl) {
|
|
79
|
+
const path = buildPath(tool.path, params.pathParams ?? {});
|
|
80
|
+
const queryString = buildQueryString(params.queryParams ?? {});
|
|
81
|
+
const fullUrl = `${apiUrl}${path}${queryString}`;
|
|
82
|
+
let cmd = `curl -X ${tool.method} "${fullUrl}"`;
|
|
83
|
+
cmd += ' \\\n -H "Authorization: APIToken $F5XC_API_TOKEN"';
|
|
84
|
+
cmd += ' \\\n -H "Content-Type: application/json"';
|
|
85
|
+
if (params.body && ["POST", "PUT", "PATCH"].includes(tool.method)) {
|
|
86
|
+
cmd += ` \\\n -d '${JSON.stringify(params.body, null, 2)}'`;
|
|
87
|
+
}
|
|
88
|
+
return cmd;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Generate documentation response for unauthenticated mode
|
|
92
|
+
*/
|
|
93
|
+
function generateDocumentationResponse(tool, params) {
|
|
94
|
+
const apiUrl = "https://{tenant}.console.ves.volterra.io/api";
|
|
95
|
+
return {
|
|
96
|
+
tool: {
|
|
97
|
+
name: tool.toolName,
|
|
98
|
+
summary: tool.summary,
|
|
99
|
+
method: tool.method,
|
|
100
|
+
path: tool.path,
|
|
101
|
+
domain: tool.domain,
|
|
102
|
+
resource: tool.resource,
|
|
103
|
+
operation: tool.operation,
|
|
104
|
+
},
|
|
105
|
+
f5xcctlCommand: generateF5xcctlCommand(tool, params),
|
|
106
|
+
curlExample: generateCurlCommand(tool, params, apiUrl),
|
|
107
|
+
authMessage: "API execution disabled. Set F5XC_API_URL and F5XC_API_TOKEN to enable execution.",
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Execute a tool by name with the given parameters
|
|
112
|
+
*
|
|
113
|
+
* In authenticated mode: Makes the actual API call
|
|
114
|
+
* In documentation mode: Returns CLI equivalents and examples
|
|
115
|
+
*
|
|
116
|
+
* @param params - Execution parameters
|
|
117
|
+
* @param credentialManager - Optional credential manager for auth
|
|
118
|
+
* @returns Execution result or documentation
|
|
119
|
+
*
|
|
120
|
+
* @example
|
|
121
|
+
* ```typescript
|
|
122
|
+
* // Execute in authenticated mode
|
|
123
|
+
* const result = await executeTool({
|
|
124
|
+
* toolName: "f5xc-api-waap-http-loadbalancer-list",
|
|
125
|
+
* pathParams: { namespace: "default" }
|
|
126
|
+
* }, credentialManager);
|
|
127
|
+
*
|
|
128
|
+
* // Execute in documentation mode (no credentials)
|
|
129
|
+
* const docs = await executeTool({
|
|
130
|
+
* toolName: "f5xc-api-waap-http-loadbalancer-create",
|
|
131
|
+
* pathParams: { "metadata.namespace": "default" },
|
|
132
|
+
* body: { metadata: { name: "example-lb" }, spec: { ... } }
|
|
133
|
+
* });
|
|
134
|
+
* ```
|
|
135
|
+
*/
|
|
136
|
+
export async function executeTool(params, credentialManager) {
|
|
137
|
+
const { toolName, pathParams = {}, queryParams = {}, body } = params;
|
|
138
|
+
// Validate tool exists
|
|
139
|
+
if (!toolExists(toolName)) {
|
|
140
|
+
return {
|
|
141
|
+
success: false,
|
|
142
|
+
error: `Tool "${toolName}" not found. Use search_tools to find available tools.`,
|
|
143
|
+
toolInfo: {
|
|
144
|
+
name: toolName,
|
|
145
|
+
method: "UNKNOWN",
|
|
146
|
+
path: "UNKNOWN",
|
|
147
|
+
operation: "UNKNOWN",
|
|
148
|
+
},
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
// Get full tool definition
|
|
152
|
+
const tool = getToolByName(toolName);
|
|
153
|
+
if (!tool) {
|
|
154
|
+
return {
|
|
155
|
+
success: false,
|
|
156
|
+
error: `Failed to load tool "${toolName}".`,
|
|
157
|
+
toolInfo: {
|
|
158
|
+
name: toolName,
|
|
159
|
+
method: "UNKNOWN",
|
|
160
|
+
path: "UNKNOWN",
|
|
161
|
+
operation: "UNKNOWN",
|
|
162
|
+
},
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
const toolInfo = {
|
|
166
|
+
name: tool.toolName,
|
|
167
|
+
method: tool.method,
|
|
168
|
+
path: tool.path,
|
|
169
|
+
operation: tool.operation,
|
|
170
|
+
};
|
|
171
|
+
// Check authentication
|
|
172
|
+
const creds = credentialManager ?? new CredentialManager();
|
|
173
|
+
const authMode = creds.getAuthMode();
|
|
174
|
+
if (authMode === AuthMode.NONE) {
|
|
175
|
+
// Return documentation response
|
|
176
|
+
return generateDocumentationResponse(tool, params);
|
|
177
|
+
}
|
|
178
|
+
// Authenticated mode - execute API call
|
|
179
|
+
try {
|
|
180
|
+
const httpClient = createHttpClient(creds);
|
|
181
|
+
const path = buildPath(tool.path, pathParams);
|
|
182
|
+
const queryString = buildQueryString(queryParams);
|
|
183
|
+
const fullPath = `${path}${queryString}`;
|
|
184
|
+
logger.debug(`Executing tool: ${toolName}`, { method: tool.method, path: fullPath });
|
|
185
|
+
let response;
|
|
186
|
+
switch (tool.method.toUpperCase()) {
|
|
187
|
+
case "GET":
|
|
188
|
+
response = await httpClient.get(fullPath);
|
|
189
|
+
break;
|
|
190
|
+
case "POST":
|
|
191
|
+
response = await httpClient.post(fullPath, body);
|
|
192
|
+
break;
|
|
193
|
+
case "PUT":
|
|
194
|
+
response = await httpClient.put(fullPath, body);
|
|
195
|
+
break;
|
|
196
|
+
case "DELETE":
|
|
197
|
+
response = await httpClient.delete(fullPath);
|
|
198
|
+
break;
|
|
199
|
+
default:
|
|
200
|
+
return {
|
|
201
|
+
success: false,
|
|
202
|
+
error: `Unsupported HTTP method: ${tool.method}`,
|
|
203
|
+
toolInfo,
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
return {
|
|
207
|
+
success: true,
|
|
208
|
+
data: response.data,
|
|
209
|
+
statusCode: response.status,
|
|
210
|
+
toolInfo,
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
catch (error) {
|
|
214
|
+
logger.error(`Tool execution failed: ${toolName}`, {
|
|
215
|
+
error: error instanceof Error ? error.message : String(error),
|
|
216
|
+
});
|
|
217
|
+
return {
|
|
218
|
+
success: false,
|
|
219
|
+
error: error instanceof Error ? error.message : "Unknown error occurred",
|
|
220
|
+
toolInfo,
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Validate execution parameters before running
|
|
226
|
+
*/
|
|
227
|
+
export function validateExecuteParams(toolName, params) {
|
|
228
|
+
const errors = [];
|
|
229
|
+
// Check tool exists
|
|
230
|
+
const tool = getToolByName(toolName);
|
|
231
|
+
if (!tool) {
|
|
232
|
+
return { valid: false, errors: [`Tool "${toolName}" not found`] };
|
|
233
|
+
}
|
|
234
|
+
// Check required path parameters
|
|
235
|
+
for (const param of tool.pathParameters) {
|
|
236
|
+
if (param.required) {
|
|
237
|
+
const value = params.pathParams?.[param.name] ?? params.pathParams?.[param.name.replace("metadata.", "")];
|
|
238
|
+
if (!value) {
|
|
239
|
+
errors.push(`Missing required path parameter: ${param.name}`);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
// Check if body is required
|
|
244
|
+
if (tool.requestBodySchema && !params.body) {
|
|
245
|
+
if (["POST", "PUT", "PATCH"].includes(tool.method)) {
|
|
246
|
+
errors.push("Request body is required for this operation");
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
return { valid: errors.length === 0, errors };
|
|
250
|
+
}
|
|
251
|
+
//# sourceMappingURL=execute.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execute.js","sourceRoot":"","sources":["../../../src/tools/discovery/execute.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AAC/E,OAAO,EAAE,gBAAgB,EAA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AChE,CAAC;QACH,CAAC;IACH,CAAC;IAED,4BAA4B;IAC5B,IAAI,IAAI,CAAC,iBAAiB,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;QAC3C,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;YACnD,MAAM,CAAC,IAAI,CAAC,6CAA6C,CAAC,CAAC;QAC7D,CAAC;IACH,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;AAChD,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool Index Loader
|
|
3
|
+
*
|
|
4
|
+
* Loads and caches the lightweight tool index for discovery.
|
|
5
|
+
* Generates the index from existing tool registry on first load.
|
|
6
|
+
*/
|
|
7
|
+
import type { ToolIndex, ToolIndexEntry, ToolIndexMetadata } from "./types.js";
|
|
8
|
+
/**
|
|
9
|
+
* Get the tool index (generates on first call, cached thereafter)
|
|
10
|
+
*/
|
|
11
|
+
export declare function getToolIndex(): ToolIndex;
|
|
12
|
+
/**
|
|
13
|
+
* Clear the cached index (useful for testing or refresh)
|
|
14
|
+
*/
|
|
15
|
+
export declare function clearIndexCache(): void;
|
|
16
|
+
/**
|
|
17
|
+
* Get index metadata without loading full index
|
|
18
|
+
*/
|
|
19
|
+
export declare function getIndexMetadata(): ToolIndexMetadata;
|
|
20
|
+
/**
|
|
21
|
+
* Check if a tool exists by name
|
|
22
|
+
*/
|
|
23
|
+
export declare function toolExists(toolName: string): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Get a single tool entry by name
|
|
26
|
+
*/
|
|
27
|
+
export declare function getToolEntry(toolName: string): ToolIndexEntry | undefined;
|
|
28
|
+
//# sourceMappingURL=index-loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-loader.d.ts","sourceRoot":"","sources":["../../../src/tools/discovery/index-loader.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAkC/E;;GAEG;AACH,wBAAgB,YAAY,IAAI,SAAS,CAKxC;AAED;;GAEG;AACH,wBAAgB,eAAe,IAAI,IAAI,CAEtC;AAED;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,iBAAiB,CAEpD;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAGpD;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS,CAGzE"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool Index Loader
|
|
3
|
+
*
|
|
4
|
+
* Loads and caches the lightweight tool index for discovery.
|
|
5
|
+
* Generates the index from existing tool registry on first load.
|
|
6
|
+
*/
|
|
7
|
+
import { allTools } from "../registry.js";
|
|
8
|
+
// Cached index for performance
|
|
9
|
+
let cachedIndex = null;
|
|
10
|
+
/**
|
|
11
|
+
* Generate tool index from the existing tool registry
|
|
12
|
+
*/
|
|
13
|
+
function generateIndex() {
|
|
14
|
+
const tools = allTools.map((tool) => ({
|
|
15
|
+
name: tool.toolName,
|
|
16
|
+
domain: tool.domain,
|
|
17
|
+
resource: tool.resource,
|
|
18
|
+
operation: tool.operation,
|
|
19
|
+
summary: tool.summary,
|
|
20
|
+
}));
|
|
21
|
+
// Calculate domain counts
|
|
22
|
+
const domains = {};
|
|
23
|
+
for (const tool of tools) {
|
|
24
|
+
domains[tool.domain] = (domains[tool.domain] ?? 0) + 1;
|
|
25
|
+
}
|
|
26
|
+
const metadata = {
|
|
27
|
+
totalTools: tools.length,
|
|
28
|
+
domains,
|
|
29
|
+
generatedAt: new Date().toISOString(),
|
|
30
|
+
version: "1.0.0",
|
|
31
|
+
};
|
|
32
|
+
return { metadata, tools };
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Get the tool index (generates on first call, cached thereafter)
|
|
36
|
+
*/
|
|
37
|
+
export function getToolIndex() {
|
|
38
|
+
if (!cachedIndex) {
|
|
39
|
+
cachedIndex = generateIndex();
|
|
40
|
+
}
|
|
41
|
+
return cachedIndex;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Clear the cached index (useful for testing or refresh)
|
|
45
|
+
*/
|
|
46
|
+
export function clearIndexCache() {
|
|
47
|
+
cachedIndex = null;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Get index metadata without loading full index
|
|
51
|
+
*/
|
|
52
|
+
export function getIndexMetadata() {
|
|
53
|
+
return getToolIndex().metadata;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Check if a tool exists by name
|
|
57
|
+
*/
|
|
58
|
+
export function toolExists(toolName) {
|
|
59
|
+
const index = getToolIndex();
|
|
60
|
+
return index.tools.some((t) => t.name === toolName);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Get a single tool entry by name
|
|
64
|
+
*/
|
|
65
|
+
export function getToolEntry(toolName) {
|
|
66
|
+
const index = getToolIndex();
|
|
67
|
+
return index.tools.find((t) => t.name === toolName);
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=index-loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-loader.js","sourceRoot":"","sources":["../../../src/tools/discovery/index-loader.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,+BAA+B;AAC/B,IAAI,WAAW,GAAqB,IAAI,CAAC;AAEzC;;GAEG;AACH,SAAS,aAAa;IACpB,MAAM,KAAK,GAAqB,QAAQ,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC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;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,QAAgB;IAC3C,MAAM,KAAK,GAAG,YAAY,EAAE,CAAC;IAC7B,OAAO,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC;AACtD,CAAC"}
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Discovery Module - Dynamic Tool Discovery for Token Efficiency
|
|
3
|
+
*
|
|
4
|
+
* This module implements the Speakeasy-style dynamic toolset pattern
|
|
5
|
+
* that reduces token consumption by 95%+ through lazy loading.
|
|
6
|
+
*
|
|
7
|
+
* Instead of loading all 1,400+ tools upfront (~535K tokens), this module
|
|
8
|
+
* exposes three meta-tools that load tool schemas on-demand:
|
|
9
|
+
*
|
|
10
|
+
* 1. search_tools - Find tools matching a natural language query
|
|
11
|
+
* 2. describe_tool - Get full schema for a specific tool
|
|
12
|
+
* 3. execute_tool - Execute a discovered tool
|
|
13
|
+
*
|
|
14
|
+
* Token Impact:
|
|
15
|
+
* - Before: 535,000 tokens loaded at server start
|
|
16
|
+
* - After: ~500 tokens (meta-tools) + ~375 tokens per tool used
|
|
17
|
+
*/
|
|
18
|
+
export type { ToolIndexEntry, SearchResult, SearchOptions, ToolIndex, ToolIndexMetadata, } from "./types.js";
|
|
19
|
+
export type { ToolDescription, ParameterDescription, CompactToolDescription } from "./describe.js";
|
|
20
|
+
export type { ExecuteToolParams, ExecuteToolResult, DocumentationResponse } from "./execute.js";
|
|
21
|
+
export { getToolIndex, clearIndexCache, getIndexMetadata, toolExists, getToolEntry, } from "./index-loader.js";
|
|
22
|
+
export { searchTools, getToolsByDomain, getToolsByResource, getAvailableDomains, getToolCountByDomain, } from "./search.js";
|
|
23
|
+
export { describeTool, describeTools, describeToolSafe, describeToolCompact, getFullToolSchema, getOptimizationStats, } from "./describe.js";
|
|
24
|
+
export { executeTool, validateExecuteParams } from "./execute.js";
|
|
25
|
+
export type { CrudOperation, ConsolidatedResource, ConsolidatedIndex } from "./consolidate.js";
|
|
26
|
+
export { getConsolidatedIndex, clearConsolidatedCache, getConsolidatedResource, getConsolidatedByDomain, searchConsolidatedResources, resolveConsolidatedTool, getConsolidationStats, } from "./consolidate.js";
|
|
27
|
+
/**
|
|
28
|
+
* MCP Tool Definitions for the discovery meta-tools
|
|
29
|
+
*
|
|
30
|
+
* These are the three tools that get registered with the MCP server
|
|
31
|
+
* instead of the 1,400+ individual API tools.
|
|
32
|
+
*/
|
|
33
|
+
export declare const DISCOVERY_TOOLS: {
|
|
34
|
+
readonly search: {
|
|
35
|
+
readonly name: "f5xc-api-search-tools";
|
|
36
|
+
readonly description: string;
|
|
37
|
+
readonly inputSchema: {
|
|
38
|
+
readonly type: "object";
|
|
39
|
+
readonly properties: {
|
|
40
|
+
readonly query: {
|
|
41
|
+
readonly type: "string";
|
|
42
|
+
readonly description: "Natural language search query (e.g., 'http load balancer', 'create origin pool', 'delete dns zone')";
|
|
43
|
+
};
|
|
44
|
+
readonly limit: {
|
|
45
|
+
readonly type: "number";
|
|
46
|
+
readonly description: "Maximum number of results to return (default: 10, max: 50)";
|
|
47
|
+
readonly default: 10;
|
|
48
|
+
};
|
|
49
|
+
readonly domains: {
|
|
50
|
+
readonly type: "array";
|
|
51
|
+
readonly items: {
|
|
52
|
+
readonly type: "string";
|
|
53
|
+
};
|
|
54
|
+
readonly description: "Filter by domain(s): waap, dns, core, network, site, security, appstack";
|
|
55
|
+
};
|
|
56
|
+
readonly operations: {
|
|
57
|
+
readonly type: "array";
|
|
58
|
+
readonly items: {
|
|
59
|
+
readonly type: "string";
|
|
60
|
+
};
|
|
61
|
+
readonly description: "Filter by operation type(s): create, get, list, update, delete";
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
readonly required: readonly ["query"];
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
readonly describe: {
|
|
68
|
+
readonly name: "f5xc-api-describe-tool";
|
|
69
|
+
readonly description: string;
|
|
70
|
+
readonly inputSchema: {
|
|
71
|
+
readonly type: "object";
|
|
72
|
+
readonly properties: {
|
|
73
|
+
readonly toolName: {
|
|
74
|
+
readonly type: "string";
|
|
75
|
+
readonly description: "The exact tool name (e.g., 'f5xc-api-waap-http-loadbalancer-create')";
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
readonly required: readonly ["toolName"];
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
readonly execute: {
|
|
82
|
+
readonly name: "f5xc-api-execute-tool";
|
|
83
|
+
readonly description: string;
|
|
84
|
+
readonly inputSchema: {
|
|
85
|
+
readonly type: "object";
|
|
86
|
+
readonly properties: {
|
|
87
|
+
readonly toolName: {
|
|
88
|
+
readonly type: "string";
|
|
89
|
+
readonly description: "The exact tool name to execute";
|
|
90
|
+
};
|
|
91
|
+
readonly pathParams: {
|
|
92
|
+
readonly type: "object";
|
|
93
|
+
readonly description: "Path parameters (e.g., { namespace: 'default', name: 'example-resource' })";
|
|
94
|
+
readonly additionalProperties: {
|
|
95
|
+
readonly type: "string";
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
readonly queryParams: {
|
|
99
|
+
readonly type: "object";
|
|
100
|
+
readonly description: "Query parameters for the request";
|
|
101
|
+
readonly additionalProperties: {
|
|
102
|
+
readonly type: "string";
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
readonly body: {
|
|
106
|
+
readonly type: "object";
|
|
107
|
+
readonly description: "Request body for POST/PUT/PATCH operations";
|
|
108
|
+
};
|
|
109
|
+
};
|
|
110
|
+
readonly required: readonly ["toolName"];
|
|
111
|
+
};
|
|
112
|
+
};
|
|
113
|
+
readonly serverInfo: {
|
|
114
|
+
readonly name: "f5xc-api-server-info";
|
|
115
|
+
readonly description: string;
|
|
116
|
+
readonly inputSchema: {
|
|
117
|
+
readonly type: "object";
|
|
118
|
+
readonly properties: {};
|
|
119
|
+
};
|
|
120
|
+
};
|
|
121
|
+
readonly searchResources: {
|
|
122
|
+
readonly name: "f5xc-api-search-resources";
|
|
123
|
+
readonly description: string;
|
|
124
|
+
readonly inputSchema: {
|
|
125
|
+
readonly type: "object";
|
|
126
|
+
readonly properties: {
|
|
127
|
+
readonly query: {
|
|
128
|
+
readonly type: "string";
|
|
129
|
+
readonly description: "Natural language search query (e.g., 'http load balancer', 'origin pool', 'dns zone')";
|
|
130
|
+
};
|
|
131
|
+
readonly limit: {
|
|
132
|
+
readonly type: "number";
|
|
133
|
+
readonly description: "Maximum number of results to return (default: 10)";
|
|
134
|
+
readonly default: 10;
|
|
135
|
+
};
|
|
136
|
+
readonly domains: {
|
|
137
|
+
readonly type: "array";
|
|
138
|
+
readonly items: {
|
|
139
|
+
readonly type: "string";
|
|
140
|
+
};
|
|
141
|
+
readonly description: "Filter by domain(s): waap, dns, core, network, site, security, appstack";
|
|
142
|
+
};
|
|
143
|
+
};
|
|
144
|
+
readonly required: readonly ["query"];
|
|
145
|
+
};
|
|
146
|
+
};
|
|
147
|
+
readonly executeResource: {
|
|
148
|
+
readonly name: "f5xc-api-execute-resource";
|
|
149
|
+
readonly description: string;
|
|
150
|
+
readonly inputSchema: {
|
|
151
|
+
readonly type: "object";
|
|
152
|
+
readonly properties: {
|
|
153
|
+
readonly resourceName: {
|
|
154
|
+
readonly type: "string";
|
|
155
|
+
readonly description: "The consolidated resource name (e.g., 'f5xc-api-waap-http-loadbalancer')";
|
|
156
|
+
};
|
|
157
|
+
readonly operation: {
|
|
158
|
+
readonly type: "string";
|
|
159
|
+
readonly enum: readonly ["create", "get", "list", "update", "delete"];
|
|
160
|
+
readonly description: "The CRUD operation to perform";
|
|
161
|
+
};
|
|
162
|
+
readonly pathParams: {
|
|
163
|
+
readonly type: "object";
|
|
164
|
+
readonly description: "Path parameters (e.g., { namespace: 'default', name: 'example-resource' })";
|
|
165
|
+
readonly additionalProperties: {
|
|
166
|
+
readonly type: "string";
|
|
167
|
+
};
|
|
168
|
+
};
|
|
169
|
+
readonly queryParams: {
|
|
170
|
+
readonly type: "object";
|
|
171
|
+
readonly description: "Query parameters for the request";
|
|
172
|
+
readonly additionalProperties: {
|
|
173
|
+
readonly type: "string";
|
|
174
|
+
};
|
|
175
|
+
};
|
|
176
|
+
readonly body: {
|
|
177
|
+
readonly type: "object";
|
|
178
|
+
readonly description: "Request body for create/update operations";
|
|
179
|
+
};
|
|
180
|
+
};
|
|
181
|
+
readonly required: readonly ["resourceName", "operation"];
|
|
182
|
+
};
|
|
183
|
+
};
|
|
184
|
+
};
|
|
185
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tools/discovery/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,YAAY,EACV,cAAc,EACd,YAAY,EACZ,aAAa,EACb,SAAS,EACT,iBAAiB,GAClB,MAAM,YAAY,CAAC;AAEpB,YAAY,EAAE,eAAe,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AAEnG,YAAY,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAGhG,OAAO,EACL,YAAY,EACZ,eAAe,EACf,gBAAgB,EAChB,UAAU,EACV,YAAY,GACb,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EACL,WAAW,EACX,gBAAgB,EAChB,kBAAkB,EAClB,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,aAAa,CAAC;AAGrB,OAAO,EACL,YAAY,EACZ,aAAa,EACb,gBAAgB,EAChB,mBAAmB,EACnB,iBAAiB,EACjB,oBAAoB,GACrB,MAAM,eAAe,CAAC;AAGvB,OAAO,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAGlE,YAAY,EAAE,aAAa,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAC/F,OA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