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.

Metadata

Release files for mcp-safebase 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mcp-safebase 0.3.0
File Size Uploaded Provenance Actions
mcp_safebase-0.3.0.tar.gz 62.2 kB With provenance Details for mcp_safebase-0.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for mcp-safebase 0.3.0
File Interpreter ABI Platform Actions
mcp_safebase-0.3.0-py3-none-any.whl Python 3 none any Details for mcp_safebase-0.3.0-py3-none-any.whl

Total release size: 107.6 kB

Release files / mcp_safebase-0.3.0.tar.gz

Download URL mcp_safebase-0.3.0.tar.gz
Size 62.2 kB
Tags Source
SHA-256 checksum
How to use checksums
cccee6489b88d96705149625fdb1c89847ce96c3a92296ebe3015a96ffa72616
BLAKE2b-256 checksum
How to use checksums
ceb924a65143dded2b97dc8c920120f41b71bf92a9bdf89e14a4d42cb4574933
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 5, 2026.

Transparency log

Release files / mcp_safebase-0.3.0-py3-none-any.whl

Download URL mcp_safebase-0.3.0-py3-none-any.whl
Size 45.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6176a708e20e2ee6693ad55e9158154f8e2c23a86aeaada39074bb379d556c06
BLAKE2b-256 checksum
How to use checksums
9a5b150da22f8ecd60f63a56481d936e47be7c14074564c0db0d28c225eb6532
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 5, 2026.

Transparency log

Security for mcp-safebase 0.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for mcp_safebase-0.3.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 5, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files Full provenance

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