Skip to main content
Glama
jdug-jadodev

mcp-context-cache

by jdug-jadodev

mcp-context-cache

Caché de contexto para agentes de IA. Carga, almacena y entrega el contexto de archivos del proyecto de forma eficiente usando el Protocolo de Contexto de Modelos (MCP).


¿Por qué usarlo?

Sin este servidor

Con este servidor

El agente llama a read_file una vez por archivo

Una sola llamada devuelve todo el proyecto

30 archivos = 30 tool calls

30 archivos = 1 tool call


Related MCP server: MCP Filesystem Server

Características

  • Caché LRU — Los archivos se hashean con SHA-256 y se almacenan en memoria. Los archivos sin cambios nunca se vuelven a leer del disco.

  • Pipeline de seguridad — 8 pasos de validación bloquean archivos sensibles (.env, *.pem, credenciales, binarios, etc.).

  • 3 herramientas MCP — Carga de contexto flexible: por lista de archivos, directorio o archivo de configuración.

  • Truncado inteligente — Respeta límites de tamaño configurables y reporta los archivos omitidos.

  • Orden alfabético — Salida determinista para respuestas estables del agente de IA.


Instalación

Instalación global (recomendada)

npm install -g mcp-context-cache

Con pnpm:

pnpm add -g mcp-context-cache

Verificar la instalación:

mcp-context-cache --version

Sin instalar

npx mcp-context-cache --init

Guía de configuración

Paso 1 — Registra el servidor MCP en tu IDE

VS Code

Opción A — Global (todos los workspaces): Edita ~/.config/Code/User/mcp.json en macOS/Linux o %APPDATA%\Code\User\mcp.json en Windows:

{
  "servers": {
    "mcp-context-cache": {
      "type": "stdio",
      "command": "mcp-context-cache"
    }
  }
}

Opción B — Por workspace: Crea .vscode/mcp.json en la raíz del proyecto:

{
  "servers": {
    "mcp-context-cache": {
      "type": "stdio",
      "command": "mcp-context-cache"
    }
  }
}

JetBrains (IntelliJ, WebStorm, PyCharm, etc.)

Crea .mcp.json en la raíz del proyecto:

{
  "mcpServers": {
    "mcp-context-cache": {
      "command": "mcp-context-cache"
    }
  }
}

JetBrains AI Assistant detecta .mcp.json automáticamente desde la versión 2024.3.


Paso 2 — Instrucciones al agente para preferir las herramientas MCP

Los agentes de IA usan sus herramientas nativas por defecto. Debes indicarles explícitamente que prefieran las del servidor MCP.

VS Code — Instrucciones globales

Crea el archivo ~/.config/Code/User/prompts/mcp-context-cache.instructions.md:

---
applyTo: "**"
---

# Carga de contexto — mcp-context-cache

## HERRAMIENTAS PROHIBIDAS

NUNCA uses estas herramientas para leer archivos del proyecto:

- `read_file`
- `list_dir`
- `file_search`
- `semantic_search`
- `grep_search`

Solo se permite usarlas si TODAS las herramientas MCP fallan con error.

## PROCEDIMIENTO OBLIGATORIO

Antes de cualquier otra llamada al inicio de una tarea:

1. Verifica si el workspace contiene un archivo `contextcache.json`.
2. Si existe → llama a `get_context_from_config` con `{ "projectRoot": "<ruta-absoluta>" }`.
3. Si no existe y necesitas un directorio → llama a `get_directory_context`.
4. Para archivos específicos → llama a `get_project_context` con un array `paths`.
5. Solo usa `read_file` si las tres herramientas MCP devuelven error.

## Referencia de herramientas

- `get_context_from_config`  →  `{ "projectRoot": "<ruta-absoluta>" }`
- `get_project_context`      →  `{ "paths": ["rel/ruta.ts", ...], "projectRoot": "<ruta-absoluta>" }`
- `get_directory_context`    →  `{ "rootPath": "<ruta-absoluta-al-directorio>" }`

El frontmatter applyTo: "**" le indica a VS Code Copilot que inyecte este archivo en cada conversación.

VS Code — Por proyecto

Crea .github/copilot-instructions.md en la raíz del proyecto:

## PROHIBIDO — no uses estas herramientas para leer archivos

NUNCA llames a `read_file`, `list_dir`, `file_search`, `semantic_search` o `grep_search`.
Solo recurre a ellas si todas las herramientas MCP devuelven error.

## PRIMER PASO OBLIGATORIO

Este proyecto tiene un `contextcache.json`. Llama a `get_context_from_config` antes de cualquier otra herramienta:

{ "projectRoot": "<ruta-absoluta-a-este-repo>" }

JetBrains — Prompt de sistema global (AI Assistant)

Ve a Settings → Tools → AI Assistant → System prompt y agrega:

Al trabajar en cualquier proyecto que tenga un archivo contextcache.json, llama a la herramienta MCP
get_context_from_config con la ruta raíz del proyecto antes de leer archivos individuales.
Prefiere get_directory_context sobre leer archivos uno por uno, y get_project_context
sobre múltiples llamadas a read_file.

Paso 3 — Inicializa tu proyecto

Ejecuta en la raíz del proyecto para generar un contextcache.json:

npx @jdug-jadodev/mcp-context-cache --init

O créalo manualmente:

{
  "modules": [
    {
      "name": "src",
      "path": "src",
      "includeInstructions": true,
      "excludePatterns": ["**/*.test.ts", "**/*.spec.ts", "**/__mocks__/**"]
    }
  ],
  "globalInstructions": ".github/copilot-instructions.md",
  "maxTotalSizeKb": 2048,
  "cache": {
    "maxEntries": 5000,
    "maxEntrySizeKb": 1024
  },
  "security": {
    "allowedPaths": ["./"],
    "deniedPaths": ["./node_modules", "./dist", "./secrets", "./.git"],
    "deniedFiles": [".env", "credentials.json", "*.pem"],
    "maxFileSizeKb": 500,
    "allowedExtensions": [".ts", ".tsx", ".js", ".jsx", ".json", ".md", ".yaml", ".yml"]
  }
}

Referencia de campos

Campo

Descripción

modules

Lista de directorios a empaquetar

modules[].path

Ruta relativa a la raíz del proyecto

modules[].includeInstructions

Si es true, antepone el contenido de globalInstructions

modules[].excludePatterns

Patrones glob a omitir

globalInstructions

Ruta al Markdown incluido al inicio del bundle cuando includeInstructions: true

maxTotalSizeKb

Tamaño máximo total del bundle en KB

cache.maxEntries

Número máximo de archivos en la caché LRU

cache.maxEntrySizeKb

Tamaño máximo de archivo individual en caché

security.allowedPaths

Rutas desde las que el servidor puede leer

security.deniedPaths

Rutas siempre bloqueadas

security.deniedFiles

Patrones de nombres de archivo siempre bloqueados

security.maxFileSizeKb

Tamaño máximo de archivo a servir

security.allowedExtensions

Lista blanca de extensiones de archivo


Herramientas MCP

get_context_from_config

Carga el contexto completo del proyecto definido en contextcache.json. Úsala siempre primero.

{ "projectRoot": "/ruta/absoluta/al/proyecto" }

Parámetro

Tipo

Requerido

Descripción

projectRoot

string

Directorio que contiene contextcache.json

configPath

string

no

Ruta explícita a contextcache.json


get_directory_context

Carga recursivamente todos los archivos de un directorio.

{ "rootPath": "/ruta/absoluta/al/directorio", "excludePatterns": ["*.test.ts"] }

Parámetro

Tipo

Requerido

Descripción

rootPath

string

Directorio a escanear

configPath

string

no

Ruta a contextcache.json para la configuración de seguridad

excludePatterns

string[]

no

Patrones glob adicionales a excluir


get_project_context

Carga una lista específica de archivos por ruta.

{ "paths": ["src/auth/login.ts", "src/types.ts"], "projectRoot": "/ruta/absoluta" }

Parámetro

Tipo

Requerido

Descripción

paths

string[]

Rutas de archivos a cargar

projectRoot

string

no

Raíz para resolver rutas relativas

configPath

string

no

Ruta a contextcache.json


Formato de salida

Cada archivo en el bundle se envuelve con marcadores BUNDLE:

BUNDLE_START: <sha256-fingerprint>
ruta/al/archivo.ts
<contenido completo del archivo>
BUNDLE_END: ruta/al/archivo.ts

Los archivos siempre se ordenan alfabéticamente para una salida determinista.

Manejo de BUNDLE_TRUNCATED

Cuando el tamaño total supera maxTotalSizeKb, la respuesta incluye:

BUNDLE_TRUNCATED: límite de tamaño excedido.
Límite configurado: 2048 KB
Tamaño total: 3100 KB
Archivos omitidos:
  src/modulo-grande/archivo-a.ts
  src/modulo-grande/archivo-b.ts

Llama a get_project_context con las rutas omitidas para recuperarlos en una llamada de seguimiento.


Seguridad

Los siguientes archivos están siempre bloqueados, independientemente del contextcache.json:

  • .env, .env.*, credentials.json, *.pem, id_rsa, id_ed25519

  • *.key, private.key, secret*, secrets.json, token*

  • service-account.json, .npmrc, .pypirc

  • Todos los binarios: .exe, .dll, .png, .zip, .wasm, etc.

Las rutas fuera de allowedPaths son rechazadas. El servidor nunca sigue symlinks fuera del árbol permitido.


Desarrollo

pnpm install
pnpm build   # Compila TypeScript → dist/
pnpm dev     # Ejecuta con tsx (sin paso de build)
pnpm test    # Suite de tests con Vitest

Licencia

MIT

Available Tools

3 tools
get_context_from_configA

Reads contextcache.json and returns full project context with module instructions and caching.

ParametersJSON Schema
NameRequiredDescriptionDefault
configPathNoExplicit path to contextcache.json (optional)
projectRootYesDirectory where contextcache.json is located

TDQS

A3.5/5.0
Behavior3/5

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

Indicates read operation and caching, but lacks details on error handling, permissions, or side effects. Without annotations, more transparency is needed.

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?

Single concise sentence efficiently conveys purpose with no wasted words.

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

Completeness3/5

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

Adequate for simple structure (2 params, no output schema), but omits details on output format and error scenarios.

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 coverage is 100%, so parameters are well-documented. Description adds no extra meaning beyond the schema, meeting baseline.

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

Purpose5/5

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

Description clearly specifies the tool reads a specific resource (contextcache.json) and returns a defined output (full project context with module instructions and caching), distinguishing it from sibling tools.

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 siblings (get_directory_context, get_project_context) or any exclusions.

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

get_directory_contextB

Recursively packages all files in a directory and returns them as formatted context for AI agents.

ParametersJSON Schema
NameRequiredDescriptionDefault
rootPathYesRoot directory path to recursively include
configPathNoPath to contextcache.json (optional)
excludePatternsNoAdditional glob patterns to exclude

TDQS

B3.2/5.0
Behavior2/5

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

With no annotations, the description must disclose behavioral traits, but it only mentions 'recursively packages' without details on side effects, performance limits, or whether it modifies state. It lacks transparency beyond the basic operation.

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, clear sentence with no unnecessary words. It conveys the core functionality efficiently, though it could benefit from slightly more structure.

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

Completeness3/5

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

Given the tool's complexity (recursive directory traversal) and the lack of an output schema, the description is somewhat minimal. It doesn't explain the output format or any limitations, but it covers the basic purpose adequately.

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 coverage is 100%, so parameters are already documented. The description does not add any additional meaning or context beyond what the schema provides, hence baseline score of 3.

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

Purpose5/5

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

The description clearly states the verb 'packages' and the resource 'all files in a directory', with the purpose of returning formatted context. It is specific and distinct from siblings by mentioning recursion and packaging.

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 is provided on when to use this tool versus its siblings (get_context_from_config, get_project_context) or when not to use it. The description only states what it does.

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

get_project_contextA

Returns formatted context for a list of files. Use this to load specific files into AI agent context with caching.

ParametersJSON Schema
NameRequiredDescriptionDefault
pathsYesList of absolute or relative file paths to include
configPathNoPath to contextcache.json for security configuration
projectRootNoProject root for resolving relative paths (default: cwd)

TDQS

A3.7/5.0
Behavior3/5

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

No annotations are present, so the description bears the full burden. It mentions caching and formatted output, but does not disclose side effects, authentication needs, rate limits, or what 'formatted context' entails. Adequate but limited.

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?

Two sentences that are direct and front-loaded. The first states the action, the second gives usage guidance. No superfluous information.

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

Completeness3/5

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

Given 3 parameters and no output schema or annotations, the description lacks details on return format, caching behavior, and error scenarios. It references sibling tools but does not clarify differentiation. Leaves gaps.

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 baseline is 3. The description adds 'with caching' but does not elaborate on parameter meaning beyond what the schema already provides. No extra value.

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 it returns formatted context for a list of files and mentions caching. It distinguishes from siblings by specifying file paths, but does not explicitly compare to get_context_from_config or get_directory_context.

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

Usage Guidelines4/5

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

The description advises 'Use this to load specific files into AI agent context with caching,' giving clear context and a specific usage intent. However, it does not provide when-not-to-use or compare with sibling tools.

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

TDQS

A3.8/5.0
Disambiguation5/5

Each tool has a distinct input source: config file, directory, or specific file list. No overlap in purpose.

Naming Consistency5/5

All tools use the consistent 'get_<object>_context' pattern, making them predictable and easy to differentiate.

Tool Count5/5

Three tools is well-scoped for a context-caching server, covering the primary ways to load context without unnecessary bloat.

Completeness4/5

The set covers the main context retrieval methods (config, directory, file list) but lacks cache management or update capabilities, which are minor gaps.

Maintenance

ActivityInactive
ResponsivenessNo issues

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

  • A
    license
    A
    quality
    F
    maintenance
    A Model Context Protocol server that provides secure and intelligent interaction with files and filesystems, offering smart context management and token-efficient operations for working with large files and complex directory structures.
    21
    66
    MIT
  • A
    license
    A
    quality
    D
    maintenance
    Provides secure filesystem access for AI models through the Model Context Protocol with strict path validation, file operations, directory management, and system command execution within predefined directories.
    16
    33
    MIT
  • F
    license
    Not graded
    quality
    D
    maintenance
    Enables LLMs to securely read, search, and analyze local file systems through the Model Context Protocol. Provides tools for listing files, pattern-based searching, and reading file contents with built-in security validation.
    6
  • F
    license
    Not graded
    quality
    D
    maintenance
    Efficiently delivers project documentation to AI agents like Claude on-demand, optimizing token usage by loading context only when needed. Supports document retrieval, listing, and keyword search with security features.

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/jdug-jadodev/MCP-CACHING'

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