Skip to main content
Glama
phantomswap

phantomswap

๐ŸŽญ PhantomSwap

"Your data, ghosted." โ€” Privacy-first, bidirectional data masking & unmasking service for safe AI interactions.

FastAPI Python 3.11+ SQLite MCP License: MIT


๐Ÿ’ก The Problem & The Solution

When collaborating with Large Language Models (LLMs) on resumes, portfolio websites, codebases, or sensitive documents, personal identifiers (PII) like names, emails, phone numbers, colleges, and internal company project names are exposed.

PhantomSwap solves this locally:

  1. Define a Swap Session: Map your real personal data to realistic fake placeholders.

  2. ๐ŸŽญ Mask: Swap real values with fake placeholders before sending your text or code to AI.

  3. ๐Ÿค– Send to AI: Let AI build your portfolio website, optimize your resume, or refactor your code.

  4. ๐Ÿ”“ Unmask: Seamlessly restore all real personal values back across the generated text or entire codebase directories!

100% Local Execution โ€” Your real data never leaves your computer.


Related MCP server: SecureMCP

๐ŸŒŸ Key Features

  • โšก Bidirectional Replacement Engine: Guaranteed collision-safe two-pass replacement avoiding chain-replacement corruption.

  • ๐ŸŽจ Modern Dark Glassmorphism UI: Beautiful web dashboard with live stats, copy buttons, search, and directory inspector.

  • ๐Ÿ“ Bulk Directory Processing: Recursively mask and unmask entire projects (e.g. AI-generated portfolio website folders) with automatic .bak safety backups.

  • ๐Ÿค– Native MCP Server: Integrated Model Context Protocol server for AI coding assistants (Claude Desktop, Cursor, Windsurf).

  • โŒจ๏ธ Rich CLI: Feature-complete terminal CLI with rich formatted tables and pipe support.

  • ๐Ÿ“œ Task Audit History: Complete tracking and logging of every masking operation.


๐Ÿ—๏ธ Architecture

flowchart TD
    subgraph Interfaces
        UI["๐ŸŽจ Web UI Dashboard (Port 8000)"]
        CLI["โŒจ๏ธ Terminal CLI (Typer + Rich)"]
        MCP["๐Ÿค– MCP Server (Claude / Cursor / Windsurf)"]
        API["๐ŸŒ REST API (FastAPI)"]
    end

    subgraph Core
        ENGINE["๐Ÿ”ง Two-Pass Replacement Engine"]
        FILEOPS["๐Ÿ“ Bulk File & Directory Ops"]
    end

    subgraph Storage
        DB[("๐Ÿ’พ Local SQLite DB (phantomswap.db)")]
        BAK[("๐Ÿ›ก๏ธ Automatic .bak File Backups")]
    end

    UI --> API
    CLI --> API
    API --> ENGINE
    API --> FILEOPS
    MCP --> ENGINE
    MCP --> FILEOPS
    API --> DB
    MCP --> DB
    FILEOPS --> BAK

๐Ÿš€ Quick Start

1. Setup & Installation

Using uv (Fastest):

# Create virtual environment and install dependencies
uv venv
uv pip install -r requirements.txt

Or using standard Python (venv):

# Windows
py -m venv .venv
.venv\Scripts\pip install -r requirements.txt

# Linux / macOS
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt

2. Run the Web Dashboard & API

Local:

# With uv
uv run python -m app.main

# Or with python virtualenv
.venv\Scripts\python -m app.main

Or with Docker / Docker Compose:

# Build and run container with persistent SQLite volume
docker compose up --build -d

Open your browser at:


โŒจ๏ธ Command Line Interface (CLI)

# List swap sessions
uv run python -m cli.main sessions list

# Create a new session
uv run python -m cli.main sessions create my-resume \
  --description "Masking resume personal details" \
  -m "Shiva Patel:Alex Johnson" \
  -m "shiva.patel@gmail.com:alex.johnson@example.com" \
  -m "IIT Delhi:State University"

# Mask text directly from terminal
uv run python -m cli.main mask --session my-resume --text "Shiva Patel graduated from IIT Delhi."
# Output: Alex Johnson graduated from State University.

# Unmask text
uv run python -m cli.main unmask --session my-resume --text "Alex Johnson graduated from State University."
# Output: Shiva Patel graduated from IIT Delhi.

# Mask an entire directory (e.g. portfolio project)
uv run python -m cli.main dir mask D:\projects\MyPortfolio --session my-resume --ext .html,.css,.js

# Unmask the directory when AI generation is complete
uv run python -m cli.main dir unmask D:\projects\MyPortfolio --session my-resume --ext .html,.css,.js

# View task history
uv run python -m cli.main history

๐Ÿค– Model Context Protocol (MCP) Integration

PhantomSwap includes a built-in MCP server that allows AI assistants to mask and unmask sensitive project context autonomously.

Claude Desktop Configuration

Add the following to your claude_desktop_config.json:

{
  "mcpServers": {
    "phantomswap": {
      "command": "uv",
      "args": [
        "run",
        "--directory",
        "d:/DEVELOPMENT/MulipleStringChanger",
        "python",
        "-m",
        "mcp_server.server"
      ]
    }
  }
}

Available MCP Tools:

  • phantomswap_list_sessions: List all available masking profiles.

  • phantomswap_get_session: Retrieve replacement mappings.

  • phantomswap_create_session: Create new session with key-value pairs.

  • phantomswap_mask_text: Anonymize text before sending to AI.

  • phantomswap_unmask_text: Restore original values in AI responses.

  • phantomswap_mask_directory: Bulk mask project directories.

  • phantomswap_unmask_directory: Bulk unmask project directories.


๐Ÿงช Testing

Run the automated test suite with pytest:

uv run pytest tests/ -v

๐Ÿ“„ License

MIT License ยฉ 2026. Built with privacy in mind.

Available Tools

7 tools
phantomswap_create_sessionB

Create a new swap session with key-value mappings. mappings should be a list of objects like: [{"real_value": "Real", "fake_value": "Fake"}]

Inputs: name (required), mappings (required), description (required), case_sensitive. Returns: result

phantomswap_get_sessionA

Get full details and all key-value mappings of a specific swap session.

Inputs: session_name_or_id (required). Returns: result

phantomswap_list_sessionsA

List all available PhantomSwap swap sessions with their summary details.

Inputs: no named parameters. Returns: result

phantomswap_mask_directoryB

Mask all files in a directory using a swap session.

Inputs: directory_path (required), session_name_or_id (required), file_extensions. Returns: result

phantomswap_mask_textC

Mask sensitive information in text by swapping real values with fake placeholders.

Inputs: text (required), session_name_or_id (required). Returns: result

phantomswap_unmask_directoryC

Unmask all files in a directory using a swap session.

Inputs: directory_path (required), session_name_or_id (required), file_extensions. Returns: result

phantomswap_unmask_textC

Unmask text by restoring fake placeholders back to original real values.

Inputs: text (required), session_name_or_id (required). Returns: result

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelogโ€ฆ

    TDQS

    A3.5/5.0

    Scored across 7 tools

    Disambiguation5/5

    Each tool has a clearly distinct purpose: session management (list/get/create) versus masking operations (mask/unmask text or directory). There is no meaningful overlap between any two tools.

    Naming Consistency5/5

    All tools follow the consistent phantomswap_<verb>_<target> pattern using snake_case. The session tools use list/get/create and the masking tools use mask/unmask, making the naming highly predictable.

    Tool Count5/5

    Seven tools is well-scoped for a session-based masking utility on three session management tools and four mask/unmask operations. Every tool earns its place and there are no redundant additions.

    Completeness4/5

    The core workflow is covered: sessions can be created, listed, and retrieved, and masking/unmasking works for both text and directories. Missing session update/delete operations are minor administrative gaps that can be worked around by creating new sessions.

    Maintenance

    ActivityStale
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      Not graded
      quality
      D
      maintenance
      Enables anonymization and deanonymization of sensitive data in text using Microsoft Presidio. Supports session-based storage to reversibly replace sensitive information like passwords and secrets with placeholder tokens.
      -
    • A
      license
      B
      quality
      B
      maintenance
      Enables local grammar-preserving masking of sensitive content, entities, and code identifiers into synthetic tokens before sending prompts to LLMs, then restores the original text and symbols from responses using session-scoped in-memory mappings.
      5
      2
      Apache 2.0
    • A
      license
      B
      quality
      B
      maintenance
      Enables local, in-memory de-identification of PII, PHI, and credentials with deterministic reversible surrogate tokens before LLM transmission, then restores originals from volatile session mappings and audits for exposures without network egress or disk writes.
      5
      115 npm
      1
      Apache 2.0
    • F
      license
      Not graded
      quality
      B
      maintenance
      Enables reversible anonymization of sensitive PII such as SSNs, credit cards, passport numbers, emails, and phone numbers before sending prompts to external LLMs, then restores original values locally using HMAC isolation.
      7
      -