cloud-cost-mcp 1.1.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/LICENSE +190 -0
- package/NOTICE +15 -0
- package/README.md +232 -0
- package/dist/data/bundled/aws-pricing.json +379 -0
- package/dist/data/bundled/azure-pricing.json +367 -0
- package/dist/data/bundled/gcp-pricing.json +383 -0
- package/dist/data/bundled/oci-pricing.json +290 -0
- package/dist/data/cache.d.ts +53 -0
- package/dist/data/cache.d.ts.map +1 -0
- package/dist/data/cache.js +95 -0
- package/dist/data/cache.js.map +1 -0
- package/dist/data/fetchers/aws.d.ts +65 -0
- package/dist/data/fetchers/aws.d.ts.map +1 -0
- package/dist/data/fetchers/aws.js +298 -0
- package/dist/data/fetchers/aws.js.map +1 -0
- package/dist/data/fetchers/azure.d.ts +83 -0
- package/dist/data/fetchers/azure.d.ts.map +1 -0
- package/dist/data/fetchers/azure.js +369 -0
- package/dist/data/fetchers/azure.js.map +1 -0
- package/dist/data/fetchers/gcp.d.ts +44 -0
- package/dist/data/fetchers/gcp.d.ts.map +1 -0
- package/dist/data/fetchers/gcp.js +182 -0
- package/dist/data/fetchers/gcp.js.map +1 -0
- package/dist/data/fetchers/oci.d.ts +65 -0
- package/dist/data/fetchers/oci.d.ts.map +1 -0
- package/dist/data/fetchers/oci.js +130 -0
- package/dist/data/fetchers/oci.js.map +1 -0
- package/dist/data/loader.d.ts +56 -0
- package/dist/data/loader.d.ts.map +1 -0
- package/dist/data/loader.js +149 -0
- package/dist/data/loader.js.map +1 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +715 -0
- package/dist/index.js.map +1 -0
- package/dist/tools/calculator.d.ts +36 -0
- package/dist/tools/calculator.d.ts.map +1 -0
- package/dist/tools/calculator.js +271 -0
- package/dist/tools/calculator.js.map +1 -0
- package/dist/tools/compare.d.ts +64 -0
- package/dist/tools/compare.d.ts.map +1 -0
- package/dist/tools/compare.js +243 -0
- package/dist/tools/compare.js.map +1 -0
- package/dist/types.d.ts +171 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +6 -0
- package/dist/types.js.map +1 -0
- package/package.json +57 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cloud Cost MCP - OCI Real-Time Pricing Fetcher
|
|
3
|
+
* Uses Oracle's public pricing API (no auth required)
|
|
4
|
+
*/
|
|
5
|
+
export interface OCIProduct {
|
|
6
|
+
partNumber: string;
|
|
7
|
+
displayName: string;
|
|
8
|
+
metricName: string;
|
|
9
|
+
serviceCategory: string;
|
|
10
|
+
currencyCodeLocalizations: Array<{
|
|
11
|
+
currencyCode: string;
|
|
12
|
+
prices: Array<{
|
|
13
|
+
model: string;
|
|
14
|
+
value: number;
|
|
15
|
+
}>;
|
|
16
|
+
}>;
|
|
17
|
+
}
|
|
18
|
+
export interface OCIPricingResponse {
|
|
19
|
+
lastUpdated: string;
|
|
20
|
+
items: OCIProduct[];
|
|
21
|
+
}
|
|
22
|
+
export interface OCISimplifiedProduct {
|
|
23
|
+
partNumber: string;
|
|
24
|
+
displayName: string;
|
|
25
|
+
metricName: string;
|
|
26
|
+
serviceCategory: string;
|
|
27
|
+
unitPrice: number;
|
|
28
|
+
currency: string;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Fetch real-time pricing from Oracle's public API
|
|
32
|
+
*/
|
|
33
|
+
export declare function fetchOCIRealTimePricing(options?: {
|
|
34
|
+
currency?: string;
|
|
35
|
+
category?: string;
|
|
36
|
+
search?: string;
|
|
37
|
+
}): Promise<{
|
|
38
|
+
lastUpdated: string;
|
|
39
|
+
totalProducts: number;
|
|
40
|
+
items: OCISimplifiedProduct[];
|
|
41
|
+
}>;
|
|
42
|
+
/**
|
|
43
|
+
* Get all service categories from OCI's real-time API
|
|
44
|
+
*/
|
|
45
|
+
export declare function getOCICategories(): Promise<string[]>;
|
|
46
|
+
/**
|
|
47
|
+
* Check if OCI API is accessible
|
|
48
|
+
*/
|
|
49
|
+
export declare function checkOCIAPIStatus(): Promise<{
|
|
50
|
+
available: boolean;
|
|
51
|
+
message: string;
|
|
52
|
+
}>;
|
|
53
|
+
/**
|
|
54
|
+
* Get OCI compute products from real-time API
|
|
55
|
+
*/
|
|
56
|
+
export declare function fetchOCIComputePricing(options?: {
|
|
57
|
+
currency?: string;
|
|
58
|
+
}): Promise<OCISimplifiedProduct[]>;
|
|
59
|
+
/**
|
|
60
|
+
* Get OCI storage products from real-time API
|
|
61
|
+
*/
|
|
62
|
+
export declare function fetchOCIStoragePricing(options?: {
|
|
63
|
+
currency?: string;
|
|
64
|
+
}): Promise<OCISimplifiedProduct[]>;
|
|
65
|
+
//# sourceMappingURL=oci.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oci.d.ts","sourceRoot":"","sources":["../../../src/data/fetchers/oci.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,MAAM,WAAW,UAAU;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,MAAM,CAAC;IACxB,yBAAyB,EAAE,KAAK,CAAC;QAC/B,YAAY,EAAE,MAAM,CAAC;QACrB,MAAM,EAAE,KAAK,CAAC;YACZ,KAAK,EAAE,MAAM,CAAC;YACd,KAAK,EAAE,MAAM,CAAC;SACf,CAAC,CAAC;KACJ,CAAC,CAAC;CACJ;AAED,MAAM,WAAW,kBAAkB;IACjC,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,UAAU,EAAE,CAAC;CACrB;AAED,MAAM,WAAW,oBAAoB;IACnC,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,MAAM,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,wBAAsB,uBAAuB,CAAC,OAAO,CAAC,EAAE;IACtD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,GAAG,OAAO,CAAC;IACV,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,KAAK,EAAE,oBAAoB,EAAE,CAAC;CAC/B,CAAC,CA8DD;AAkCD;;GAEG;AACH,wBAAsB,gBAAgB,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC,CAO1D;AAED;;GAEG;AACH,wBAAsB,iBAAiB,IAAI,OAAO,CAAC;IAAE,SAAS,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,CAa1F;AAED;;GAEG;AACH,wBAAsB,sBAAsB,CAAC,OAAO,CAAC,EAAE;IACrD,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,GAAG,OAAO,CAAC,oBAAoB,EAAE,CAAC,CAMlC;AAED;;GAEG;AACH,wBAAsB,sBAAsB,CAAC,OAAO,CAAC,EAAE;IACrD,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,GAAG,OAAO,CAAC,oBAAoB,EAAE,CAAC,CAMlC"}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cloud Cost MCP - OCI Real-Time Pricing Fetcher
|
|
3
|
+
* Uses Oracle's public pricing API (no auth required)
|
|
4
|
+
*/
|
|
5
|
+
import { pricingCache, CACHE_KEYS } from '../cache.js';
|
|
6
|
+
const OCI_PRICING_API = 'https://apexapps.oracle.com/pls/apex/cetools/api/v1/products/';
|
|
7
|
+
/**
|
|
8
|
+
* Fetch real-time pricing from Oracle's public API
|
|
9
|
+
*/
|
|
10
|
+
export async function fetchOCIRealTimePricing(options) {
|
|
11
|
+
const currency = options?.currency || 'USD';
|
|
12
|
+
const cacheKey = `${CACHE_KEYS.OCI_REALTIME}_${currency}`;
|
|
13
|
+
// Check cache (5 minute TTL for real-time data)
|
|
14
|
+
const cached = pricingCache.get(cacheKey);
|
|
15
|
+
if (cached) {
|
|
16
|
+
return filterOCIData(cached, options);
|
|
17
|
+
}
|
|
18
|
+
try {
|
|
19
|
+
const response = await fetch(OCI_PRICING_API);
|
|
20
|
+
if (!response.ok) {
|
|
21
|
+
throw new Error(`OCI API request failed: ${response.status}`);
|
|
22
|
+
}
|
|
23
|
+
const data = await response.json();
|
|
24
|
+
// Transform to simpler format with selected currency
|
|
25
|
+
const items = data.items.map(item => {
|
|
26
|
+
let unitPrice = 0;
|
|
27
|
+
for (const curr of item.currencyCodeLocalizations || []) {
|
|
28
|
+
if (curr.currencyCode === currency) {
|
|
29
|
+
for (const p of curr.prices) {
|
|
30
|
+
if (p.model === 'PAY_AS_YOU_GO') {
|
|
31
|
+
unitPrice = p.value;
|
|
32
|
+
break;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
break;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return {
|
|
39
|
+
partNumber: item.partNumber,
|
|
40
|
+
displayName: item.displayName,
|
|
41
|
+
metricName: item.metricName,
|
|
42
|
+
serviceCategory: item.serviceCategory,
|
|
43
|
+
unitPrice,
|
|
44
|
+
currency,
|
|
45
|
+
};
|
|
46
|
+
});
|
|
47
|
+
const result = {
|
|
48
|
+
lastUpdated: data.lastUpdated || new Date().toISOString(),
|
|
49
|
+
totalProducts: items.length,
|
|
50
|
+
items,
|
|
51
|
+
};
|
|
52
|
+
// Cache for 5 minutes
|
|
53
|
+
pricingCache.set(cacheKey, result, 5);
|
|
54
|
+
return filterOCIData(result, options);
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
throw new Error(`Failed to fetch OCI pricing: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Filter OCI pricing data by category or search term
|
|
62
|
+
*/
|
|
63
|
+
function filterOCIData(data, options) {
|
|
64
|
+
let items = data.items;
|
|
65
|
+
if (options?.category) {
|
|
66
|
+
const cat = options.category.toLowerCase();
|
|
67
|
+
items = items.filter(item => item.serviceCategory.toLowerCase().includes(cat));
|
|
68
|
+
}
|
|
69
|
+
if (options?.search) {
|
|
70
|
+
const search = options.search.toLowerCase();
|
|
71
|
+
items = items.filter(item => item.displayName.toLowerCase().includes(search) ||
|
|
72
|
+
item.partNumber.toLowerCase().includes(search) ||
|
|
73
|
+
item.serviceCategory.toLowerCase().includes(search));
|
|
74
|
+
}
|
|
75
|
+
return {
|
|
76
|
+
...data,
|
|
77
|
+
items,
|
|
78
|
+
totalProducts: items.length,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Get all service categories from OCI's real-time API
|
|
83
|
+
*/
|
|
84
|
+
export async function getOCICategories() {
|
|
85
|
+
const data = await fetchOCIRealTimePricing();
|
|
86
|
+
const categories = new Set();
|
|
87
|
+
for (const item of data.items) {
|
|
88
|
+
categories.add(item.serviceCategory);
|
|
89
|
+
}
|
|
90
|
+
return Array.from(categories).sort();
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Check if OCI API is accessible
|
|
94
|
+
*/
|
|
95
|
+
export async function checkOCIAPIStatus() {
|
|
96
|
+
try {
|
|
97
|
+
const response = await fetch(OCI_PRICING_API);
|
|
98
|
+
if (response.ok) {
|
|
99
|
+
return { available: true, message: 'OCI Pricing API is accessible' };
|
|
100
|
+
}
|
|
101
|
+
return { available: false, message: `API returned status ${response.status}` };
|
|
102
|
+
}
|
|
103
|
+
catch (error) {
|
|
104
|
+
return {
|
|
105
|
+
available: false,
|
|
106
|
+
message: `API check failed: ${error instanceof Error ? error.message : 'Unknown error'}`,
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Get OCI compute products from real-time API
|
|
112
|
+
*/
|
|
113
|
+
export async function fetchOCIComputePricing(options) {
|
|
114
|
+
const data = await fetchOCIRealTimePricing({
|
|
115
|
+
currency: options?.currency,
|
|
116
|
+
category: 'Compute',
|
|
117
|
+
});
|
|
118
|
+
return data.items;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Get OCI storage products from real-time API
|
|
122
|
+
*/
|
|
123
|
+
export async function fetchOCIStoragePricing(options) {
|
|
124
|
+
const data = await fetchOCIRealTimePricing({
|
|
125
|
+
currency: options?.currency,
|
|
126
|
+
category: 'Storage',
|
|
127
|
+
});
|
|
128
|
+
return data.items;
|
|
129
|
+
}
|
|
130
|
+
//# sourceMappingURL=oci.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oci.js","sourceRoot":"","sources":["../../../src/data/fetchers/oci.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEvD,MAAM,eAAe,GAAG,+DAA+D,CAAC;AA8BxF;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAAC,OAI7C;IAKC,MAAM,QAAQ,GAAG,OAAO,EAAE,QAAQ,IAAI,KAAK,CAAC;IAC5C,MAAM,QAAQ,GAAG,GAAG,UAAU,CAAC,YAAY,IAAI,QAAQ,EAAE,CAAC;IAE1D,gDAAgD;IAChD,MAAM,MAAM,GAAG,YAAY,CAAC,GAAG,CAI5B,QAAQ,CAAC,CAAC;IAEb,IAAI,MAAM,EAAE,CAAC;QACX,OAAO,aAAa,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACxC,CAAC;IAED,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,eAAe,CAAC,CAAC;QAC9C,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CAAC,2BAA2B,QAAQ,CAAC,M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CP - Data Loader
|
|
3
|
+
* Loads pricing data from bundled JSON files for all cloud providers
|
|
4
|
+
*/
|
|
5
|
+
import type { CloudProvider, ProviderPricingData, AllCloudPricing, ComputeInstance, StoragePricing, EgressPricing, DataFreshnessInfo } from '../types.js';
|
|
6
|
+
/**
|
|
7
|
+
* Get pricing data for a specific provider
|
|
8
|
+
*/
|
|
9
|
+
export declare function getProviderData(provider: CloudProvider): ProviderPricingData;
|
|
10
|
+
/**
|
|
11
|
+
* Get all provider pricing data
|
|
12
|
+
*/
|
|
13
|
+
export declare function getAllProviderData(): AllCloudPricing;
|
|
14
|
+
/**
|
|
15
|
+
* Get all compute instances across all providers
|
|
16
|
+
*/
|
|
17
|
+
export declare function getAllComputeInstances(): ComputeInstance[];
|
|
18
|
+
/**
|
|
19
|
+
* Get all storage options across all providers
|
|
20
|
+
*/
|
|
21
|
+
export declare function getAllStorageOptions(): StoragePricing[];
|
|
22
|
+
/**
|
|
23
|
+
* Get egress pricing for all providers
|
|
24
|
+
*/
|
|
25
|
+
export declare function getAllEgressPricing(): EgressPricing[];
|
|
26
|
+
/**
|
|
27
|
+
* Check data freshness for all providers
|
|
28
|
+
*/
|
|
29
|
+
export declare function getDataFreshness(): DataFreshnessInfo[];
|
|
30
|
+
/**
|
|
31
|
+
* Get provider metadata
|
|
32
|
+
*/
|
|
33
|
+
export declare function getProviderMetadata(provider: CloudProvider): import("../types.js").PricingMetadata;
|
|
34
|
+
/**
|
|
35
|
+
* Refresh cache for all providers
|
|
36
|
+
*/
|
|
37
|
+
export declare function refreshAllCache(): void;
|
|
38
|
+
/**
|
|
39
|
+
* Get Kubernetes pricing for all providers
|
|
40
|
+
*/
|
|
41
|
+
export declare function getAllKubernetesPricing(): {
|
|
42
|
+
aws: import("../types.js").KubernetesPricing | undefined;
|
|
43
|
+
azure: import("../types.js").KubernetesPricing | undefined;
|
|
44
|
+
gcp: import("../types.js").KubernetesPricing | undefined;
|
|
45
|
+
oci: import("../types.js").KubernetesPricing | undefined;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Get database pricing for all providers
|
|
49
|
+
*/
|
|
50
|
+
export declare function getAllDatabasePricing(): {
|
|
51
|
+
aws: import("../types.js").DatabasePricing[];
|
|
52
|
+
azure: import("../types.js").DatabasePricing[];
|
|
53
|
+
gcp: import("../types.js").DatabasePricing[];
|
|
54
|
+
oci: import("../types.js").DatabasePricing[];
|
|
55
|
+
};
|
|
56
|
+
//# sourceMappingURL=loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../src/data/loader.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,KAAK,EACV,aAAa,EACb,mBAAmB,EACnB,eAAe,EACf,eAAe,EACf,cAAc,EACd,aAAa,EACb,iBAAiB,EAClB,MAAM,aAAa,CAAC;AAerB;;GAEG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,aAAa,GAAG,mBAAmB,CAW5E;AAED;;GAEG;AACH,wBAAgB,kBAAkB,IAAI,eAAe,CAOpD;AAED;;GAEG;AACH,wBAAgB,sBAAsB,IAAI,eAAe,EAAE,CAgB1D;AAED;;GAEG;AACH,wBAAgB,oBAAoB,IAAI,cAAc,EAAE,CAgBvD;AAED;;GAEG;AACH,wBAAgB,mBAAmB,IAAI,aAAa,EAAE,CAQrD;AAED;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,iBAAiB,EAAE,CAoBtD;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,aAAa,yCAE1D;AAED;;GAEG;AACH,wBAAgB,eAAe,IAAI,IAAI,CAEtC;AAED;;GAEG;AACH,wBAAgB,uBAAuB;;;;;EAQtC;AAED;;GAEG;AACH,wBAAgB,qBAAqB;;;;;EAQpC"}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cloud Cost MCP - Data Loader
|
|
3
|
+
* Loads pricing data from bundled JSON files for all cloud providers
|
|
4
|
+
*/
|
|
5
|
+
import { readFileSync } from 'fs';
|
|
6
|
+
import { fileURLToPath } from 'url';
|
|
7
|
+
import { dirname, join } from 'path';
|
|
8
|
+
import { pricingCache, CACHE_KEYS } from './cache.js';
|
|
9
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
10
|
+
const __dirname = dirname(__filename);
|
|
11
|
+
/**
|
|
12
|
+
* Load bundled pricing data from JSON file for a specific provider
|
|
13
|
+
*/
|
|
14
|
+
function loadBundledData(provider) {
|
|
15
|
+
const dataPath = join(__dirname, 'bundled', `${provider}-pricing.json`);
|
|
16
|
+
const rawData = readFileSync(dataPath, 'utf-8');
|
|
17
|
+
return JSON.parse(rawData);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Get pricing data for a specific provider
|
|
21
|
+
*/
|
|
22
|
+
export function getProviderData(provider) {
|
|
23
|
+
const cacheKey = `${provider.toUpperCase()}_PRICING`;
|
|
24
|
+
const cached = pricingCache.get(cacheKey);
|
|
25
|
+
if (cached) {
|
|
26
|
+
return cached;
|
|
27
|
+
}
|
|
28
|
+
const data = loadBundledData(provider);
|
|
29
|
+
pricingCache.set(cacheKey, data, 60 * 24); // Cache for 24 hours
|
|
30
|
+
return data;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Get all provider pricing data
|
|
34
|
+
*/
|
|
35
|
+
export function getAllProviderData() {
|
|
36
|
+
return {
|
|
37
|
+
aws: getProviderData('aws'),
|
|
38
|
+
azure: getProviderData('azure'),
|
|
39
|
+
gcp: getProviderData('gcp'),
|
|
40
|
+
oci: getProviderData('oci'),
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Get all compute instances across all providers
|
|
45
|
+
*/
|
|
46
|
+
export function getAllComputeInstances() {
|
|
47
|
+
const cached = pricingCache.get(CACHE_KEYS.ALL_COMPUTE);
|
|
48
|
+
if (cached) {
|
|
49
|
+
return cached;
|
|
50
|
+
}
|
|
51
|
+
const allData = getAllProviderData();
|
|
52
|
+
const instances = [
|
|
53
|
+
...allData.aws.compute,
|
|
54
|
+
...allData.azure.compute,
|
|
55
|
+
...allData.gcp.compute,
|
|
56
|
+
...allData.oci.compute,
|
|
57
|
+
];
|
|
58
|
+
pricingCache.set(CACHE_KEYS.ALL_COMPUTE, instances, 60);
|
|
59
|
+
return instances;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Get all storage options across all providers
|
|
63
|
+
*/
|
|
64
|
+
export function getAllStorageOptions() {
|
|
65
|
+
const cached = pricingCache.get(CACHE_KEYS.ALL_STORAGE);
|
|
66
|
+
if (cached) {
|
|
67
|
+
return cached;
|
|
68
|
+
}
|
|
69
|
+
const allData = getAllProviderData();
|
|
70
|
+
const storage = [
|
|
71
|
+
...allData.aws.storage,
|
|
72
|
+
...allData.azure.storage,
|
|
73
|
+
...allData.gcp.storage,
|
|
74
|
+
...allData.oci.storage,
|
|
75
|
+
];
|
|
76
|
+
pricingCache.set(CACHE_KEYS.ALL_STORAGE, storage, 60);
|
|
77
|
+
return storage;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Get egress pricing for all providers
|
|
81
|
+
*/
|
|
82
|
+
export function getAllEgressPricing() {
|
|
83
|
+
const allData = getAllProviderData();
|
|
84
|
+
return [
|
|
85
|
+
allData.aws.egress,
|
|
86
|
+
allData.azure.egress,
|
|
87
|
+
allData.gcp.egress,
|
|
88
|
+
allData.oci.egress,
|
|
89
|
+
];
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Check data freshness for all providers
|
|
93
|
+
*/
|
|
94
|
+
export function getDataFreshness() {
|
|
95
|
+
const allData = getAllProviderData();
|
|
96
|
+
const now = new Date();
|
|
97
|
+
const thirtyDaysMs = 30 * 24 * 60 * 60 * 1000;
|
|
98
|
+
return ['aws', 'azure', 'gcp', 'oci'].map(provider => {
|
|
99
|
+
const data = allData[provider];
|
|
100
|
+
const lastUpdated = new Date(data.metadata.lastUpdated);
|
|
101
|
+
const ageMs = now.getTime() - lastUpdated.getTime();
|
|
102
|
+
const ageInDays = Math.floor(ageMs / (24 * 60 * 60 * 1000));
|
|
103
|
+
return {
|
|
104
|
+
provider,
|
|
105
|
+
lastUpdated: data.metadata.lastUpdated,
|
|
106
|
+
ageInDays,
|
|
107
|
+
isStale: ageMs > thirtyDaysMs,
|
|
108
|
+
source: data.metadata.source,
|
|
109
|
+
canRefresh: provider === 'aws' || provider === 'azure' || provider === 'oci', // These have public APIs
|
|
110
|
+
};
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Get provider metadata
|
|
115
|
+
*/
|
|
116
|
+
export function getProviderMetadata(provider) {
|
|
117
|
+
return getProviderData(provider).metadata;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Refresh cache for all providers
|
|
121
|
+
*/
|
|
122
|
+
export function refreshAllCache() {
|
|
123
|
+
pricingCache.clear();
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Get Kubernetes pricing for all providers
|
|
127
|
+
*/
|
|
128
|
+
export function getAllKubernetesPricing() {
|
|
129
|
+
const allData = getAllProviderData();
|
|
130
|
+
return {
|
|
131
|
+
aws: allData.aws.kubernetes,
|
|
132
|
+
azure: allData.azure.kubernetes,
|
|
133
|
+
gcp: allData.gcp.kubernetes,
|
|
134
|
+
oci: allData.oci.kubernetes,
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Get database pricing for all providers
|
|
139
|
+
*/
|
|
140
|
+
export function getAllDatabasePricing() {
|
|
141
|
+
const allData = getAllProviderData();
|
|
142
|
+
return {
|
|
143
|
+
aws: allData.aws.database || [],
|
|
144
|
+
azure: allData.azure.database || [],
|
|
145
|
+
gcp: allData.gcp.database || [],
|
|
146
|
+
oci: allData.oci.database || [],
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
//# sourceMappingURL=loader.js.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AAO,IAAI,QAAQ,KAAK,KAAK,EAAE,yBAAyB;SACxG,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,mBAAmB,CAAC,QAAuB;IACzD,OAAO,eAAe,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC;AAC5C,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe;IAC7B,YAAY,CAAC,KAAK,EAAE,CAAC;AACvB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,uBAAuB;IACrC,MAAM,OAAO,GAAG,kBAAkB,EAAE,CAAC;IACrC,OAAO;QACL,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,UAAU;QAC3B,KAAK,EAAE,OAAO,CAAC,KAAK,CAAC,UAAU;QAC/B,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,UAAU;QAC3B,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,UAAU;KAC5B,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,qBAAqB;IACnC,MAAM,OAAO,GAAG,kBAAkB,EAAE,CAAC;IACrC,OAAO;QACL,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,QAAQ,IAAI,EAAE;QAC/B,KAAK,EAAE,OAAO,CAAC,KAAK,CAAC,QAAQ,IAAI,EAAE;QACnC,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,QAAQ,IAAI,EAAE;QAC/B,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,QAAQ,IAAI,EAAE;KAChC,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Cloud Cost MCP Server
|
|
4
|
+
* Multi-cloud pricing comparison for AWS, Azure, GCP, and OCI
|
|
5
|
+
*
|
|
6
|
+
* Copyright 2026 Jason Wilbur
|
|
7
|
+
*
|
|
8
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
9
|
+
* you may not use this file except in compliance with the License.
|
|
10
|
+
* You may obtain a copy of the License at
|
|
11
|
+
*
|
|
12
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
13
|
+
*
|
|
14
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
15
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
16
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
17
|
+
* See the License for the specific language governing permissions and
|
|
18
|
+
* limitations under the License.
|
|
19
|
+
*/
|
|
20
|
+
export {};
|
|
21
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA;;;;;;;;;;;;;;;;;GAiBG"}
|