MCP server for caching and memory in Claude Code
An MCP server for caching and memory: connect Claude Code or any coding agent to Crowkis, scope it to a tenant, share it with a team, know the limits.
An MCP server for caching and memory gives an AI assistant two abilities it can call as tools: look up an answer that has already been computed, and remember facts between sessions. Crowkis ships one as the crowkis mcp subcommand. Claude Code, or any other MCP client, launches it as a local process scoped to the tenant you configure.
In plain words. Usually your code wraps the model with a cache. With MCP the assistant holds the cache and the memory as tools and decides when to use them. That is how you add both to an agent whose code you do not control.
What is MCP, and why put a cache behind it?
MCP, the Model Context Protocol, is an open-source standard for connecting AI applications to external systems (introduction). A server exposes tools. The specification calls tools model-controlled: the language model can discover and invoke them automatically, based on its understanding of the context and the user's prompt (tools).
Messages are encoded as JSON-RPC. For a server that runs on your machine the transport is stdio: the client launches the server as a subprocess, writes requests to its standard input and reads responses from its standard output (transports).
A cache belongs behind that interface because assistants repeat work. Everyone on a team asks the same questions about the same repository. Each session starts cold and pays again for an explanation a colleague's session produced yesterday. In your own application you would wrap the model call with a cache. An assistant such as Claude Code makes its model calls in code you do not own, so there is no place to add that wrapper. MCP gives the assistant the cache as a tool instead.
How do you connect Claude Code to Crowkis?
One command registers the server:
claude mcp add --env CROWKIS_TENANT=my-team crowkis -- crowkis mcpThe shape is claude mcp add [options] <name> -- <command> [args...]. Everything after the double dash is the command that runs the server, and --env sets a variable in that server's environment (Claude Code MCP documentation). Other MCP clients take the same information as a JSON block:
{"mcpServers": {"crowkis": {"command": "crowkis", "args": ["mcp"],
"env": {"CROWKIS_TENANT": "your-tenant"}}}}Check the result with claude mcp list, or with /mcp inside a session. The /mcp panel shows each connected server with its tool count. Because the client starts the server as a subprocess, the crowkis binary has to be runnable on the machine where the client runs. mcp is a subcommand of the same binary that runs crowkis server, so there is no separate package to install.
Why does the server require a tenant?
Since version 0.5.2, crowkis mcp exits with a clear message if no tenant is configured. The exit code is 1 and the message names the variable.
| Variable | Required | What it does |
|---|---|---|
CROWKIS_TENANT | yes | Sets the tenant every read and write of this server process belongs to |
CROWKIS_USER | no | Sub-scopes agent memory to one user inside that tenant |
The reasoning is worth copying into any tool server you write yourself. Tools are model-controlled, so every tool argument is a value the model chooses. A tenant passed as an argument would let the agent pick its own boundary, and that is not an authorisation decision. A variable in the process environment is chosen by the person who wrote the configuration.
Before this change the server sent no tenant at all, so every agent shared one bucket. If you run a single-tenant deployment, set any one name, for example CROWKIS_TENANT=default. How tenants are kept apart inside the engine is covered in tenant isolation.
What can the agent do once it is connected?
Two things, both backed by the same engine your services would use.
Cache. The agent can ask whether a question has a stored answer, and store one after it has computed it. Lookups match by meaning and structure, and Crowkis applies confidence, freshness and safety checks before it reuses anything, as what a semantic cache is explains. Writes get no shortcut for being made by an assistant. Every cache write passes the five-stage anti-poisoning pipeline, and a pair whose answer does not fit its question is rejected. An agent that tries to store a confused answer is refused in the same way a careless script would be. See cache poisoning.
Memory. The agent can keep facts that outlive the session: the conventions of a codebase, a user's preferences, a decision made last week. Memory is recalled by relevance blended with recency, and a new fact that contradicts an old one retires it. The model behind that is in long-term memory for AI agents.
The exact tool names are whatever the server advertises. Clients discover them through the protocol's tool listing request, and in Claude Code you read them in the /mcp panel.
One practical step makes the difference between a registered server and a used one. Because the model decides when to call a tool, tell it when. A line in your project instructions works: before answering a question about this codebase, check the Crowkis cache, and after answering a new one, store the answer.
How do you share one cache across a team?
Give everyone the same tenant. One developer's answered question then becomes a cache hit for the next person who asks it, in whatever words. That saves cost, and the saving grows with how often a team repeats itself.
Claude Code has three places to store a server definition, and its documentation lists them:
| Scope | Loads in | Shared | Stored in |
|---|---|---|---|
| Local, the default | the current project only | no | ~/.claude.json |
| Project | the current project only | yes, through version control | .mcp.json in the project root |
| User | all your projects | no | ~/.claude.json |
For a team, add the server with --scope project and commit .mcp.json. Keep the tenant in that file. Do not hard-code one person's CROWKIS_USER in it. Claude Code expands ${VAR} and ${VAR:-default} inside the env block of .mcp.json, so each developer's own environment can supply the user while the tenant stays shared.
Two things to plan for:
- Tenants per project. A tenant per repository keeps one project's answers out of another's. The Community edition allows up to three tenants, so decide early whether you split by project or by team.
- Stale answers. Code changes, and an explanation of last month's code is wrong today. Write entries with an expiry, and clear a topic from any RESP3 client when it changes.
CINVALIDATE "<instruction>" TENANT tpreviews what it would purge until you addCOMMIT, andCFLUSH TENANT tclears one tenant. See cache invalidation and freshness.
MCP, SDK or gateway: which integration fits?
Crowkis has more than one front door. The choice depends on who should decide that the cache gets checked.
| Integration | Who decides to use the cache | Fits |
|---|---|---|
MCP server, crowkis mcp | the model, as a tool call | Claude Code and other assistants whose code you do not control |
| SDK or RESP3 commands | your code, on every request | applications you write, where a cache-first flow must be deterministic |
| AI gateway | the proxy, on every request | existing OpenAI-compatible clients, with no code change |
The gateway is described in the OpenAI-compatible AI gateway, and the commands in the Crowkis command reference.
When should you not use the MCP server?
- When every request must hit the cache. Tool use is the model's choice. Some questions will be answered without a lookup. If you need a guarantee, put the cache in the request path with the gateway or the SDK.
- When the tenant must change per request. One server process has one tenant, fixed in its environment. That is the point of the design, and it also means a single process cannot serve several customers.
- When you have not decided who may write. A shared cache is shared content. An answer stored by one agent is read by every teammate's agent. Tenant scoping and the write pipeline are the controls, and the MCP specification adds a third: there should always be a human in the loop with the ability to deny a tool invocation. Claude Code's documentation also tells you to verify that you trust each server before you connect it.
- When you need a remote endpoint. The documented setup is a command-launched local process. No hosted HTTP endpoint for MCP is described in the docs.
Common questions
Does the Crowkis MCP server work with clients other than Claude Code?
It should work with any client that can launch a local server from a command, arguments and an environment block, which is what the JSON configuration above describes. MCP is an open standard, and its specification says clients should support stdio whenever possible.
Why does crowkis mcp exit as soon as it starts?
No tenant is configured. Since 0.5.2 the server exits with code 1 and names the variable. Set CROWKIS_TENANT in the server's environment, through --env or the env block.
Is agent memory shared between everyone on the tenant?
Only if you leave it unscoped. Set CROWKIS_USER and memory is sub-scoped to that user. Memory written with no user lands in a bucket the whole tenant can read, which is why Crowkis redacts personal data from it before storage.
Do I need a second service for MCP?
No extra package. mcp is a subcommand of the crowkis binary, alongside server and doctor. Product details and the Docker image are on the Crowkis page.