Provides process-wide CacheEngine, TokenCounter, and MetricsCollector singletons for intelligence tools. Reuse it so new tools share one cache, one token count, and one metrics stream.
// Source: https://github.com/ooples/token-optimizer-mcp | License: MIT | Copyright 2025 ooples
// Provided via justclaw.it.com; keep this notice with the code.
/**
* Shared Singleton Instances for Intelligence Tools
*
* This module provides true singleton instances of CacheEngine, TokenCounter,
* and MetricsCollector that are shared across ALL intelligence tools.
*
* This ensures:
* - Consistent cache state across all tools
* - Unified metrics collection
* - Accurate token counting across the system
* - Memory efficiency (single instances instead of per-tool instances)
*/
import { CacheEngine } from '../../core/cache-engine.js';
import { TokenCounter } from '../../core/token-counter.js';
import { MetricsCollector } from '../../core/metrics.js';
// Singleton instances - create
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key