Skip to main content

SafeBase

Tests

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:

  1. Each bucket is encrypted with a separate password. Compromising one bucket's password does not compromise the others.
  2. 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.
  3. 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_file opens 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

mcp_safebase-0.3.0.tar.gz (62.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mcp_safebase-0.3.0-py3-none-any.whl (45.3 kB view details)

Uploaded Python 3

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

Hashes for mcp_safebase-0.3.0.tar.gz
Algorithm Hash digest
SHA256 cccee6489b88d96705149625fdb1c89847ce96c3a92296ebe3015a96ffa72616
MD5 17c88d03dc7b188c040e4af11f102869
BLAKE2b-256 ceb924a65143dded2b97dc8c920120f41b71bf92a9bdf89e14a4d42cb4574933

See more details on using hashes here.

Provenance

The following attestation bundles were made for mcp_safebase-0.3.0.tar.gz:

Publisher: publish.yml on lesichkovm/mcp-safebase

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for mcp_safebase-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6176a708e20e2ee6693ad55e9158154f8e2c23a86aeaada39074bb379d556c06
MD5 e4098204987b961f17092f6d664b1b85
BLAKE2b-256 9a5b150da22f8ecd60f63a56481d936e47be7c14074564c0db0d28c225eb6532

See more details on using hashes here.

Provenance

The following attestation bundles were made for mcp_safebase-0.3.0-py3-none-any.whl:

Publisher: publish.yml on lesichkovm/mcp-safebase

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page