MCP-Context-Provider is a static MCP server written in TypeScript, designed to provide persistent tool context for AI models (primarily for Claude Desktop and Claude Code), preventing context loss between chats. The project status is beta, feature-complete, and the API is stabilizing.
Purpose
The core problem this tool solves is: every time a new conversation starts, the AI model needs to re-establish tool usage rules and context. MCP-Context-Provider persists "Contexts" and "Instincts" so that these rules are retained across sessions.
Main Capabilities
- Contexts: Static tool rules, stored as JSON files in contexts/*_context.json. Each file matches one or more tools via a glob pattern and injects static rules.
- Instincts: Rules distilled from sessions with confidence scores, stored in the learned.instincts.yaml file, requiring human approval.
- Four subsystems:
- Engine: Loads, matches, and merges contexts and instincts to generate the injection payload.
- MCP server (src/server/index.ts): Supports stdio and HTTP transports, providing 10 MCP tools.
- CLI (mcp-cp): An approval registry for instinct lifecycle management.
- Memory bridge: Optionally syncs instincts to mcp-memory-service.
Usage
Installation and Configuration
- Claude Desktop (macOS): Add the configuration in ~/Library/Application Support/Claude/claude_desktop_config.json.
- Claude Code (global): Add the configuration in ~/.mcp.json. Note: args and env values must use absolute paths. Claude Code does not support the cwd field in MCP server configuration; relative paths will resolve from the wrong directory and cause connection failures.
- Claude Code plugin (marketplace): Can be installed directly from the marketplace, automatically configuring the correct MCP server path without manually editing .mcp.json.
- /instill skill (Claude Code): Install this skill globally (keep it updated via git pull), then at the end of an efficient session use /instill to distill learned patterns into candidate instincts.
- Automatic trigger hook (optional): The instill-trigger hook automatically detects errors during a session and, when a threshold is reached, prompts Claude to suggest using /instill. It monitors user corrections (UserPromptSubmit) and tool failures (PostToolUse). After installing the hook, it must be registered under UserPromptSubmit and PostToolUse in ~/.claude/settings.json. Scoring rules: corrections have a weight of 1.5x, tool failures have a weight of 0.5x, the merge threshold is 3.0, and it prompts at most once per session; all of these can be adjusted via the CONFIG object in the hook file.
Storage Location
Instinct storage does not depend on the directory from which the MCP host starts the server. The resolution order is:
- INSTINCTS_PATH — explicit override, always takes priority.
- ./instincts — only when the working directory is the mcp-context-provider checkout directory (development scenario).
- $XDG_DATA_HOME/mcp-context-provider/instincts — when XDG_DATA_HOME is set.
- ~/.local/share/mcp-context-provider/instincts — the default. Contexts are resolved in the same way, but fall back to the contexts/ directory bundled within the package. You can view the currently active storage via a command; the resolved path also appears in the list_instincts response and in the /health payload in HTTP mode. If the resolved storage is located within a git working tree that is not a checkout of this repository, the server will warn at startup.
Merged Storage
Merging always targets the canonical learned.instincts.yaml. Existing ids are not overwritten; merging only adds. Old file formats are normalized when read.
Managing Instincts
Use the CLI Manage instincts.
Use cases
- Users who need to maintain consistency in tool usage rules across multiple Claude sessions.
- Developers who want to automatically distill and reuse experiential rules from historical sessions.
- Scenarios where Claude Code is used for long-term project development and where reducing repeated context establishment is desired.
Limitations
- /instill is a Claude Code skill and is only available in the Claude Code CLI; Claude Desktop does not have a skill system. However, in Claude Desktop a similar effect can be achieved by creating a project and pasting the instill instructions as custom instructions, and the MCP tools (list_instincts and build_injection) are available in both.
- /instill is not exposed as an MCP tool because it is an interactive multi-step workflow, whereas MCP tools can only return a single response and cannot drive multi-turn interaction.
- learned.instincts.yaml may contain sensitive data (internal hostnames, customer names, infrastructure details, etc.), is stored by default in the user-level directory, and if pointed to a checkout directory it must be added to .gitignore and its contents reviewed.
- The project is in beta status, and the API is being stabilized.
License
Apache-2.0 License.