SafeBase
An encrypted store for secrets and sensitive information that AI agents can read and write via MCP — but only when the human unlocks access. This keeps your data safe from leaks, accidental exposure, and AI mishaps. The human controls access, not the AI.
Why
AI agents often need access to secrets and sensitive information — API keys, credentials, customer data. But you don't want the AI to have unrestricted access to all of it at all times. The more the AI can see, the more it can accidentally leak or misuse.
SafeBase gives you control over when and for how long the AI can access your data. When the AI needs it, you unlock the bucket. When you're done, it locks again. The AI only sees the content during the session you allow — not before, not after.
Three rules:
- Each bucket is encrypted with a separate password. Compromising one bucket's password does not compromise the others.
- The AI can only see or edit data if the human unlocks the bucket. When the AI needs to read or write data, SafeBase pops up a native OS password dialog on the human's desktop. Until the human unlocks it, the AI cannot see or modify anything in that bucket.
- Unlock is temporary. The human chooses how long the key stays in memory: 1, 5, 10, or 15 minutes, or for the lifetime of the server process. After that, the bucket locks again and the AI loses access until the human unlocks it next time.
The AI never sees the password.
How it works
When the AI calls a tool that needs to decrypt data (get_file, put_file, query_bucket, edit_file), SafeBase checks whether that bucket's key is already in memory:
- Bucket is locked → a password dialog appears on the human's desktop. The human types the password and picks a duration. The server derives the encryption key and holds it in memory. Until the human does this, the AI cannot access any data in that bucket.
- Bucket is unlocked → the tool call completes immediately, no dialog.
- Unlock has expired → the bucket locks again. The dialog reappears. The AI must wait for the human to unlock it.
For secret rotation, edit_file opens a GUI editor on the human's screen pre-filled with the decrypted JSON. The human edits and saves. The AI receives only "File updated successfully" — never the new value.
Data model
- Database = a folder
- Bucket = a subfolder inside a database, each with its own password
- File = one encrypted JSON file inside a bucket
All files are encrypted at rest using Fernet (AES-128-CBC + HMAC-SHA256). Passwords are never stored in plaintext — only bcrypt hashes and per-bucket salts live on disk.
Quick Start
1. Install:
pip install mcp-safebase
Or use directly with uvx (no install needed):
uvx mcp-safebase
Requires tkinter (bundled with Python on Windows and macOS; on Linux may need python3-tk).
2. Create the storage directory (outside any git repo):
mkdir C:\Users\YourName\safebase-data
3. Configure your MCP client (e.g. Windsurf mcp_config.json):
{
"mcpServers": {
"safebase": {
"command": "uvx",
"args": ["mcp-safebase"],
"env": {
"SAFEBASE_ROOT": "C:\\Users\\YourName\\safebase-data"
}
}
}
}
No password env var. The password is set per-bucket by the human via a dialog on first use.
4. Use it:
The MCP client starts the server automatically when the AI calls a tool. The first time the AI writes to a new bucket, a dialog appears on your screen to create a password for that bucket.
Tools
| Tool | Description | Password dialog? | Editor dialog? |
|---|---|---|---|
list_databases |
List all databases (folders) in the root | No | No |
create_database |
Create a new database (folder) | No | No |
list_buckets |
List buckets (subfolders) in a database | No | No |
create_bucket |
Create a new bucket (subfolder) in a database | No | No |
list_files |
List files in a bucket | No | No |
put_file |
Write an encrypted JSON file to a bucket | Yes¹ | No |
get_file |
Read and decrypt a file from a bucket | Yes¹ | No |
edit_file |
Open a GUI editor on the human's screen to edit a stored secret. The AI never sees the content — only a success/cancel confirmation. | Yes¹ | Yes |
delete_file |
Delete a file from a bucket | No | No |
delete_bucket |
Delete a bucket and all its contents | No | No |
query_bucket |
List all files in a bucket with optional field filtering | Yes¹ | No |
change_bucket_password |
Change a bucket's password (re-encrypts all files) | Yes² | No |
Dialogs shown to the human (the AI never sees any dialog content):
- Password dialog — a native OS window where the human enters or creates the bucket password. Shown by any tool marked "Yes¹" when the key is not already in memory (first use, or after the session duration expires).
change_bucket_password(Yes²) shows it twice: once for the current password, once for the new one. - Editor dialog — only
edit_fileopens this. It's a tkinter window with an editable text field pre-filled with the decrypted JSON. The human edits the content directly and clicks Save (or Cancel). The AI receives only"File updated successfully"or"Edit cancelled by user"— never the file content.
Documentation
- Specification — full technical spec: architecture, storage model, encryption, password lifecycle, threat model, error handling
- Password System — how per-bucket passwords work, session duration, changing passwords, what happens when you cancel
- Security — threat model, what SafeBase protects against and what it doesn't
- Usage Examples — concrete examples: contact rosters, sales leads, secret rotation
Testing
pytest test_server.py -v # 101 tests
python test_smoke.py # quick smoke test (headless)
Tests mock the dialog functions, so they run without tkinter or a display.
License
AGPL-3.0 — see LICENSE. Commercial use requires a separate commercial license.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mcp_safebase-0.3.0.tar.gz.
File metadata
- Download URL: mcp_safebase-0.3.0.tar.gz
- Upload date:
- Size: 62.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cccee6489b88d96705149625fdb1c89847ce96c3a92296ebe3015a96ffa72616
|
|
| MD5 |
17c88d03dc7b188c040e4af11f102869
|
|
| BLAKE2b-256 |
ceb924a65143dded2b97dc8c920120f41b71bf92a9bdf89e14a4d42cb4574933
|
Provenance
The following attestation bundles were made for mcp_safebase-0.3.0.tar.gz:
Publisher:
publish.yml on lesichkovm/mcp-safebase
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mcp_safebase-0.3.0.tar.gz -
Subject digest:
cccee6489b88d96705149625fdb1c89847ce96c3a92296ebe3015a96ffa72616 - Sigstore transparency entry: 2728294683
- Sigstore integration time:
-
Permalink:
lesichkovm/mcp-safebase@8b82b72c0bd8e3642b2685dfac6d508930b3a3f3 -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/lesichkovm
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@8b82b72c0bd8e3642b2685dfac6d508930b3a3f3 -
Trigger Event:
release
-
Statement type:
File details
Details for the file mcp_safebase-0.3.0-py3-none-any.whl.
File metadata
- Download URL: mcp_safebase-0.3.0-py3-none-any.whl
- Upload date:
- Size: 45.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6176a708e20e2ee6693ad55e9158154f8e2c23a86aeaada39074bb379d556c06
|
|
| MD5 |
e4098204987b961f17092f6d664b1b85
|
|
| BLAKE2b-256 |
9a5b150da22f8ecd60f63a56481d936e47be7c14074564c0db0d28c225eb6532
|
Provenance
The following attestation bundles were made for mcp_safebase-0.3.0-py3-none-any.whl:
Publisher:
publish.yml on lesichkovm/mcp-safebase
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mcp_safebase-0.3.0-py3-none-any.whl -
Subject digest:
6176a708e20e2ee6693ad55e9158154f8e2c23a86aeaada39074bb379d556c06 - Sigstore transparency entry: 2728294726
- Sigstore integration time:
-
Permalink:
lesichkovm/mcp-safebase@8b82b72c0bd8e3642b2685dfac6d508930b3a3f3 -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/lesichkovm
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@8b82b72c0bd8e3642b2685dfac6d508930b3a3f3 -
Trigger Event:
release
-
Statement type: