An agent that works through MCP often has tools for the web, a database or GitHub, and nowhere of its own to keep a file. When the session ends, what it made is wherever it happened to write it.
afile-mcp is a small MCP server that comes with the aFile CLI and runs on your machine. Its tools save, list, read and share the agent’s files and notes. Each one is encrypted on your machine before it’s uploaded, so the storage at the other end holds only ciphertext.
Install and connect
npm i -g @afile/cli
afile connect
afile key --export --out afile-key.jsonafile connect registers the agent with no account and makes its key on this machine. Export a copy of the key and keep it somewhere safe. Without it, nobody can open the items again, aFile included. The CLI needs Node.js 24 or later.
Add it to your MCP host
afile mcp --host claudeIt prints the entry for Claude Code, with the paths on your machine, and a claude mcp add line that adds it for you:
Output
{
"mcpServers": {
"afile": {
"command": "/path/to/node",
"args": [
"/path/to/@afile/cli/bin/afile-mcp.js"
]
}
}
}
Or add it directly: claude mcp add afile -- /path/to/node /path/to/@afile/cli/bin/afile-mcp.jsUse --host gemini for Gemini CLI, and --host opencode for OpenCode, where it matches the version you have installed. Plain afile mcp prints the usual mcpServers entry for other hosts. The install puts afile-mcp on your PATH, so this short form works too:
{"mcpServers": {"afile": {"command": "afile-mcp"}}}The tools
| Tool | What it does |
|---|---|
list_items | Lists the files, notes and secret names the agent keeps, by kind or tag. Never a secret’s value. |
save_item | Saves text, or a local file by its path, under a unique name, with tags and a note. |
get_item | Reads one item by name or id. Text up to 100 KiB comes back as text. Anything else is written to a path you give. |
share_item | Makes a link to one item, open for a day unless you say otherwise and 30 days at most, or for a single download. |
Secrets stay out of MCP on purpose. get_item won’t return one and share_item won’t share one. A program that needs a key gets it from afile run in a terminal.
The same storage as the CLI
The server uses the same token and key as the CLI, from ~/.config/afile. A file the agent saved over MCP can be shared with afile share in a terminal, and a file you saved in a terminal shows up in list_items. Receive links, versions, secrets and deleting are in the CLI.
What gets stored
- Names, tags, notes and contents are encrypted on your machine, each item under its own AES-256-GCM key. aFile can’t read any of them.
- Each agent has 1 GiB, and each item can be up to 25 MiB.
- Saving over an item keeps the version before it for 30 days.
Questions people ask
Is it a remote MCP server?
No. It runs on your machine over stdio, started by your MCP host, and uploads only ciphertext to the aFile API: api.afile.sh, unless you set AFILE_API_URL.
Does it need an account or an API key?
No. afile connect gives the agent its own token, saved on your machine.
Can my agent ask me for a private detail through it?
Only on a self-hosted aFile server, once you’ve linked the agent to your vault there. Linking a person and asks don’t work on api.afile.sh.