dangerzone
You can create, modify, and remove custom Python tools at runtime, then call them, with persistence across restarts.
Add new tools with
add_tool, supplying a name, description, JSON Schemainput_schema, and Pythonsourcedefiningmain(arguments)(sync or async) that returns JSON.Edit existing custom tools with
edit_tool; all fields are supplied, the name identifies the tool, and invalid edits leave the old tool intact.Remove custom tools with
remove_tool.Call dynamically added tools as normal MCP tools; arguments are validated, code runs in a fresh worker with a default 30-second timeout, and failures return tool errors.
Persist custom tools in a project-local
dangerzone.tools.json(unless--no-persist), so they survive server restarts.The built-in
add_tool,edit_tool, andremove_tooltools are permanent and cannot be edited or removed.Custom tool code executes with the server user's OS permissions; process separation is not a sandbox.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@dangerzone Create a Python tool that squares a number and test it with 7."
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
dangerzone-mcp
A Python example of a self-modifying MCP server, built on the official MCP Python SDK. The agent connected to it can write a new tool, call it, fix it, and find it still there in the next session.
The server has three permanent tools: add_tool, edit_tool, and
remove_tool. Everything else in the catalog is Python that arrived at
runtime, usually written by the agent, saved in a JSON file in your project.
The name is a reminder that this runs model-written Python on your machine with your permissions. Read Trust before pointing it at anything you care about.
What it looks like

Register the server, then ask for a tool:
Use dangerzone to create a tool that squares a number. Call it with 7, then edit it to cube numbers and call it again.
The agent calls add_tool with Python source and an input schema. The server
saves the definition and notifies the client that its tool list changed. Calling
square with 7 returns 49; after edit_tool changes it to cube numbers, the same
call returns 343. Restarting the server restores the edited tool. remove_tool
takes it out of the catalog when it is no longer needed.
Each call validates its arguments and runs the Python code in a fresh worker,
with a 30-second timeout by default (--timeout SECONDS). Failures return tool
errors so the session can continue.
Related MCP server: MCP Python Interpreter
Register
Install uv and Git, then clone the repository and read it. The server runs on your machine with your permissions, and there is no install path that skips that step on purpose.
git clone https://github.com/khuber/dangerzone-mcp.git
cd dangerzone-mcp && uv syncClaude Code
From the checkout:
claude mcp add --transport stdio --scope user dangerzone -- \
uv run --project "$PWD" dangerzone-mcpThis makes the server available across your projects. Run /mcp in Claude Code
to check the connection. Each project keeps its own catalog as described under
Persistence. Updating is a git pull in the checkout followed
by a reconnect; nothing changes until you do that.
Other MCP clients
For clients that accept mcpServers JSON and refresh tools after change
notifications, replace the path with your checkout:
{
"mcpServers": {
"dangerzone": {
"command": "uv",
"args": [
"run",
"--project", "/absolute/path/to/dangerzone-mcp",
"dangerzone-mcp"
]
}
}
}See client compatibility for the Codex limitation. The setup guide covers registration scopes, server options, updates, and troubleshooting.
Persistence
Tools survive restarts in a project-local dangerzone.tools.json. The server
uses the containing Git root, or the starting directory outside Git. Clients
start it in the project directory; --project-dir PATH overrides the starting
point. The file is created by the first add_tool call, so projects where you
never write a tool stay untouched. Add --no-persist to the server command to
keep tools in memory for one process.
Keep personal catalogs out of Git, or deliberately commit reviewed tools to share them. See the catalog reference for the file format, recovery behavior, and ignore entries.
Trust
Workers are process separation, not a sandbox. Tool code has the server user's file, network, and process access. That is fine for tools I asked for on my own laptop and not fine for much else. To run code you do not trust, put the workers under a different OS user or in a container with the server package read-only.
Persistence adds a second consideration. A repository you clone can arrive
with a dangerzone.tools.json already in it, written by whoever committed it,
and the agent uses the tool descriptions in that file to decide what to call.
Treat a catalog you did not write the way you would treat a Makefile from a
stranger: read the source and the descriptions before enabling it, or start
the server with --no-persist so it never loads.
Client compatibility
The add-then-call workflow requires a client that refreshes its tool list after change notifications. Codex has a reported issue where tools added after initial discovery never become callable in the task, including in later turns: openai/codex#43642. Codex setup examples are omitted until this workflow is verified to work there.
For implementation details and limitations, see the reference. For development setup and checks, see the setup guide.
Built on the MCP Python SDK 2.3 against the 2026-07-28 spec. MIT licensed.
Available Tools
3 toolsadd_toolA
Add a new Python tool. Use edit_tool to change an existing tool. source must define main(arguments), sync or async, returning JSON. input_schema describes the arguments object using JSON Schema 2020-12. The add_tool, edit_tool and remove_tool built-ins are permanent. Code executes with the server user's OS permissions.
Inputs: name (required), source (required), description (required), input_schema (required). Returns: name, status
edit_toolADestructiveIdempotent
Replace an existing custom tool's description, input_schema, and Python source. Supply all fields; the name identifies the tool. Invalid edits leave the old tool intact. The add_tool, edit_tool and remove_tool built-ins cannot be edited.
Inputs: name (required), source (required), description (required), input_schema (required). Returns: name, status
remove_toolADestructive
Remove a custom tool. The add_tool, edit_tool and remove_tool built-ins can never be removed.
Inputs: name (required). Returns: name, status
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 3 tools
Each tool targets a distinct lifecycle stage: add_tool creates, edit_tool modifies an existing tool, and remove_tool deletes one. There is no realistic overlap or ambiguity between these operations.
All three tool names follow the same verb_noun pattern in lowercase snake_case: add_tool, edit_tool, remove_tool. The naming is perfectly consistent and immediately indicates each tool's purpose.
Three tools is minimal but exactly right for a self-modifying tool server: create, update, and delete. There is no unnecessary duplication or bloat.
The core add/edit/remove lifecycle is covered, and tool discovery is available through MCP's normal tool-listing mechanism. The only minor gap is that there is no way to retrieve a custom tool's Python source after it has been added, which can make edit_tool awkward if the source was not retained externally.
Related MCP Connectors
Persistent memory and knowledge management for AI agents with semantic search and 50+ tools.
Git-backed platform for skills, tools, and context for AI agents
Turn an idea or meeting transcript into a working single-file AI agent, check it, use it right away.
Turn an idea or meeting transcript into a working single-file AI agent, check it, use it right away.
Related MCP Servers
- FlicenseNot gradedqualityNot gradedmaintenanceEnables LLMs to interact with Python environments, execute code or scripts, manage packages, and read/write files within an isolated working directory.-
- FlicenseNot gradedqualityAmaintenanceEnables LLMs to interact with Python environments, run code and scripts, manage packages, and read or write files within a configured working directory.-
- FlicenseNot gradedqualityAmaintenanceEnables LLMs to interact with Python environments, execute code, manage packages, and perform file operations within a configurable working directory.-
- FlicenseNot gradedqualityAmaintenanceEnables LLMs to interact with Python environments, execute code or scripts, manage packages, and read/write files within an isolated working directory.-