@@ -32,8 +32,6 @@ import {
3232 HelperTools ,
3333 SERVER_NAME ,
3434 SERVER_VERSION ,
35- SESSION_TOOL_CALL_COUNTER_CACHE_MAX_SIZE ,
36- SESSION_TOOL_CALL_COUNTER_CACHE_TTL_SECS ,
3735 SKYFIRE_PAY_ID_PROPERTY_DESCRIPTION ,
3836 SKYFIRE_README_CONTENT ,
3937 SKYFIRE_TOOL_INSTRUCTIONS ,
@@ -48,7 +46,6 @@ import type {
4846 ActorsMcpServerOptions ,
4947 ActorTool ,
5048 HelperTool ,
51- ToolCallCounterStore ,
5249 ToolCallTelemetryProperties ,
5350 ToolEntry ,
5451} from '../types.js' ;
@@ -58,7 +55,6 @@ import { logHttpError } from '../utils/logging.js';
5855import { buildMCPResponse } from '../utils/mcp.js' ;
5956import { createProgressTracker } from '../utils/progress.js' ;
6057import { cloneToolEntry , getToolPublicFieldOnly } from '../utils/tools.js' ;
61- import { TTLLRUCache } from '../utils/ttl-lru.js' ;
6258import { getUserIdFromTokenCached } from '../utils/userid-cache.js' ;
6359import { getPackageVersion } from '../utils/version.js' ;
6460import { connectMCPClient } from './client.js' ;
@@ -81,13 +77,6 @@ export class ActorsMcpServer {
8177 // Telemetry configuration (resolved from options and env vars in setupTelemetry)
8278 private telemetryEnabled : boolean | null = null ;
8379 private telemetryEnv : TelemetryEnv = DEFAULT_TELEMETRY_ENV ;
84- private toolCallCountStore : ToolCallCounterStore | undefined ;
85-
86- // In-memory storage for tool call counters (used when toolCallCountStore is not provided)
87- private sessionToolCallCounters = new TTLLRUCache < number > (
88- SESSION_TOOL_CALL_COUNTER_CACHE_MAX_SIZE ,
89- SESSION_TOOL_CALL_COUNTER_CACHE_TTL_SECS ,
90- ) ;
9180
9281 constructor ( options : ActorsMcpServerOptions = { } ) {
9382 this . options = options ;
@@ -124,15 +113,6 @@ export class ActorsMcpServer {
124113 this . setupResourceHandlers ( ) ;
125114 }
126115
127- /**
128- * Gets and increments the tool call counter for a session.
129- * @param sessionId - The session ID
130- * @returns Promise resolving to the new counter value (after increment)
131- */
132- private async getAndIncrementToolCallCounter ( sessionId : string ) : Promise < number > {
133- return await this . toolCallCountStore ?. getAndIncrement ( sessionId ) ?? 0 ;
134- }
135-
136116 /**
137117 * Telemetry configuration with precedence: explicit options > env vars > defaults
138118 */
@@ -145,34 +125,12 @@ export class ActorsMcpServer {
145125 this . telemetryEnabled = envEnabled ?? DEFAULT_TELEMETRY_ENABLED ;
146126 }
147127
148- // Setup tool call counter store only if telemetry is enabled
128+ // Configure telemetryEnv: explicit option > env var > default ('PROD')
149129 if ( this . telemetryEnabled ) {
150- // Configure telemetryEnv: explicit option > env var > default ('PROD')
151130 this . telemetryEnv = getTelemetryEnv ( this . options . telemetry ?. env ?? process . env . TELEMETRY_ENV ) ;
152-
153- if ( this . options . telemetry ?. toolCallCountStore ) {
154- this . toolCallCountStore = this . options . telemetry . toolCallCountStore ;
155- } else {
156- this . toolCallCountStore = {
157- getAndIncrement : async ( sessionId : string ) : Promise < number > => {
158- const current = this . sessionToolCallCounters . get ( sessionId ) ?? 0 ;
159- const newValue = current + 1 ;
160- this . sessionToolCallCounters . set ( sessionId , newValue ) ;
161- return newValue ;
162- } ,
163- } ;
164- }
165131 }
166132 }
167133
168- /**
169- * Gets the tool call counter store (for testing purposes)
170- * @internal
171- */
172- public getToolCallCountStore ( ) : ToolCallCounterStore | undefined {
173- return this . toolCallCountStore ;
174- }
175-
176134 /**
177135 * Returns an array of tool names.
178136 * @returns {string[] } - An array of tool names.
@@ -808,16 +766,6 @@ Please verify the tool name and ensure the tool is properly registered.`;
808766
809767 const toolFullName = tool . type === 'actor' ? tool . actorFullName : tool . name ;
810768
811- // Get or increment tool call counter for this session
812- let toolCallNumber = 0 ;
813- if ( mcpSessionId ) {
814- try {
815- toolCallNumber = await this . getAndIncrementToolCallCounter ( mcpSessionId ) ;
816- } catch ( error ) {
817- log . warning ( 'Failed to get tool call counter' , { mcpSessionId, error : String ( error ) } ) ;
818- }
819- }
820-
821769 // Get userId from cache or fetch from API
822770 let userId : string | null = null ;
823771 if ( apifyToken ) {
@@ -839,7 +787,6 @@ Please verify the tool name and ensure the tool is properly registered.`;
839787 tool_name : toolFullName ,
840788 tool_status : 'succeeded' , // Will be updated in finally
841789 tool_exec_time_ms : 0 , // Will be calculated in finally
842- tool_call_number : toolCallNumber ,
843790 } ;
844791
845792 return { telemetryData, userId } ;
0 commit comments