Skip to content

Extract and generalize caching framework from studio-mcp #28

@avrabe

Description

@avrabe

Summary

Extract the sophisticated caching implementation from studio-mcp and create a generalized pulseengine-mcp-cache crate that can be used across different MCP server implementations.

Background

Studio-MCP implements a highly optimized caching system that reduces API calls by ~80% with features including:

  • Multi-layer intelligent caching with smart invalidation
  • Performance monitoring and health metrics
  • Sensitive data filtering
  • Configurable TTL policies and memory management
  • Multi-tenant support

Key components to extract:

  • plm_cache.rs (45KB) - Core PLM-specific cache implementation
  • invalidation_service.rs (17KB) - Smart cache invalidation logic
  • sensitive_filter.rs (16KB) - Security filtering for cached data
  • mod.rs (30KB) - Main cache coordination and interfaces

Implementation Tasks

Core Cache Infrastructure

  • Create new pulseengine-mcp-cache crate in workspace
  • Extract core cache storage and TTL management from studio-mcp
  • Implement trait-based abstractions for domain-specific behaviors
  • Port performance monitoring and health metrics system

Trait-Based Abstractions

  • CacheTypeDetector trait for domain-specific type detection
  • InvalidationRuleProvider trait for operation-based invalidation
  • SensitiveDataFilter trait for security filtering
  • ResourceKeyGenerator trait for key generation patterns
  • CacheMetrics trait for performance monitoring

Configuration System

  • Environment-aware configuration (dev/staging/prod)
  • Configurable TTL policies per cache type
  • Memory limits and eviction thresholds
  • Sensitive data patterns and field definitions
  • Multi-tenant isolation settings

WASM Compatibility

  • Replace tokio-specific primitives with async trait abstractions
  • Use feature flags for runtime selection (tokio vs wasm-compatible)
  • Implement WASM-compatible time and memory APIs
  • Add browser-compatible version using web-sys

Integration Points

  • Cache context middleware for MCP requests
  • Automatic cache invalidation hooks for write operations
  • Performance metrics endpoints integration
  • Health check integration with MCP server framework

Acceptance Criteria

  • New pulseengine-mcp-cache crate compiles for both native and WASM targets
  • Trait-based design allows easy customization for different domains
  • Performance comparable to original studio-mcp implementation
  • Comprehensive documentation and usage examples
  • Integration examples with existing MCP servers
  • Full test coverage including performance benchmarks

Related Issues

References

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions