@robinmordasiewicz/f5xc-api-mcp 2.0.41-2601200045 → 2.0.44-2601231946
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 +107 -0
- package/dist/server/handlers/tool-handlers/index.d.ts +1 -0
- package/dist/server/handlers/tool-handlers/index.d.ts.map +1 -1
- package/dist/server/handlers/tool-handlers/index.js +4 -1
- package/dist/server/handlers/tool-handlers/index.js.map +1 -1
- package/dist/server/handlers/tool-handlers/quota.d.ts +10 -0
- package/dist/server/handlers/tool-handlers/quota.d.ts.map +1 -0
- package/dist/server/handlers/tool-handlers/quota.js +201 -0
- package/dist/server/handlers/tool-handlers/quota.js.map +1 -0
- package/dist/services/quota-api-client.d.ts +32 -0
- package/dist/services/quota-api-client.d.ts.map +1 -0
- package/dist/services/quota-api-client.js +97 -0
- package/dist/services/quota-api-client.js.map +1 -0
- package/dist/services/quota-formatter.d.ts +37 -0
- package/dist/services/quota-formatter.d.ts.map +1 -0
- package/dist/services/quota-formatter.js +114 -0
- package/dist/services/quota-formatter.js.map +1 -0
- package/dist/services/quota-resource-mapping.d.ts +26 -0
- package/dist/services/quota-resource-mapping.d.ts.map +1 -0
- package/dist/services/quota-resource-mapping.js +52 -0
- package/dist/services/quota-resource-mapping.js.map +1 -0
- package/dist/services/quota-service.d.ts +68 -0
- package/dist/services/quota-service.d.ts.map +1 -0
- package/dist/services/quota-service.js +203 -0
- package/dist/services/quota-service.js.map +1 -0
- package/dist/services/quota-thresholds.d.ts +38 -0
- package/dist/services/quota-thresholds.d.ts.map +1 -0
- package/dist/services/quota-thresholds.js +39 -0
- package/dist/services/quota-thresholds.js.map +1 -0
- package/dist/tools/discovery/execute.d.ts +3 -0
- package/dist/tools/discovery/execute.d.ts.map +1 -1
- package/dist/tools/discovery/execute.js +58 -0
- package/dist/tools/discovery/execute.js.map +1 -1
- package/dist/tools/discovery/validate.d.ts +17 -0
- package/dist/tools/discovery/validate.d.ts.map +1 -1
- package/dist/tools/discovery/validate.js +96 -0
- package/dist/tools/discovery/validate.js.map +1 -1
- package/dist/tools/generated/dependency-graph.json +1 -1
- package/dist/types/quota.d.ts +146 -0
- package/dist/types/quota.d.ts.map +1 -0
- package/dist/types/quota.js +3 -0
- package/dist/types/quota.js.map +1 -0
- package/dist/version.d.ts +2 -2
- package/dist/version.js +2 -2
- package/manifest.json +1 -1
- package/package.json +1 -1
- package/specs/domains/admin_console_and_ui.json +562 -25
- package/specs/domains/ai_services.json +1384 -21
- package/specs/domains/api.json +6275 -173
- package/specs/domains/authentication.json +1580 -45
- package/specs/domains/bigip.json +3108 -94
- package/specs/domains/billing_and_usage.json +2736 -63
- package/specs/domains/blindfold.json +3523 -109
- package/specs/domains/bot_and_threat_defense.json +1895 -65
- package/specs/domains/cdn.json +12134 -177
- package/specs/domains/ce_management.json +4591 -76
- package/specs/domains/certificates.json +2051 -75
- package/specs/domains/cloud_infrastructure.json +5352 -113
- package/specs/domains/container_services.json +3314 -91
- package/specs/domains/data_and_privacy_security.json +1782 -66
- package/specs/domains/data_intelligence.json +2080 -62
- package/specs/domains/ddos.json +5267 -154
- package/specs/domains/dns.json +5433 -148
- package/specs/domains/managed_kubernetes.json +2578 -85
- package/specs/domains/marketplace.json +3639 -103
- package/specs/domains/network.json +8207 -230
- package/specs/domains/network_security.json +7184 -187
- package/specs/domains/nginx_one.json +1741 -62
- package/specs/domains/object_storage.json +432 -12
- package/specs/domains/observability.json +6092 -102
- package/specs/domains/rate_limiting.json +1514 -52
- package/specs/domains/secops_and_incident_response.json +922 -36
- package/specs/domains/service_mesh.json +4833 -119
- package/specs/domains/shape.json +18376 -313
- package/specs/domains/sites.json +25222 -349
- package/specs/domains/statistics.json +11917 -225
- package/specs/domains/support.json +5549 -108
- package/specs/domains/telemetry_and_insights.json +3636 -72
- package/specs/domains/tenant_and_identity.json +12604 -268
- package/specs/domains/threat_campaign.json +3376 -66
- package/specs/domains/users.json +1562 -66
- package/specs/domains/validation.json +2 -2
- package/specs/domains/virtual.json +15283 -244
- package/specs/domains/vpm_and_node_management.json +1 -1
- package/specs/domains/waf.json +6010 -139
- package/specs/index.json +2 -2
package/README.md
CHANGED
|
@@ -18,6 +18,108 @@ other MCP-compatible tools.
|
|
|
18
18
|
- **URL Normalization** - Automatically handles various F5XC URL formats
|
|
19
19
|
- **Pre-enriched Specs** - Uses optimized OpenAPI 3.0.3 specifications with domain metadata
|
|
20
20
|
- **Server-Applied Defaults** - Distinguishes user-required fields from server-defaulted fields (v2.0.28+)
|
|
21
|
+
- **Quota Awareness** - Pre-flight quota validation prevents resource creation failures (v2.1.0+)
|
|
22
|
+
|
|
23
|
+
## Quota Awareness
|
|
24
|
+
|
|
25
|
+
The MCP server automatically checks resource quota availability before executing create
|
|
26
|
+
operations, preventing failures due to quota limits.
|
|
27
|
+
|
|
28
|
+
### Features
|
|
29
|
+
|
|
30
|
+
- **Pre-Flight Validation** - Checks quota before API calls
|
|
31
|
+
- **Automatic Blocking** - Prevents creation when quota is at 100%
|
|
32
|
+
- **Warning System** - Warns when quota usage is 80-99%
|
|
33
|
+
- **Caching** - 5-minute cache reduces API calls
|
|
34
|
+
- **Per-Namespace Tracking** - Quota limits checked per namespace
|
|
35
|
+
- **Configurable Thresholds** - Customize warning and blocking levels
|
|
36
|
+
|
|
37
|
+
### Quota MCP Tools
|
|
38
|
+
|
|
39
|
+
Three MCP tools provide visibility into quota usage:
|
|
40
|
+
|
|
41
|
+
**`f5xc-api-get-quota-status`**
|
|
42
|
+
|
|
43
|
+
```typescript
|
|
44
|
+
// Get quota status for a specific resource type
|
|
45
|
+
{
|
|
46
|
+
"namespace": "production",
|
|
47
|
+
"resourceType": "healthcheck"
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Output:
|
|
51
|
+
// Quota Status for healthcheck
|
|
52
|
+
// Namespace: production
|
|
53
|
+
// Current Usage: 95/100 (95%)
|
|
54
|
+
// Remaining: 5
|
|
55
|
+
// Status: ⚠️ Approaching limit
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
**`f5xc-api-list-namespace-quotas`**
|
|
59
|
+
|
|
60
|
+
```typescript
|
|
61
|
+
// List all quota limits for a namespace
|
|
62
|
+
{
|
|
63
|
+
"namespace": "production",
|
|
64
|
+
"showOnlyLimited": false
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// Output: Table of all resource quotas with usage
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
**`f5xc-api-clear-quota-cache`**
|
|
71
|
+
|
|
72
|
+
```typescript
|
|
73
|
+
// Clear quota cache to force fresh API queries
|
|
74
|
+
{
|
|
75
|
+
"namespace": "production" // optional
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### Quota Thresholds
|
|
80
|
+
|
|
81
|
+
Resource creation behavior based on quota usage:
|
|
82
|
+
|
|
83
|
+
| Zone | Usage | Behavior |
|
|
84
|
+
|------|-------|----------|
|
|
85
|
+
| 🟢 Green | 0-79% | Creation allowed, no warnings |
|
|
86
|
+
| 🟡 Yellow | 80-99% | Creation allowed, warning logged |
|
|
87
|
+
| 🔴 Red | 100%+ | **Creation blocked** with error |
|
|
88
|
+
|
|
89
|
+
### Example Error Message
|
|
90
|
+
|
|
91
|
+
When quota limit is reached:
|
|
92
|
+
|
|
93
|
+
```text
|
|
94
|
+
ERROR: Resource quota limit reached
|
|
95
|
+
|
|
96
|
+
Resource Type: healthcheck
|
|
97
|
+
Namespace: production
|
|
98
|
+
Current Usage: 100/100 (100%)
|
|
99
|
+
Status: ❌ At limit - cannot create additional resources
|
|
100
|
+
|
|
101
|
+
Action Required:
|
|
102
|
+
1. Delete unused healthcheck resources in the 'production' namespace
|
|
103
|
+
2. Request quota increase from F5 XC support
|
|
104
|
+
3. Use a different namespace with available quota
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### Configuration
|
|
108
|
+
|
|
109
|
+
Control quota checking behavior via environment variables:
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
# Enable/disable quota checking (default: true)
|
|
113
|
+
export F5XC_QUOTA_CHECK_ENABLED=true
|
|
114
|
+
|
|
115
|
+
# Cache TTL in seconds (default: 300 = 5 minutes)
|
|
116
|
+
export F5XC_QUOTA_CACHE_TTL=300
|
|
117
|
+
|
|
118
|
+
# Threshold percentages (defaults: 79, 99, 100)
|
|
119
|
+
export F5XC_QUOTA_GREEN_THRESHOLD=79
|
|
120
|
+
export F5XC_QUOTA_YELLOW_THRESHOLD=99
|
|
121
|
+
export F5XC_QUOTA_RED_THRESHOLD=100
|
|
122
|
+
```
|
|
21
123
|
|
|
22
124
|
## Server-Applied Default Values
|
|
23
125
|
|
|
@@ -274,6 +376,11 @@ Add to `opencode.json` (project root or `~/.config/opencode/opencode.json`):
|
|
|
274
376
|
| `F5XC_PROFILE` | No | Profile name to use (default: active profile from config) |
|
|
275
377
|
| `F5XC_TLS_INSECURE` | No | Disable SSL verification (staging only, set to `true`) |
|
|
276
378
|
| `F5XC_CA_BUNDLE` | No | Path to custom CA certificate bundle |
|
|
379
|
+
| `F5XC_QUOTA_CHECK_ENABLED` | No | Enable quota validation (default: `true`) |
|
|
380
|
+
| `F5XC_QUOTA_CACHE_TTL` | No | Quota cache TTL in seconds (default: `300`) |
|
|
381
|
+
| `F5XC_QUOTA_GREEN_THRESHOLD` | No | Green zone percentage (default: `79`) |
|
|
382
|
+
| `F5XC_QUOTA_YELLOW_THRESHOLD` | No | Yellow zone percentage (default: `99`) |
|
|
383
|
+
| `F5XC_QUOTA_RED_THRESHOLD` | No | Red zone percentage (default: `100`) |
|
|
277
384
|
| `LOG_LEVEL` | No | Logging verbosity (debug, info, warn, error) |
|
|
278
385
|
|
|
279
386
|
## Profile-Based Configuration
|
|
@@ -30,4 +30,5 @@ export { registerExecutionTools } from "./execution.js";
|
|
|
30
30
|
export { registerAnalysisTools } from "./analysis.js";
|
|
31
31
|
export { registerPlanningTools } from "./planning.js";
|
|
32
32
|
export { registerGuidanceTools } from "./guidance.js";
|
|
33
|
+
export { registerQuotaTools } from "./quota.js";
|
|
33
34
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/server/handlers/tool-handlers/index.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,EAAY,KAAK,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/server/handlers/tool-handlers/index.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,EAAY,KAAK,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAYhF;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,iBAAiB,EAAE,iBAAiB,CAAC;CACtC;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,uBAAuB,GAAG,IAAI,CA0BvF;AAGD,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -8,6 +8,7 @@ import { registerExecutionTools } from "./execution.js";
|
|
|
8
8
|
import { registerAnalysisTools } from "./analysis.js";
|
|
9
9
|
import { registerPlanningTools } from "./planning.js";
|
|
10
10
|
import { registerGuidanceTools } from "./guidance.js";
|
|
11
|
+
import { registerQuotaTools } from "./quota.js";
|
|
11
12
|
/**
|
|
12
13
|
* Registers all MCP tools for F5XC API operations.
|
|
13
14
|
*
|
|
@@ -29,13 +30,14 @@ export function registerTools(server, context) {
|
|
|
29
30
|
registerAnalysisTools(server);
|
|
30
31
|
registerPlanningTools(server);
|
|
31
32
|
registerGuidanceTools(server);
|
|
33
|
+
registerQuotaTools(server, credentialManager);
|
|
32
34
|
// Log registration completion
|
|
33
35
|
const indexMetadata = getIndexMetadata();
|
|
34
36
|
const consolidationStats = getConsolidationStats();
|
|
35
37
|
logger.info("Tool registration completed (dynamic discovery mode)", {
|
|
36
38
|
authMode,
|
|
37
39
|
authenticated: authMode !== AuthMode.NONE,
|
|
38
|
-
registeredTools: 14
|
|
40
|
+
registeredTools: 17, // Updated: 14 + 3 quota tools
|
|
39
41
|
indexedTools: indexMetadata.totalTools,
|
|
40
42
|
consolidatedResources: consolidationStats.consolidatedCount,
|
|
41
43
|
consolidationReduction: consolidationStats.reductionPercent,
|
|
@@ -50,4 +52,5 @@ export { registerExecutionTools } from "./execution.js";
|
|
|
50
52
|
export { registerAnalysisTools } from "./analysis.js";
|
|
51
53
|
export { registerPlanningTools } from "./planning.js";
|
|
52
54
|
export { registerGuidanceTools } from "./guidance.js";
|
|
55
|
+
export { registerQuotaTools } from "./quota.js";
|
|
53
56
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/server/handlers/tool-handlers/index.ts"],"names":[],"mappings":"AAAA,sDAAsD;AAUtD,OAAO,EAAE,QAAQ,EAA0B,MAAM,8BAA8B,CAAC;AAChF,OAAO,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAE5F,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,C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AC,CAAC;IAClD,qBAAqB,CAAC,MAAM,CAAC,CAAC;IAC9B,qBAAqB,CAAC,MAAM,CAAC,CAAC;IAC9B,qBAAqB,CAAC,MAAM,CAAC,CAAC;IAC9B,kBAAkB,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;IAE9C,8BAA8B;IAC9B,MAAM,aAAa,GAAG,gBAAgB,EAAE,CAAC;IACzC,MAAM,kBAAkB,GAAG,qBAAqB,EAAE,CAAC;IACnD,MAAM,CAAC,IAAI,CAAC,sDAAsD,EAAE;QAClE,QAAQ;QACR,aAAa,EAAE,QAAQ,KAAK,QAAQ,CAAC,IAAI;QACzC,eAAe,EAAE,EAAE,EAAE,8BAA8B;QACnD,YAAY,EAAE,aAAa,CAAC,UAAU;QACtC,qBAAqB,EAAE,kBAAkB,CAAC,iBAAiB;QAC3D,sBAAsB,EAAE,kBAAkB,CAAC,gBAAgB;QAC3D,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC;QAC3C,YAAY,EAAE,mCAAmC;KAClD,CAAC,CAAC;AACL,CAAC;AAED,4EAA4E;AAC5E,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
import type { CredentialManager } from "@robinmordasiewicz/f5xc-auth";
|
|
3
|
+
/**
|
|
4
|
+
* Register quota management tools with the MCP server
|
|
5
|
+
*
|
|
6
|
+
* @param server - MCP server instance
|
|
7
|
+
* @param credentialManager - Credential manager for authentication
|
|
8
|
+
*/
|
|
9
|
+
export declare function registerQuotaTools(server: McpServer, credentialManager?: CredentialManager): void;
|
|
10
|
+
//# sourceMappingURL=quota.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quota.d.ts","sourceRoot":"","sources":["../../../../src/server/handlers/tool-handlers/quota.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAGzE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAItE;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,SAAS,EAAE,iBAAiB,CAAC,EAAE,iBAAiB,GAAG,IAAI,CA4MjG"}
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
// Copyright (c) 2026 Robin Mordasiewicz. MIT License.
|
|
2
|
+
/**
|
|
3
|
+
* Quota Management Tool Handlers
|
|
4
|
+
*
|
|
5
|
+
* MCP tools for checking and managing F5XC quota usage.
|
|
6
|
+
* Provides visibility into resource quota consumption and limits.
|
|
7
|
+
*/
|
|
8
|
+
import { z } from "zod";
|
|
9
|
+
import { quotaService } from "../../../services/quota-service.js";
|
|
10
|
+
import { formatQuotaStatus, formatQuotaTable } from "../../../services/quota-formatter.js";
|
|
11
|
+
import { createHttpClient } from "@robinmordasiewicz/f5xc-auth";
|
|
12
|
+
import { logger } from "../../../utils/logging.js";
|
|
13
|
+
/**
|
|
14
|
+
* Register quota management tools with the MCP server
|
|
15
|
+
*
|
|
16
|
+
* @param server - MCP server instance
|
|
17
|
+
* @param credentialManager - Credential manager for authentication
|
|
18
|
+
*/
|
|
19
|
+
export function registerQuotaTools(server, credentialManager) {
|
|
20
|
+
/**
|
|
21
|
+
* Tool 1: Get Quota Status
|
|
22
|
+
*/
|
|
23
|
+
server.tool("f5xc-api-get-quota-status", "Get current quota usage and limits for a namespace and resource type", {
|
|
24
|
+
namespace: z
|
|
25
|
+
.string()
|
|
26
|
+
.describe("Namespace to check quota for (e.g., 'default', 'production')"),
|
|
27
|
+
resourceType: z
|
|
28
|
+
.string()
|
|
29
|
+
.optional()
|
|
30
|
+
.describe("Resource type to check (e.g., 'healthcheck', 'http-loadbalancer')"),
|
|
31
|
+
}, async (args) => {
|
|
32
|
+
const { namespace, resourceType } = args;
|
|
33
|
+
if (!credentialManager) {
|
|
34
|
+
return {
|
|
35
|
+
content: [
|
|
36
|
+
{
|
|
37
|
+
type: "text",
|
|
38
|
+
text: "Quota checking requires authentication. Please configure F5XC credentials using f5xc-api-configure-auth.",
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
try {
|
|
44
|
+
const httpClient = createHttpClient(credentialManager);
|
|
45
|
+
if (resourceType) {
|
|
46
|
+
// Get status for specific resource type
|
|
47
|
+
const status = await quotaService.getQuotaStatus(namespace, resourceType, httpClient);
|
|
48
|
+
return {
|
|
49
|
+
content: [
|
|
50
|
+
{
|
|
51
|
+
type: "text",
|
|
52
|
+
text: formatQuotaStatus(status),
|
|
53
|
+
},
|
|
54
|
+
],
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
// List all quotas for namespace
|
|
59
|
+
const allQuotas = await quotaService.getAllNamespaceQuotas(namespace, httpClient);
|
|
60
|
+
return {
|
|
61
|
+
content: [
|
|
62
|
+
{
|
|
63
|
+
type: "text",
|
|
64
|
+
text: formatQuotaTable(allQuotas),
|
|
65
|
+
},
|
|
66
|
+
],
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
catch (error) {
|
|
71
|
+
logger.error("Failed to get quota status", {
|
|
72
|
+
namespace,
|
|
73
|
+
resourceType,
|
|
74
|
+
error: error instanceof Error ? error.message : String(error),
|
|
75
|
+
});
|
|
76
|
+
return {
|
|
77
|
+
content: [
|
|
78
|
+
{
|
|
79
|
+
type: "text",
|
|
80
|
+
text: `Error fetching quota status: ${error instanceof Error ? error.message : String(error)}`,
|
|
81
|
+
},
|
|
82
|
+
],
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
/**
|
|
87
|
+
* Tool 2: List All Namespace Quotas
|
|
88
|
+
*/
|
|
89
|
+
server.tool("f5xc-api-list-namespace-quotas", "List all resource quotas for a namespace with current usage", {
|
|
90
|
+
namespace: z.string().describe("Namespace to list quotas for"),
|
|
91
|
+
showOnlyLimited: z
|
|
92
|
+
.boolean()
|
|
93
|
+
.optional()
|
|
94
|
+
.default(false)
|
|
95
|
+
.describe("Only show resources with quota limits (filter out unlimited)"),
|
|
96
|
+
}, async (args) => {
|
|
97
|
+
const { namespace, showOnlyLimited = false } = args;
|
|
98
|
+
if (!credentialManager) {
|
|
99
|
+
return {
|
|
100
|
+
content: [
|
|
101
|
+
{
|
|
102
|
+
type: "text",
|
|
103
|
+
text: "Quota checking requires authentication. Please configure F5XC credentials using f5xc-api-configure-auth.",
|
|
104
|
+
},
|
|
105
|
+
],
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
try {
|
|
109
|
+
const httpClient = createHttpClient(credentialManager);
|
|
110
|
+
const quotas = await quotaService.getAllNamespaceQuotas(namespace, httpClient);
|
|
111
|
+
// Filter unlimited resources if requested
|
|
112
|
+
const filtered = showOnlyLimited
|
|
113
|
+
? quotas.filter((q) => q.limits.limit > 0 && q.limits.limit < Infinity)
|
|
114
|
+
: quotas;
|
|
115
|
+
if (filtered.length === 0) {
|
|
116
|
+
return {
|
|
117
|
+
content: [
|
|
118
|
+
{
|
|
119
|
+
type: "text",
|
|
120
|
+
text: showOnlyLimited
|
|
121
|
+
? `No limited quota resources found in namespace '${namespace}'.`
|
|
122
|
+
: `No quota information available for namespace '${namespace}'.`,
|
|
123
|
+
},
|
|
124
|
+
],
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
return {
|
|
128
|
+
content: [
|
|
129
|
+
{
|
|
130
|
+
type: "text",
|
|
131
|
+
text: `Quota Status for Namespace: ${namespace}\n\n${formatQuotaTable(filtered)}`,
|
|
132
|
+
},
|
|
133
|
+
],
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
catch (error) {
|
|
137
|
+
logger.error("Failed to list namespace quotas", {
|
|
138
|
+
namespace,
|
|
139
|
+
error: error instanceof Error ? error.message : String(error),
|
|
140
|
+
});
|
|
141
|
+
return {
|
|
142
|
+
content: [
|
|
143
|
+
{
|
|
144
|
+
type: "text",
|
|
145
|
+
text: `Error listing namespace quotas: ${error instanceof Error ? error.message : String(error)}`,
|
|
146
|
+
},
|
|
147
|
+
],
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
/**
|
|
152
|
+
* Tool 3: Clear Quota Cache
|
|
153
|
+
*/
|
|
154
|
+
server.tool("f5xc-api-clear-quota-cache", "Clear the quota information cache to force fresh queries from the F5XC API", {
|
|
155
|
+
namespace: z
|
|
156
|
+
.string()
|
|
157
|
+
.optional()
|
|
158
|
+
.describe("Specific namespace to clear (optional - clears all if omitted)"),
|
|
159
|
+
}, async (args) => {
|
|
160
|
+
const { namespace } = args;
|
|
161
|
+
try {
|
|
162
|
+
if (namespace) {
|
|
163
|
+
quotaService.clearNamespaceCache(namespace);
|
|
164
|
+
return {
|
|
165
|
+
content: [
|
|
166
|
+
{
|
|
167
|
+
type: "text",
|
|
168
|
+
text: `✅ Cleared quota cache for namespace: ${namespace}`,
|
|
169
|
+
},
|
|
170
|
+
],
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
quotaService.clearCache();
|
|
175
|
+
return {
|
|
176
|
+
content: [
|
|
177
|
+
{
|
|
178
|
+
type: "text",
|
|
179
|
+
text: "✅ Cleared all quota cache entries",
|
|
180
|
+
},
|
|
181
|
+
],
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
catch (error) {
|
|
186
|
+
logger.error("Failed to clear quota cache", {
|
|
187
|
+
namespace,
|
|
188
|
+
error: error instanceof Error ? error.message : String(error),
|
|
189
|
+
});
|
|
190
|
+
return {
|
|
191
|
+
content: [
|
|
192
|
+
{
|
|
193
|
+
type: "text",
|
|
194
|
+
text: `Error clearing quota cache: ${error instanceof Error ? error.message : String(error)}`,
|
|
195
|
+
},
|
|
196
|
+
],
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
//# sourceMappingURL=quota.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quota.js","sourceRoot":"","sources":["../../../../src/server/handlers/tool-handlers/quota.ts"],"names":[],"mappings":"AAAA,sDAAsD;AAEtD;;;;;GAKG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAClE,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AAE3F,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAC;AAEnD;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAAC,MAAiB,EAAE,iBAAqC;IACzF;;OAEG;IACH,MAAM,CAAC,IAAI,CACT,2BAA2B,EAC3B,sEAAsE,EACtE;QACE,SAAS,EAAE,CAAC;aACT,MAAM,EAAE;aACR,QAAQ,CAAC,8DAA8D,CAAC;QAC3E,YAAY,EAAE,CAAC;aACZ,MAAM,EAAE;aACR,QAAQ,EAAE;aACV,QAAQ,CAAC,mEAAmE,CAAC;KACjF,EACD,KAAK,EAAE,IAAI,EAAE,EAAE;QACb,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,GAAG,IAAI,CAAC;QACzC,IAAI,CAAC,iBAAiB,EAAE,CA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AAM;4BACZ,IAAI,EAAE,mCAAmC;yBAC1C;qBACF;iBACF,CAAC;YACJ,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,CAAC,KAAK,CAAC,6BAA6B,EAAE;gBAC1C,SAAS;gBACT,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;aAC9D,CAAC,CAAC;YAEH,OAAO;gBACL,OAAO,EAAE;oBACP;wBACE,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE,+BAA+B,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE;qBAC9F;iBACF;aACF,CAAC;QACJ,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Quota API Client
|
|
3
|
+
*
|
|
4
|
+
* Handles communication with F5XC Quota APIs.
|
|
5
|
+
* Provides methods to fetch quota usage and limits from the F5XC platform.
|
|
6
|
+
*/
|
|
7
|
+
import type { HttpClient } from "@robinmordasiewicz/f5xc-auth";
|
|
8
|
+
import type { F5XCQuotaUsageResponse, F5XCQuotaLimitsResponse, QuotaResourceUsage } from "../types/quota.js";
|
|
9
|
+
/**
|
|
10
|
+
* Fetch quota usage from F5XC API
|
|
11
|
+
*
|
|
12
|
+
* @param namespace - Namespace to check quota for
|
|
13
|
+
* @param httpClient - Authenticated HTTP client
|
|
14
|
+
* @returns Quota usage response
|
|
15
|
+
*/
|
|
16
|
+
export declare function fetchQuotaUsage(namespace: string, httpClient: HttpClient): Promise<F5XCQuotaUsageResponse>;
|
|
17
|
+
/**
|
|
18
|
+
* Fetch quota limits from F5XC API
|
|
19
|
+
*
|
|
20
|
+
* @param namespace - Namespace to check quota limits for
|
|
21
|
+
* @param httpClient - Authenticated HTTP client
|
|
22
|
+
* @returns Quota limits response
|
|
23
|
+
*/
|
|
24
|
+
export declare function fetchQuotaLimits(namespace: string, httpClient: HttpClient): Promise<F5XCQuotaLimitsResponse>;
|
|
25
|
+
/**
|
|
26
|
+
* Parse quota usage response to extract resource usage
|
|
27
|
+
*
|
|
28
|
+
* @param response - F5XC quota usage API response
|
|
29
|
+
* @returns Array of resource usage information
|
|
30
|
+
*/
|
|
31
|
+
export declare function parseQuotaUsage(response: F5XCQuotaUsageResponse): QuotaResourceUsage[];
|
|
32
|
+
//# sourceMappingURL=quota-api-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quota-api-client.d.ts","sourceRoot":"","sources":["../../src/services/quota-api-client.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,KAAK,EACV,sBAAsB,EACtB,uBAAuB,EACvB,kBAAkB,EACnB,MAAM,mBAAmB,CAAC;AAG3B;;;;;;GAMG;AACH,wBAAsB,eAAe,CACnC,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,UAAU,GACrB,OAAO,CAAC,sBAAsB,CAAC,CAsBjC;AAED;;;;;;GAMG;AACH,wBAAsB,gBAAgB,CACpC,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,UAAU,GACrB,OAAO,CAAC,uBAAuB,CAAC,CAsBlC;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,sBAAsB,GAAG,kBAAkB,EAAE,CA0CtF"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
// Copyright (c) 2026 Robin Mordasiewicz. MIT License.
|
|
2
|
+
import { logger } from "../utils/logging.js";
|
|
3
|
+
/**
|
|
4
|
+
* Fetch quota usage from F5XC API
|
|
5
|
+
*
|
|
6
|
+
* @param namespace - Namespace to check quota for
|
|
7
|
+
* @param httpClient - Authenticated HTTP client
|
|
8
|
+
* @returns Quota usage response
|
|
9
|
+
*/
|
|
10
|
+
export async function fetchQuotaUsage(namespace, httpClient) {
|
|
11
|
+
try {
|
|
12
|
+
logger.debug(`Fetching quota usage for namespace: ${namespace}`);
|
|
13
|
+
// Normalize path - remove /api prefix since baseURL includes it
|
|
14
|
+
const path = `/web/namespaces/${namespace}/quota/usage`;
|
|
15
|
+
const response = await httpClient.get(path);
|
|
16
|
+
logger.debug(`Quota usage fetched successfully for namespace: ${namespace}`, {
|
|
17
|
+
statusCode: response.status,
|
|
18
|
+
});
|
|
19
|
+
return response.data;
|
|
20
|
+
}
|
|
21
|
+
catch (error) {
|
|
22
|
+
logger.error(`Failed to fetch quota usage for namespace: ${namespace}`, {
|
|
23
|
+
error: error instanceof Error ? error.message : String(error),
|
|
24
|
+
});
|
|
25
|
+
throw new Error(`Failed to fetch quota usage: ${error instanceof Error ? error.message : String(error)}`);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Fetch quota limits from F5XC API
|
|
30
|
+
*
|
|
31
|
+
* @param namespace - Namespace to check quota limits for
|
|
32
|
+
* @param httpClient - Authenticated HTTP client
|
|
33
|
+
* @returns Quota limits response
|
|
34
|
+
*/
|
|
35
|
+
export async function fetchQuotaLimits(namespace, httpClient) {
|
|
36
|
+
try {
|
|
37
|
+
logger.debug(`Fetching quota limits for namespace: ${namespace}`);
|
|
38
|
+
// Normalize path - remove /api prefix since baseURL includes it
|
|
39
|
+
const path = `/web/namespaces/${namespace}/quota/limits`;
|
|
40
|
+
const response = await httpClient.get(path);
|
|
41
|
+
logger.debug(`Quota limits fetched successfully for namespace: ${namespace}`, {
|
|
42
|
+
statusCode: response.status,
|
|
43
|
+
});
|
|
44
|
+
return response.data;
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
logger.error(`Failed to fetch quota limits for namespace: ${namespace}`, {
|
|
48
|
+
error: error instanceof Error ? error.message : String(error),
|
|
49
|
+
});
|
|
50
|
+
throw new Error(`Failed to fetch quota limits: ${error instanceof Error ? error.message : String(error)}`);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Parse quota usage response to extract resource usage
|
|
55
|
+
*
|
|
56
|
+
* @param response - F5XC quota usage API response
|
|
57
|
+
* @returns Array of resource usage information
|
|
58
|
+
*/
|
|
59
|
+
export function parseQuotaUsage(response) {
|
|
60
|
+
const usage = [];
|
|
61
|
+
// Handle quota_usage map (capitalized resource names)
|
|
62
|
+
if (response.quota_usage) {
|
|
63
|
+
for (const [resourceType, info] of Object.entries(response.quota_usage)) {
|
|
64
|
+
usage.push({
|
|
65
|
+
resourceType,
|
|
66
|
+
current: info.usage?.current ?? 0,
|
|
67
|
+
limit: info.limit?.maximum ?? Infinity,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
// Handle objects map (lowercase resource names) - prioritize this over quota_usage
|
|
72
|
+
if (response.objects) {
|
|
73
|
+
for (const [resourceType, info] of Object.entries(response.objects)) {
|
|
74
|
+
usage.push({
|
|
75
|
+
resourceType,
|
|
76
|
+
current: info.usage?.current ?? 0,
|
|
77
|
+
limit: info.limit?.maximum ?? Infinity,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
// Handle float_quota_usage (resources with decimal usage)
|
|
82
|
+
if (response.float_quota_usage) {
|
|
83
|
+
for (const [resourceType, info] of Object.entries(response.float_quota_usage)) {
|
|
84
|
+
usage.push({
|
|
85
|
+
resourceType,
|
|
86
|
+
current: info.usage ?? 0,
|
|
87
|
+
limit: Infinity, // Float quotas typically don't have limits
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
// Handle alternative array structure (fallback)
|
|
92
|
+
if (response.usage) {
|
|
93
|
+
usage.push(...response.usage);
|
|
94
|
+
}
|
|
95
|
+
return usage;
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=quota-api-client.js.map
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C,IAAI,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;YACpE,KAAK,CAAC,IAAI,CAAC;gBACT,YAAY;gBACZ,OAAO,EAAE,IAAI,CAAC,KAAK,EAAE,OAAO,IAAI,CAAC;gBACjC,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,OAAO,IAAI,QAAQ;aACvC,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,0DAA0D;IAC1D,IAAI,QAAQ,CAAC,iBAAiB,EAAE,CAAC;QAC/B,KAAK,MAAM,CAAC,YAAY,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAC,EAAE,CAAC;YAC9E,KAAK,CAAC,IAAI,CAAC;gBACT,YAAY;gBACZ,OAAO,EAAE,IAAI,CAAC,KAAK,IAAI,CAAC;gBACxB,KAAK,EAAE,QAAQ,EAAE,2CAA2C;aAC7D,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,gDAAgD;IAChD,IAAI,QAAQ,CAAC,KAAK,EAAE,CAAC;QACnB,KAAK,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAChC,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Quota Message Formatting
|
|
3
|
+
*
|
|
4
|
+
* Provides clear, actionable formatting for quota-related messages,
|
|
5
|
+
* errors, and status displays.
|
|
6
|
+
*/
|
|
7
|
+
import type { QuotaStatus, QuotaInfo, QuotaCheckResult } from "../types/quota.js";
|
|
8
|
+
/**
|
|
9
|
+
* Format quota status for display
|
|
10
|
+
*
|
|
11
|
+
* @param status - Quota status to format
|
|
12
|
+
* @returns Formatted quota status string
|
|
13
|
+
*/
|
|
14
|
+
export declare function formatQuotaStatus(status: QuotaStatus): string;
|
|
15
|
+
/**
|
|
16
|
+
* Format quota error message for blocking
|
|
17
|
+
*
|
|
18
|
+
* @param quotaCheck - Quota check result that failed
|
|
19
|
+
* @returns Formatted error message
|
|
20
|
+
*/
|
|
21
|
+
export declare function formatQuotaError(quotaCheck: QuotaCheckResult): string;
|
|
22
|
+
/**
|
|
23
|
+
* Format quota table for multiple resources
|
|
24
|
+
*
|
|
25
|
+
* @param quotas - Array of quota statuses
|
|
26
|
+
* @returns Formatted table string
|
|
27
|
+
*/
|
|
28
|
+
export declare function formatQuotaTable(quotas: QuotaStatus[]): string;
|
|
29
|
+
/**
|
|
30
|
+
* Format quota warning message for yellow zone
|
|
31
|
+
*
|
|
32
|
+
* @param quotaInfo - Quota information
|
|
33
|
+
* @param resourceType - Resource type
|
|
34
|
+
* @returns Formatted warning message
|
|
35
|
+
*/
|
|
36
|
+
export declare function formatQuotaWarning(quotaInfo: QuotaInfo, resourceType: string): string;
|
|
37
|
+
//# sourceMappingURL=quota-formatter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quota-formatter.d.ts","sourceRoot":"","sources":["../../src/services/quota-formatter.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,gBAAgB,EAAkB,MAAM,mBAAmB,CAAC;AAsDlG;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,CAe7D;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,gBAAgB,GAAG,MAAM,CAIrE;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,WAAW,EAAE,GAAG,MAAM,CA4B9D;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,GAAG,MAAM,CAErF"}
|