@apify/actors-mcp-server 0.2.8 → 0.2.10-beta.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/dist/actor/server.d.ts +5 -2
- package/dist/actor/server.d.ts.map +1 -1
- package/dist/actor/server.js +57 -12
- package/dist/actor/server.js.map +1 -1
- package/dist/const.d.ts +5 -3
- package/dist/const.d.ts.map +1 -1
- package/dist/const.js +5 -9
- package/dist/const.js.map +1 -1
- package/dist/main.js +19 -13
- package/dist/main.js.map +1 -1
- package/dist/mcp/actors.d.ts +13 -13
- package/dist/mcp/actors.d.ts.map +1 -1
- package/dist/mcp/actors.js +33 -26
- package/dist/mcp/actors.js.map +1 -1
- package/dist/mcp/client.d.ts +2 -1
- package/dist/mcp/client.d.ts.map +1 -1
- package/dist/mcp/client.js +37 -1
- package/dist/mcp/client.js.map +1 -1
- package/dist/mcp/server.d.ts +1 -1
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js +27 -17
- package/dist/mcp/server.js.map +1 -1
- package/dist/state.d.ts +4 -0
- package/dist/state.d.ts.map +1 -0
- package/dist/state.js +4 -0
- package/dist/state.js.map +1 -0
- package/dist/tools/actor.d.ts +6 -8
- package/dist/tools/actor.d.ts.map +1 -1
- package/dist/tools/actor.js +188 -83
- package/dist/tools/actor.js.map +1 -1
- package/dist/tools/build.d.ts.map +1 -1
- package/dist/tools/build.js +2 -0
- package/dist/tools/build.js.map +1 -1
- package/dist/tools/get-actor-details.d.ts +3 -0
- package/dist/tools/get-actor-details.d.ts.map +1 -0
- package/dist/tools/get-actor-details.js +74 -0
- package/dist/tools/get-actor-details.js.map +1 -0
- package/dist/tools/helpers.d.ts +3 -3
- package/dist/tools/helpers.d.ts.map +1 -1
- package/dist/tools/helpers.js +27 -55
- package/dist/tools/helpers.js.map +1 -1
- package/dist/tools/index.d.ts +2 -2
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +22 -24
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/run_collection.js +1 -1
- package/dist/tools/store_collection.d.ts +22 -2
- package/dist/tools/store_collection.d.ts.map +1 -1
- package/dist/tools/store_collection.js +47 -43
- package/dist/tools/store_collection.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types.d.ts +65 -21
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/actor.d.ts +7 -0
- package/dist/utils/actor.d.ts.map +1 -0
- package/dist/utils/actor.js +24 -0
- package/dist/utils/actor.js.map +1 -0
- package/dist/utils/ajv.d.ts +3 -0
- package/dist/utils/ajv.d.ts.map +1 -0
- package/dist/utils/ajv.js +3 -0
- package/dist/utils/ajv.js.map +1 -0
- package/dist/utils/generic.d.ts +7 -0
- package/dist/utils/generic.d.ts.map +1 -0
- package/dist/utils/generic.js +27 -0
- package/dist/utils/generic.js.map +1 -0
- package/dist/utils/pricing-info.d.ts +13 -0
- package/dist/utils/pricing-info.d.ts.map +1 -0
- package/dist/utils/pricing-info.js +93 -0
- package/dist/utils/pricing-info.js.map +1 -0
- package/dist/utils/ttl-lru.d.ts +35 -0
- package/dist/utils/ttl-lru.d.ts.map +1 -0
- package/dist/utils/ttl-lru.js +69 -0
- package/dist/utils/ttl-lru.js.map +1 -0
- package/package.json +4 -4
package/dist/types.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
|
2
2
|
import type { RequestHandlerExtra } from '@modelcontextprotocol/sdk/shared/protocol.js';
|
|
3
3
|
import type { Notification, Request } from '@modelcontextprotocol/sdk/types.js';
|
|
4
4
|
import type { ValidateFunction } from 'ajv';
|
|
5
|
-
import type { ActorDefaultRunOptions, ActorDefinition } from 'apify-client';
|
|
5
|
+
import type { ActorDefaultRunOptions, ActorDefinition, ActorStoreList, PricingInfo } from 'apify-client';
|
|
6
6
|
import type { ACTOR_PRICING_MODEL } from './const.js';
|
|
7
7
|
import type { ActorsMcpServer } from './mcp/server.js';
|
|
8
8
|
export interface ISchemaProperties {
|
|
@@ -35,7 +35,13 @@ export type ActorDefinitionWithDesc = Omit<ActorDefinition, 'input'> & {
|
|
|
35
35
|
defaultRunOptions: ActorDefaultRunOptions;
|
|
36
36
|
input?: IActorInputSchema;
|
|
37
37
|
};
|
|
38
|
-
|
|
38
|
+
/**
|
|
39
|
+
* Pruned Actor definition type.
|
|
40
|
+
* The `id` property is set to Actor ID.
|
|
41
|
+
*/
|
|
42
|
+
export type ActorDefinitionPruned = Pick<ActorDefinitionWithDesc, 'id' | 'actorFullName' | 'buildTag' | 'readme' | 'input' | 'description' | 'defaultRunOptions'> & {
|
|
43
|
+
webServerMcpPath?: string;
|
|
44
|
+
};
|
|
39
45
|
/**
|
|
40
46
|
* Base interface for all tools in the MCP server.
|
|
41
47
|
* Contains common properties shared by all tool types.
|
|
@@ -128,23 +134,43 @@ export interface ActorStats {
|
|
|
128
134
|
totalUsers30Days: number;
|
|
129
135
|
publicActorRunStats30Days: unknown;
|
|
130
136
|
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
137
|
+
/**
|
|
138
|
+
* Price for a single event in a specific tier.
|
|
139
|
+
*/
|
|
140
|
+
export interface TieredEventPrice {
|
|
141
|
+
tieredEventPriceUsd: number;
|
|
135
142
|
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
143
|
+
/**
|
|
144
|
+
* Allowed pricing tiers for tiered event pricing.
|
|
145
|
+
*/
|
|
146
|
+
export type PricingTier = 'FREE' | 'BRONZE' | 'SILVER' | 'GOLD' | 'PLATINUM' | 'DIAMOND';
|
|
147
|
+
/**
|
|
148
|
+
* Describes a single chargeable event for an Actor.
|
|
149
|
+
* Supports either flat pricing (eventPriceUsd) or tiered pricing (eventTieredPricingUsd).
|
|
150
|
+
*/
|
|
151
|
+
export interface ActorChargeEvent {
|
|
152
|
+
eventTitle: string;
|
|
153
|
+
eventDescription: string;
|
|
154
|
+
/** Flat price per event in USD (if not tiered) */
|
|
155
|
+
eventPriceUsd?: number;
|
|
156
|
+
/** Tiered pricing per event, by tier name (FREE, BRONZE, etc.) */
|
|
157
|
+
eventTieredPricingUsd?: Partial<Record<PricingTier, TieredEventPrice>>;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Pricing per event for an Actor, supporting both flat and tiered pricing.
|
|
161
|
+
*/
|
|
162
|
+
export interface PricingPerEvent {
|
|
163
|
+
actorChargeEvents: Record<string, ActorChargeEvent>;
|
|
147
164
|
}
|
|
165
|
+
export type ExtendedPricingInfo = PricingInfo & {
|
|
166
|
+
pricePerUnitUsd?: number;
|
|
167
|
+
trialMinutes?: number;
|
|
168
|
+
unitName?: string;
|
|
169
|
+
pricingPerEvent: PricingPerEvent;
|
|
170
|
+
tieredPricing?: Partial<Record<PricingTier, {
|
|
171
|
+
tieredPricePerUnitUsd: number;
|
|
172
|
+
}>>;
|
|
173
|
+
};
|
|
148
174
|
/**
|
|
149
175
|
* Interface for internal tools - tools implemented directly in the MCP server.
|
|
150
176
|
* Extends ToolBase with a call function implementation.
|
|
@@ -168,9 +194,27 @@ export type Input = {
|
|
|
168
194
|
debugActor?: string;
|
|
169
195
|
debugActorInput?: unknown;
|
|
170
196
|
};
|
|
171
|
-
export interface ToolCacheEntry {
|
|
172
|
-
expiresAt: number;
|
|
173
|
-
tool: ToolEntry;
|
|
174
|
-
}
|
|
175
197
|
export type ActorPricingModel = (typeof ACTOR_PRICING_MODEL)[keyof typeof ACTOR_PRICING_MODEL];
|
|
198
|
+
/**
|
|
199
|
+
* Type representing the Actor information needed in order to turn it into an MCP server tool.
|
|
200
|
+
*/
|
|
201
|
+
export interface ActorInfo {
|
|
202
|
+
webServerMcpPath: string | null;
|
|
203
|
+
actorDefinitionPruned: ActorDefinitionPruned;
|
|
204
|
+
}
|
|
205
|
+
export type ExtendedActorStoreList = ActorStoreList & {
|
|
206
|
+
categories?: string[];
|
|
207
|
+
bookmarkCount?: number;
|
|
208
|
+
actorReviewRating?: number;
|
|
209
|
+
};
|
|
210
|
+
export type ActorDefinitionStorage = {
|
|
211
|
+
views: Record<string, {
|
|
212
|
+
transformation: {
|
|
213
|
+
fields?: string[];
|
|
214
|
+
};
|
|
215
|
+
display: {
|
|
216
|
+
properties: Record<string, object>;
|
|
217
|
+
};
|
|
218
|
+
}>;
|
|
219
|
+
};
|
|
176
220
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACxE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,8CAA8C,CAAC;AACxF,OAAO,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,oCAAoC,CAAC;AAChF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,KAAK,EAAE,sBAAsB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACxE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,8CAA8C,CAAC;AACxF,OAAO,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,oCAAoC,CAAC;AAChF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,KAAK,EAAE,sBAAsB,EAAE,eAAe,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEzG,OAAO,KAAK,EAAE,mBAAmB,EAAE,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.js';
|
|
2
|
+
/**
|
|
3
|
+
* Returns an array of all field names mentioned in the display.properties
|
|
4
|
+
* of all views in the given ActorDefinitionStorage object.
|
|
5
|
+
*/
|
|
6
|
+
export declare function getActorDefinitionStorageFieldNames(storage: ActorDefinitionStorage | object): string[];
|
|
7
|
+
//# sourceMappingURL=actor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"actor.d.ts","sourceRoot":"","sources":["../../src/utils/actor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAE1D;;;GAGG;AACH,wBAAgB,mCAAmC,CAAC,OAAO,EAAE,sBAAsB,GAAG,MAAM,GAAG,MAAM,EAAE,CAiBtG"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns an array of all field names mentioned in the display.properties
|
|
3
|
+
* of all views in the given ActorDefinitionStorage object.
|
|
4
|
+
*/
|
|
5
|
+
export function getActorDefinitionStorageFieldNames(storage) {
|
|
6
|
+
const fieldSet = new Set();
|
|
7
|
+
if ('views' in storage && typeof storage.views === 'object' && storage.views !== null) {
|
|
8
|
+
for (const view of Object.values(storage.views)) {
|
|
9
|
+
// Collect from display.properties
|
|
10
|
+
if (view.display && view.display.properties) {
|
|
11
|
+
Object.keys(view.display.properties).forEach((field) => fieldSet.add(field));
|
|
12
|
+
}
|
|
13
|
+
// Collect from transformation.fields
|
|
14
|
+
if (view.transformation && Array.isArray(view.transformation.fields)) {
|
|
15
|
+
view.transformation.fields.forEach((field) => {
|
|
16
|
+
if (typeof field === 'string')
|
|
17
|
+
fieldSet.add(field);
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return Array.from(fieldSet);
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=actor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"actor.js","sourceRoot":"","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0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ajv.js","sourceRoot":"","sources":["../../src/utils/ajv.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,KAAK,CAAC;AAEtB,MAAM,CAAC,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Recursively gets the value in a nested object for each key in the keys array.
|
|
3
|
+
* Each key can be a dot-separated path (e.g. 'a.b.c').
|
|
4
|
+
* Returns an object mapping each key to its resolved value (or undefined if not found).
|
|
5
|
+
*/
|
|
6
|
+
export declare function getValuesByDotKeys<T extends object>(obj: T, keys: string[]): Record<string, unknown>;
|
|
7
|
+
//# sourceMappingURL=generic.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generic.d.ts","sourceRoot":"","sources":["../../src/utils/generic.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,SAAS,MAAM,EAAE,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAqBpG"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Recursively gets the value in a nested object for each key in the keys array.
|
|
3
|
+
* Each key can be a dot-separated path (e.g. 'a.b.c').
|
|
4
|
+
* Returns an object mapping each key to its resolved value (or undefined if not found).
|
|
5
|
+
*/
|
|
6
|
+
export function getValuesByDotKeys(obj, keys) {
|
|
7
|
+
const result = {};
|
|
8
|
+
for (const key of keys) {
|
|
9
|
+
const path = key.split('.');
|
|
10
|
+
let current = obj;
|
|
11
|
+
for (const segment of path) {
|
|
12
|
+
if (current !== null
|
|
13
|
+
&& typeof current === 'object'
|
|
14
|
+
&& Object.prototype.hasOwnProperty.call(current, segment)) {
|
|
15
|
+
// Use index signature to avoid 'any' and type errors
|
|
16
|
+
current = current[segment];
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
current = undefined;
|
|
20
|
+
break;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
result[key] = current;
|
|
24
|
+
}
|
|
25
|
+
return result;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=generic.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generic.js","sourceRoot":"","sources":["../../src/utils/generic.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAmB,GAAM,EAAE,IAAc;IACvE,MAAM,MAAM,GAA4B,EAAE,CAAC;IAC3C,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACrB,MAAM,IAAI,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC5B,IAAI,OAAO,GAAY,GAAG,CAAC;QAC3B,KAAK,MAAM,OAAO,IAAI,IAAI,EAAE,CAAC;YACzB,IACI,OAAO,KAAK,IAAI;mBACb,OAAO,OAAO,KAAK,QAAQ;mBAC3B,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,EAC3D,CAAC;gBACC,qDAAqD;gBACrD,OAAO,GAAI,OAAmC,CAAC,OAAO,CAAC,CAAC;YAC5D,CAAC;iBAAM,CAAC;gBACJ,OAAO,GAAG,SAAS,CAAC;gBACpB,MAAM;YACV,CAAC;QACL,CAAC;QACD,MAAM,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC;IAC1B,CAAC;IACD,OAAO,MAAM,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ActorRunPricingInfo } from 'apify-client';
|
|
2
|
+
import type { ExtendedPricingInfo } from '../types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Returns the most recent valid pricing information from a list of pricing infos,
|
|
5
|
+
* based on the provided current date.
|
|
6
|
+
*
|
|
7
|
+
* Filters out pricing infos that have a `startedAt` date in the future or missing,
|
|
8
|
+
* then sorts the remaining infos by `startedAt` in descending order (most recent first).
|
|
9
|
+
* Returns the most recent valid pricing info, or `null` if none are valid.
|
|
10
|
+
*/
|
|
11
|
+
export declare function getCurrentPricingInfo(pricingInfos: ActorRunPricingInfo[], now: Date): ActorRunPricingInfo | null;
|
|
12
|
+
export declare function pricingInfoToString(pricingInfo: ExtendedPricingInfo | null): string;
|
|
13
|
+
//# sourceMappingURL=pricing-info.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pricing-info.d.ts","sourceRoot":"","sources":["../../src/utils/pricing-info.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAGxD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAEvD;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAC,YAAY,EAAE,mBAAmB,EAAE,EAAE,GAAG,EAAE,IAAI,GAAG,mBAAmB,GAAG,IAAI,CAmBhH;AA+BD,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,mBAAmB,GAAG,IAAI,GAAG,MAAM,CAgCnF"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { ACTOR_PRICING_MODEL } from '../const.js';
|
|
2
|
+
/**
|
|
3
|
+
* Returns the most recent valid pricing information from a list of pricing infos,
|
|
4
|
+
* based on the provided current date.
|
|
5
|
+
*
|
|
6
|
+
* Filters out pricing infos that have a `startedAt` date in the future or missing,
|
|
7
|
+
* then sorts the remaining infos by `startedAt` in descending order (most recent first).
|
|
8
|
+
* Returns the most recent valid pricing info, or `null` if none are valid.
|
|
9
|
+
*/
|
|
10
|
+
export function getCurrentPricingInfo(pricingInfos, now) {
|
|
11
|
+
// Filter out all future dates and those without a startedAt date
|
|
12
|
+
const validPricingInfos = pricingInfos.filter((info) => {
|
|
13
|
+
if (!info.startedAt)
|
|
14
|
+
return false;
|
|
15
|
+
const startedAt = new Date(info.startedAt);
|
|
16
|
+
return startedAt <= now;
|
|
17
|
+
});
|
|
18
|
+
// Sort and return the most recent pricing info
|
|
19
|
+
validPricingInfos.sort((a, b) => {
|
|
20
|
+
const aDate = new Date(a.startedAt || 0);
|
|
21
|
+
const bDate = new Date(b.startedAt || 0);
|
|
22
|
+
return bDate.getTime() - aDate.getTime(); // Sort descending
|
|
23
|
+
});
|
|
24
|
+
if (validPricingInfos.length > 0) {
|
|
25
|
+
return validPricingInfos[0]; // Return the most recent pricing info
|
|
26
|
+
}
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
function convertMinutesToGreatestUnit(minutes) {
|
|
30
|
+
if (minutes < 60) {
|
|
31
|
+
return { value: minutes, unit: 'minutes' };
|
|
32
|
+
}
|
|
33
|
+
if (minutes < 60 * 24) { // Less than 24 hours
|
|
34
|
+
return { value: Math.floor(minutes / 60), unit: 'hours' };
|
|
35
|
+
} // 24 hours or more
|
|
36
|
+
return { value: Math.floor(minutes / (60 * 24)), unit: 'days' };
|
|
37
|
+
}
|
|
38
|
+
function payPerEventPricingToString(pricingPerEvent) {
|
|
39
|
+
if (!pricingPerEvent || !pricingPerEvent.actorChargeEvents)
|
|
40
|
+
return 'No event pricing information available.';
|
|
41
|
+
const eventStrings = [];
|
|
42
|
+
for (const event of Object.values(pricingPerEvent.actorChargeEvents)) {
|
|
43
|
+
let eventStr = `- ${event.eventTitle}: ${event.eventDescription} `;
|
|
44
|
+
if (typeof event.eventPriceUsd === 'number') {
|
|
45
|
+
eventStr += `(Flat price: $${event.eventPriceUsd} per event)`;
|
|
46
|
+
}
|
|
47
|
+
else if (event.eventTieredPricingUsd) {
|
|
48
|
+
const tiers = Object.entries(event.eventTieredPricingUsd)
|
|
49
|
+
.map(([tier, price]) => `${tier}: $${price.tieredEventPriceUsd}`)
|
|
50
|
+
.join(', ');
|
|
51
|
+
eventStr += `(Tiered pricing: ${tiers} per event)`;
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
eventStr += '(No price info)';
|
|
55
|
+
}
|
|
56
|
+
eventStrings.push(eventStr);
|
|
57
|
+
}
|
|
58
|
+
return `This Actor charges per event as follows:\n${eventStrings.join('\n')}`;
|
|
59
|
+
}
|
|
60
|
+
export function pricingInfoToString(pricingInfo) {
|
|
61
|
+
// If there is no pricing infos entries the Actor is free to use
|
|
62
|
+
// based on https://github.com/apify/apify-core/blob/058044945f242387dde2422b8f1bef395110a1bf/src/packages/actor/src/paid_actors/paid_actors_common.ts#L691
|
|
63
|
+
if (pricingInfo === null || pricingInfo.pricingModel === ACTOR_PRICING_MODEL.FREE) {
|
|
64
|
+
return 'This Actor is free to use; the user only pays for the computing resources consumed by the Actor.';
|
|
65
|
+
}
|
|
66
|
+
if (pricingInfo.pricingModel === ACTOR_PRICING_MODEL.PRICE_PER_DATASET_ITEM) {
|
|
67
|
+
const customUnitName = pricingInfo.unitName !== 'result' ? pricingInfo.unitName : '';
|
|
68
|
+
// Handle tiered pricing if present
|
|
69
|
+
if (pricingInfo.tieredPricing && Object.keys(pricingInfo.tieredPricing).length > 0) {
|
|
70
|
+
const tiers = Object.entries(pricingInfo.tieredPricing)
|
|
71
|
+
.map(([tier, obj]) => `${tier}: $${obj.tieredPricePerUnitUsd * 1000} per 1000 ${customUnitName || 'results'}`)
|
|
72
|
+
.join(', ');
|
|
73
|
+
return `This Actor charges per results${customUnitName ? ` (in this case named ${customUnitName})` : ''}; tiered pricing per 1000 ${customUnitName || 'results'}: ${tiers}.`;
|
|
74
|
+
}
|
|
75
|
+
return `This Actor charges per results${customUnitName ? ` (in this case named ${customUnitName})` : ''}; the price per 1000 ${customUnitName || 'results'} is ${pricingInfo.pricePerUnitUsd * 1000} USD.`;
|
|
76
|
+
}
|
|
77
|
+
if (pricingInfo.pricingModel === ACTOR_PRICING_MODEL.FLAT_PRICE_PER_MONTH) {
|
|
78
|
+
const { value, unit } = convertMinutesToGreatestUnit(pricingInfo.trialMinutes || 0);
|
|
79
|
+
// Handle tiered pricing if present
|
|
80
|
+
if (pricingInfo.tieredPricing && Object.keys(pricingInfo.tieredPricing).length > 0) {
|
|
81
|
+
const tiers = Object.entries(pricingInfo.tieredPricing)
|
|
82
|
+
.map(([tier, obj]) => `${tier}: $${obj.tieredPricePerUnitUsd} per month`)
|
|
83
|
+
.join(', ');
|
|
84
|
+
return `This Actor is rental and thus has tiered pricing per month: ${tiers}, with a trial period of ${value} ${unit}.`;
|
|
85
|
+
}
|
|
86
|
+
return `This Actor is rental and thus has a flat price of ${pricingInfo.pricePerUnitUsd} USD per month, with a trial period of ${value} ${unit}.`;
|
|
87
|
+
}
|
|
88
|
+
if (pricingInfo.pricingModel === ACTOR_PRICING_MODEL.PAY_PER_EVENT) {
|
|
89
|
+
return payPerEventPricingToString(pricingInfo.pricingPerEvent);
|
|
90
|
+
}
|
|
91
|
+
return 'unknown';
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=pricing-info.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pricing-info.js","sourceRoot":"","sources":["../../src/utils/pricing-info.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAGlD;;;;;;;GAOG;AACH,MAAM,UAAU,qBAAqB,CAAC,YAAmC,EAAE,GAAS;IAChF,iEAAiE;IACjE,MAAM,iBAAiB,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE;QACnD,IAAI,CAAC,IAAI,CAAC,SAAS;YAAE,OAAO,KAAK,CAAC;QAClC,MAAM,SAAS,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAC3C,OAAO,SAAS,IAAI,GAAG,CAAC;IAC5B,CAAC,CAAC,CAAC;IAEH,+CAA+C;IAC/C,iBAAiB,CAAC,IAAI,CAAC,CAA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AA4B,KAAK,IAAI,IAAI,GAAG,CAAC;QAC5H,CAAC;QACD,OAAO,qDAAqD,WAAW,CAAC,eAAe,0CAA0C,KAAK,IAAI,IAAI,GAAG,CAAC;IACtJ,CAAC;IACD,IAAI,WAAW,CAAC,YAAY,KAAK,mBAAmB,CAAC,aAAa,EAAE,CAAC;QACjE,OAAO,0BAA0B,CAAC,WAAW,CAAC,eAAe,CAAC,CAAC;IACnE,CAAC;IACD,OAAO,SAAS,CAAC;AACrB,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LRU cache with TTL (time-to-live) for storing entries.
|
|
3
|
+
*
|
|
4
|
+
* This class wraps an LRU cache and adds a time-to-live (TTL) expiration to each entry.
|
|
5
|
+
* When an entry is accessed, it is checked for expiration and removed if expired.
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* ```typescript
|
|
9
|
+
* const cache = new TTLLRUCache<string>(100, 60); // 100 items, 60 seconds TTL
|
|
10
|
+
* cache.set('key', 'value');
|
|
11
|
+
* const value = cache.get('key');
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
export declare class TTLLRUCache<T> {
|
|
15
|
+
private readonly cache;
|
|
16
|
+
private readonly ttlMillis;
|
|
17
|
+
/**
|
|
18
|
+
* @param maxLength Maximum number of items in the cache (LRU eviction)
|
|
19
|
+
* @param ttlSecs Time-to-live for each entry, in seconds
|
|
20
|
+
*/
|
|
21
|
+
constructor(maxLength: number, ttlSecs: number);
|
|
22
|
+
/**
|
|
23
|
+
* Set a value in the cache with the given key. If the key exists, it is updated and TTL is reset.
|
|
24
|
+
* @param key Cache key
|
|
25
|
+
* @param value Value to store
|
|
26
|
+
*/
|
|
27
|
+
set(key: string, value: T): void;
|
|
28
|
+
/**
|
|
29
|
+
* Get a value from the cache by key. Returns null if not found or expired.
|
|
30
|
+
* @param key Cache key
|
|
31
|
+
* @returns The value if present and not expired, otherwise null
|
|
32
|
+
*/
|
|
33
|
+
get(key: string): T | null;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=ttl-lru.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ttl-lru.d.ts","sourceRoot":"","sources":["../../src/utils/ttl-lru.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;GAYG;AACH,qBAAa,WAAW,CAAC,CAAC;IAEtB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAGnB;IAGH,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IAEnC;;;OAGG;gBACS,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;IAU9C;;;;OAIG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;IAWzB;;;;OAIG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC,GAAG,IAAI;CAQ7B"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { LruCache } from '@apify/datastructures';
|
|
2
|
+
/**
|
|
3
|
+
* LRU cache with TTL (time-to-live) for storing entries.
|
|
4
|
+
*
|
|
5
|
+
* This class wraps an LRU cache and adds a time-to-live (TTL) expiration to each entry.
|
|
6
|
+
* When an entry is accessed, it is checked for expiration and removed if expired.
|
|
7
|
+
*
|
|
8
|
+
* Usage:
|
|
9
|
+
* ```typescript
|
|
10
|
+
* const cache = new TTLLRUCache<string>(100, 60); // 100 items, 60 seconds TTL
|
|
11
|
+
* cache.set('key', 'value');
|
|
12
|
+
* const value = cache.get('key');
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export class TTLLRUCache {
|
|
16
|
+
/**
|
|
17
|
+
* @param maxLength Maximum number of items in the cache (LRU eviction)
|
|
18
|
+
* @param ttlSecs Time-to-live for each entry, in seconds
|
|
19
|
+
*/
|
|
20
|
+
constructor(maxLength, ttlSecs) {
|
|
21
|
+
// Internal LRU cache storing value and expiration timestamp for each entry
|
|
22
|
+
Object.defineProperty(this, "cache", {
|
|
23
|
+
enumerable: true,
|
|
24
|
+
configurable: true,
|
|
25
|
+
writable: true,
|
|
26
|
+
value: void 0
|
|
27
|
+
});
|
|
28
|
+
// Time-to-live in milliseconds for each entry
|
|
29
|
+
Object.defineProperty(this, "ttlMillis", {
|
|
30
|
+
enumerable: true,
|
|
31
|
+
configurable: true,
|
|
32
|
+
writable: true,
|
|
33
|
+
value: void 0
|
|
34
|
+
});
|
|
35
|
+
this.ttlMillis = ttlSecs * 1000;
|
|
36
|
+
this.cache = new LruCache({
|
|
37
|
+
maxLength,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Set a value in the cache with the given key. If the key exists, it is updated and TTL is reset.
|
|
42
|
+
* @param key Cache key
|
|
43
|
+
* @param value Value to store
|
|
44
|
+
*/
|
|
45
|
+
set(key, value) {
|
|
46
|
+
// If the key already exists, remove it to update the value and reset TTL
|
|
47
|
+
if (this.cache.get(key)) {
|
|
48
|
+
this.cache.remove(key);
|
|
49
|
+
}
|
|
50
|
+
this.cache.add(key, {
|
|
51
|
+
value,
|
|
52
|
+
expiresAt: Date.now() + this.ttlMillis,
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Get a value from the cache by key. Returns null if not found or expired.
|
|
57
|
+
* @param key Cache key
|
|
58
|
+
* @returns The value if present and not expired, otherwise null
|
|
59
|
+
*/
|
|
60
|
+
get(key) {
|
|
61
|
+
const entry = this.cache.get(key);
|
|
62
|
+
if (entry && entry.expiresAt > Date.now()) {
|
|
63
|
+
return entry.value;
|
|
64
|
+
}
|
|
65
|
+
this.cache.remove(key); // Remove expired entry
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=ttl-lru.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ttl-lru.js","sourceRoot":"","sources":["../../src/utils/ttl-lru.ts"],"names":[],"mappings":"A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.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Model Context Protocol Server for Apify",
|
|
6
6
|
"engines": {
|
|
@@ -32,10 +32,10 @@
|
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@apify/datastructures": "^2.0.3",
|
|
34
34
|
"@apify/log": "^2.5.16",
|
|
35
|
-
"@modelcontextprotocol/sdk": "^1.
|
|
35
|
+
"@modelcontextprotocol/sdk": "^1.13.2",
|
|
36
36
|
"ajv": "^8.17.1",
|
|
37
|
-
"apify": "^3.4.
|
|
38
|
-
"apify-client": "^2.12.
|
|
37
|
+
"apify": "^3.4.2",
|
|
38
|
+
"apify-client": "^2.12.6",
|
|
39
39
|
"express": "^4.21.2",
|
|
40
40
|
"yargs": "^17.7.2",
|
|
41
41
|
"zod": "^3.24.1",
|