Skip to main content
Glama
ibproduct

Memory Cache MCP Server

by ibproduct

Memory Cache Server

A Model Context Protocol (MCP) server that reduces token consumption by efficiently caching data between language model interactions. Works with any MCP client and any language model that uses tokens.

Installation

  1. Clone the repository:

git clone git@github.com:ibproduct/ib-mcp-cache-server
cd ib-mcp-cache-server
  1. Install dependencies:

npm install
  1. Build the project:

npm run build
  1. Add to your MCP client settings:

{
  "mcpServers": {
    "memory-cache": {
      "command": "node",
      "args": ["/path/to/ib-mcp-cache-server/build/index.js"]
    }
  }
}
  1. The server will automatically start when you use your MCP client

Related MCP server: MCP Memory Server

Verifying It Works

When the server is running properly, you'll see:

  1. A message in the terminal: "Memory Cache MCP server running on stdio"

  2. Improved performance when accessing the same data multiple times

  3. No action required from you - the caching happens automatically

You can verify the server is running by:

  1. Opening your MCP client

  2. Looking for any error messages in the terminal where you started the server

  3. Performing operations that would benefit from caching (like reading the same file multiple times)

Configuration

The server can be configured through config.json or environment variables:

{
  "maxEntries": 1000,        // Maximum number of items in cache
  "maxMemory": 104857600,    // Maximum memory usage in bytes (100MB)
  "defaultTTL": 3600,        // Default time-to-live in seconds (1 hour)
  "checkInterval": 60000,    // Cleanup interval in milliseconds (1 minute)
  "statsInterval": 30000     // Stats update interval in milliseconds (30 seconds)
}

Configuration Settings Explained

  1. maxEntries (default: 1000)

    • Maximum number of items that can be stored in cache

    • Prevents cache from growing indefinitely

    • When exceeded, oldest unused items are removed first

  2. maxMemory (default: 100MB)

    • Maximum memory usage in bytes

    • Prevents excessive memory consumption

    • When exceeded, least recently used items are removed

  3. defaultTTL (default: 1 hour)

    • How long items stay in cache by default

    • Items are automatically removed after this time

    • Prevents stale data from consuming memory

  4. checkInterval (default: 1 minute)

    • How often the server checks for expired items

    • Lower values keep memory usage more accurate

    • Higher values reduce CPU usage

  5. statsInterval (default: 30 seconds)

    • How often cache statistics are updated

    • Affects accuracy of hit/miss rates

    • Helps monitor cache effectiveness

How It Reduces Token Consumption

The memory cache server reduces token consumption by automatically storing data that would otherwise need to be re-sent between you and the language model. You don't need to do anything special - the caching happens automatically when you interact with any language model through your MCP client.

Here are some examples of what gets cached:

1. File Content Caching

When reading a file multiple times:

  • First time: Full file content is read and cached

  • Subsequent times: Content is retrieved from cache instead of re-reading the file

  • Result: Fewer tokens used for repeated file operations

2. Computation Results

When performing calculations or analysis:

  • First time: Full computation is performed and results are cached

  • Subsequent times: Results are retrieved from cache if the input is the same

  • Result: Fewer tokens used for repeated computations

3. Frequently Accessed Data

When the same data is needed multiple times:

  • First time: Data is processed and cached

  • Subsequent times: Data is retrieved from cache until TTL expires

  • Result: Fewer tokens used for accessing the same information

Automatic Cache Management

The server automatically manages the caching process by:

  • Storing data when first encountered

  • Serving cached data when available

  • Removing old/unused data based on settings

  • Tracking effectiveness through statistics

Optimization Tips

1. Set Appropriate TTLs

  • Shorter for frequently changing data

  • Longer for static content

2. Adjust Memory Limits

  • Higher for more caching (more token savings)

  • Lower if memory usage is a concern

3. Monitor Cache Stats

  • High hit rate = good token savings

  • Low hit rate = adjust TTL or limits

Environment Variable Configuration

You can override config.json settings using environment variables in your MCP settings:

{
  "mcpServers": {
    "memory-cache": {
      "command": "node",
      "args": ["/path/to/build/index.js"],
      "env": {
        "MAX_ENTRIES": "5000",
        "MAX_MEMORY": "209715200",  // 200MB
        "DEFAULT_TTL": "7200",      // 2 hours
        "CHECK_INTERVAL": "120000",  // 2 minutes
        "STATS_INTERVAL": "60000"    // 1 minute
      }
    }
  }
}

You can also specify a custom config file location:

{
  "env": {
    "CONFIG_PATH": "/path/to/your/config.json"
  }
}

The server will:

  1. Look for config.json in its directory

  2. Apply any environment variable overrides

  3. Use default values if neither is specified

Testing the Cache in Practice

To see the cache in action, try these scenarios:

  1. File Reading Test

    • Read and analyze a large file

    • Ask the same question about the file again

    • The second response should be faster as the file content is cached

  2. Data Analysis Test

    • Perform analysis on some data

    • Request the same analysis again

    • The second analysis should use cached results

  3. Project Navigation Test

    • Explore a project's structure

    • Query the same files/directories again

    • Directory listings and file contents will be served from cache

The cache is working when you notice:

  • Faster responses for repeated operations

  • Consistent answers about unchanged content

  • No need to re-read files that haven't changed

Available Tools

4 tools
clear_cacheC

Clear specific or all cache entries

ParametersJSON Schema
NameRequiredDescriptionDefault
keyNoSpecific key to clear (optional - clears all if not provided)

TDQS

C2.9/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries full burden but provides minimal behavioral insight. It implies a destructive action ('clear') but doesn't disclose permanence, side effects (e.g., performance impact), permissions required, or error handling. For a mutation tool, this leaves critical gaps in understanding its behavior.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with zero waste. It's front-loaded with the core action and scope, making it easy to parse quickly. No extraneous details or repetition are present.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a destructive tool with no annotations and no output schema, the description is incomplete. It lacks information on permissions, side effects, return values, or error cases. Given the complexity of cache operations and the absence of structured safety hints, more context is needed for safe and effective use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents the optional 'key' parameter. The description adds marginal value by implying the scope ('specific or all'), but doesn't explain key formats, validation, or default behavior beyond what's in the schema. Baseline 3 is appropriate given high schema coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('clear') and resource ('cache entries'), specifying it can target 'specific or all' entries. It distinguishes from siblings like 'get_cache_stats' (read-only) and 'retrieve_data' (data access), but doesn't explicitly differentiate from 'store_data' (which might involve cache updates).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance on when to use this tool versus alternatives is provided. The description doesn't mention prerequisites (e.g., admin rights), typical scenarios (e.g., after data updates), or when to avoid it (e.g., during high traffic). It merely states what it does without contextual usage advice.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

get_cache_statsC

Get cache statistics

ParametersJSON Schema
NameRequiredDescriptionDefault

No parameters

TDQS

C2.4/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. 'Get cache statistics' implies a read-only operation, but it doesn't specify what the statistics include, whether they're real-time or aggregated, if there are rate limits, or what permissions might be required. The description lacks details on return format, potential side effects, or error conditions.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise ('Get cache statistics'), which could be efficient if it were more informative. However, it's under-specified rather than appropriately concise—it lacks necessary details about what statistics are retrieved. While it's front-loaded, it doesn't earn its place by adding sufficient value beyond the tool name.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the lack of annotations and output schema, the description is incomplete for a tool that likely returns complex statistical data. It doesn't explain what the cache statistics include, how they're formatted, or any behavioral nuances. For a tool with no structured metadata, the description should provide more context to help an agent understand its functionality and output.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 0 parameters with 100% coverage, so no parameter documentation is needed. The description doesn't add parameter information, which is appropriate here. A baseline of 4 is applied for zero-parameter tools, as the description doesn't need to compensate for any gaps in schema coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose2/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description 'Get cache statistics' is a tautology that essentially restates the tool name 'get_cache_stats' without adding meaningful specificity. It doesn't distinguish what kind of statistics are retrieved (e.g., hit rates, memory usage, entry counts) or how they differ from what might be available through sibling tools like retrieve_data.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention when it's appropriate to get cache statistics (e.g., for monitoring, debugging, or performance analysis) or how it relates to sibling tools like clear_cache, retrieve_data, or store_data. There's no indication of prerequisites or exclusions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

retrieve_dataC

Retrieve data from the cache

ParametersJSON Schema
NameRequiredDescriptionDefault
keyYesKey of the cached data to retrieve

TDQS

C2.6/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It states the tool retrieves data, implying a read-only operation, but doesn't disclose behavioral traits like error handling (e.g., what happens if the key doesn't exist), performance aspects, or any side effects. The description is minimal and lacks critical operational details.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with no wasted words, making it front-loaded and easy to parse. However, it's overly concise to the point of under-specification, which slightly reduces its effectiveness. Every word earns its place, but more detail could improve clarity.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool has no annotations and no output schema, the description is incomplete. It doesn't explain what the retrieved data looks like, potential return values, or error conditions. For a retrieval tool with one parameter, more context is needed to guide effective use, making this description inadequate.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% description coverage, with the 'key' parameter clearly documented. The description adds no additional meaning beyond the schema, such as examples of key formats or constraints. Since schema coverage is high, the baseline score of 3 is appropriate, as the description doesn't compensate but also doesn't detract.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states the action ('retrieve') and resource ('data from the cache'), which is clear but basic. It doesn't distinguish this tool from its sibling 'get_cache_stats', which might also retrieve cache-related information. The purpose is understandable but lacks specificity about what type of data or scope is involved.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'store_data' or 'clear_cache'. It doesn't mention prerequisites, such as needing data to be cached first, or context for when retrieval is appropriate versus other cache operations. Usage is implied but not explicitly stated.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

store_dataC

Store data in the cache with optional TTL

ParametersJSON Schema
NameRequiredDescriptionDefault
keyYesUnique identifier for the cached data
valueYesData to cache
ttlNoTime-to-live in seconds (optional)

TDQS

C2.9/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions 'optional TTL' which hints at expiration behavior, but doesn't describe what happens when data is stored (e.g., overwrites existing keys, requires specific permissions, has size limits, or returns confirmation). For a mutation tool with zero annotation coverage, this leaves significant gaps in understanding its behavior.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise with a single sentence that communicates the core purpose and one key feature (optional TTL). Every word earns its place with no redundancy or unnecessary elaboration. It's front-loaded with the main action and resource.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a mutation tool with no annotations and no output schema, the description is insufficiently complete. It doesn't explain what happens after storage (success/failure indicators), whether the operation is idempotent, what errors might occur, or how it interacts with sibling tools. The 100% schema coverage helps with parameters, but behavioral context is lacking.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all three parameters thoroughly. The description adds minimal value beyond the schema by mentioning 'optional TTL', but doesn't provide additional context about parameter usage, constraints, or best practices. This meets the baseline for high schema coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Store data') and target ('in the cache'), which is specific and unambiguous. It distinguishes from sibling tools like 'retrieve_data' (read vs. write) and 'clear_cache' (store vs. delete). However, it doesn't explicitly mention what type of cache or differentiate from 'get_cache_stats' beyond the basic verb distinction.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'retrieve_data' or 'clear_cache'. It mentions optional TTL but doesn't explain when TTL should be applied or any prerequisites for usage. There's no context about when this tool is appropriate versus other storage methods.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

TDQS

B3.1/5.0
Disambiguation5/5

Each tool has a clearly distinct purpose: clear_cache removes entries, get_cache_stats provides metrics, retrieve_data fetches data, and store_data saves data. There is no overlap or ambiguity between these four operations.

Naming Consistency3/5

The naming is mixed: clear_cache and get_cache_stats follow a verb_noun pattern, but retrieve_data and store_data use a verb_object pattern. While readable, this inconsistency in structure (cache vs. data as the object) deviates from a uniform convention.

Tool Count5/5

With 4 tools, this is well-scoped for a memory cache server. It covers the essential operations (store, retrieve, clear, stats) without being overly sparse or bloated, making each tool necessary and focused.

Completeness4/5

The toolset covers core cache operations: storing, retrieving, clearing, and monitoring. A minor gap is the lack of an update or delete specific entry tool, but agents can work around this by using clear_cache for deletion and store_data for updates, so it's mostly complete.

Maintenance

ActivityInactive
ResponsivenessSyncing

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

Related MCP Servers

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ibproduct/ib-mcp-cache-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server