# Prompt Cache Hit Calculator AI Agent Connect

> Analyze prompt prefix caching performance, efficiency, and cost savings.

## Overview
- **Category:** analytics
- **Price:** Free
- **Endpoint:** https://edge.vinkius.com/vk_preview_RtPMDdAVBYJh5FuqI4pTMxgwoz4sOxqI1BctS0MI/ai-agent-connect
- **Tags:** caching, tokens, cost-analysis, prompt-engineering, performance

## Description

This MCP server provides deterministic analysis of prompt prefix caching strategies. It allows AI agents to evaluate how effectively cached prefixes are being utilized to reduce latency and costs. Use `analyze_cache_performance` to calculate hit rates and monetary savings, `evaluate_cache_optimization` to determine the ideal cache size based on prefix sharing, and `inspect_cache_dynamics` to monitor eviction rates and specific prefix match lengths.

## Tools

### analyze_cache_performance
Provides a high-level overview of how well the cache is performing regarding hits, efficiency, and cost savings

### evaluate_cache_optimization
Identifies the ideal cache capacity and the degree of prefix overlap to guide infrastructure scaling

### inspect_cache_dynamics
Investigates the frequency of cache turnover and the specific overlap between individual requests

## Prompt Examples

**Prompt:** 
```
Analyze my cache performance with a cache size of 1000 tokens and a cost of 0.00002 per token.
```

**Response:** 
```
The cache hit rate is 0.45, with a cache efficiency of 0.25. The total cache hit value saved is $0.12.
```

**Prompt:** 
```
What is the optimal cache size for these request logs?
```

**Response:** 
```
The optimal cache size is 1540 tokens, with a prefix sharing ratio of 0.65.
```

**Prompt:** 
```
Check the cache eviction rate for a 5000 token cache.
```

**Response:** 
```
The cache eviction rate is 0.02, indicating a stable cache with low turnover.
```

## Frequently Asked Questions

**How do I calculate the monetary value of my cache hits?**
You can use the `analyze_cache_performance` tool. By providing the `costPerToken` parameter, the tool calculates the total `cacheHitValue` based on the tokens saved during successful hits.

**What determines the optimal cache size?**
The `evaluate_cache_optimization` tool determines the optimal cache size by calculating the 95th percentile of prefix lengths from your request logs.

**How can I see if my cache is evicting too many items?**
Use the `inspect_cache_dynamics` tool. It provides the `cacheEvictionRate`, which is the number of evictions divided by the total cache capacity.
