AutoTool
AutoTool is an MCP server that lets an agent extend its own toolset by writing, verifying, mounting, and calling new Python MCP tools on demand.
Use
create_toolto submit a complete self-contained Python MCP server script for a missing capability, with a snake_case_toolname, optional smoke-test tool/arguments, and retry with fixes if verification fails.AutoTool verifies the script in a guarded subprocess, injects only declared credentials, and mounts it so its tools appear in the tool list.
Use
run_toolto call a created tool by full name (e.g.weather_tool__current) with arguments, especially if it does not appear in the current tool list.In this schema, no credentials are available, so created tools must use public keyless APIs and must not declare
REQUIRED_ENV.
Enables integration with LangGraph via langchain-mcp-adapters, allowing LangGraph agents to launch AutoTool as an MCP server and use its tools.
Integrates with Ollama as an OpenAI-compatible local model endpoint, enabling the use of local models without an API key.
Integrates with OpenAI's API to serve as a model provider for the agent and for AutoTool's own tool synthesis, supporting models like gpt-6-sol and OpenAI-compatible endpoints.
AutoTool
A tool layer that grows, for any AI agent. Connect AutoTool to Claude Code, Codex, Cursor, Claude Desktop, OpenClaw or an agent you are building. When your agent needs something it has no tool for, such as a web API, live data or your company's internal service, it writes the tool. AutoTool then:
verifies it: lint, launch in a subprocess, smoke test;
guards it: the tool runs in its own process with only the credentials it declares;
mounts it, live, with no restart;
keeps it for every agent on your machine.
The model is told your keys' names (TAVILY_API_KEY), never their values, and values that a tool
echoes back are redacted before the model sees them.
your agent (Claude Code, Codex, Cursor, your own) ──MCP──▶ autotool serve
├─ create_tool the agent writes a tool
├─ run_tool call any created tool
├─ weather_tool__current ─▶ own process, gets WEATHER_API_KEY only
└─ tavily_tool__search ─▶ own process, gets TAVILY_API_KEY onlyQuick start
Python 3.11+. Pick the way you work:
Build your own agent (Python)
pip install "autotool-mcp[models]"
export OPENAI_API_KEY=sk-... # your agent's model (or ANTHROPIC_API_KEY)import asyncio, autotool
from autotool.core.llm import default_provider
answer = asyncio.run(
autotool.run_agent(
"What are the top 3 stories on Hacker News right now?",
default_provider(),
on_consent=lambda question: input(question + " [y/N] ") == "y", # asked before a tool gets a key
)
)
print(answer)The agent has no Hacker News tool. It writes one, AutoTool verifies and mounts it, and the agent uses it. Run it again and the tool is already there.
Local or other models. Any OpenAI-compatible endpoint works: Ollama, LM Studio, vLLM, OpenRouter, and others. Set a base URL and a model name; local servers need no key.
export OPENAI_BASE_URL=http://localhost:11434/v1 # Ollama; LM Studio: http://localhost:1234/v1
export OPENAI_LLM=qwen2.5:14b # the model name on that serverdefault_provider() then talks to that endpoint through the Chat Completions API. Pick a model
with tool calling. Writing a working tool is real coding, so small models fail more often than
frontier ones. AUTOTOOL_PROVIDER=openai keeps OpenAI's Responses API even with a custom base URL.
Already have an agent loop? Connect it to AutoTool and pass tool calls through:
async with autotool.connect() as client: # starts AutoTool as an MCP server
listed = await client.list_tools() # AutoTool commands and tools mounted in this session
tools = autotool.openai_tools(listed) # or autotool.anthropic_tools(listed)
result = await client.call_tool(name, arguments) # whatever your model asked forFrameworks with stdio MCP support (OpenAI Agents SDK MCPServerStdio, LangGraph via
langchain-mcp-adapters) can also launch autotool serve directly.
Add it to Claude Code, Codex, Cursor, Claude Desktop or OpenClaw
pip install autotool-mcp # or: pipx install autotool-mcp / uv tool install autotool-mcp
autotool setup # registers AutoTool with every agent app it finds
autotool keys add TAVILY_API_KEY # stored in your OS keychain; add as many as you likeRestart your agent app and ask for something it can't do yet: "Search the web for this week's
James Webb news". It writes a Tavily tool. AutoTool asks whether that tool may use
TAVILY_API_KEY, verifies it, hands it that key and nothing else, and the answer comes back.
Next time, the tool is already there.
autotool setup --dry-run shows what it would change first. JSON configs (Claude Desktop, Cursor)
are backed up to .bak before editing. Existing entries keep their env block, and an existing
Claude Code or Codex entry is left untouched.
Related MCP server: ToolForge MCP Server
Reuse tools across running hosts
If another running host creates a tool in the same AutoTool home, ask your agent to call
refresh_tools. This loads tools from the shared cache without restarting the session or
restarting unchanged tools. The response includes new tool names for run_tool, and hosts
that handle tool-list change notifications can pick them up as native tools.
refresh_tools starts cached Python scripts under the same credential policy as startup.
Keep the shared tools directory under your control. Check the server log for skipped entries.
Adding credentials
You add environment variables. AutoTool offers their names to your agent, and a created tool
gets a value only if it declares that name in its code (REQUIRED_ENV = ["TAVILY_API_KEY"]).
Pick any of these places (the first match wins):
Where | How |
Your host's MCP config |
|
OS keychain |
|
|
|
Any file |
|
A new key can be used by the next tool your agent creates, with no restart. Your agent's tool list
shows the new name on the next listing. After adding the key and granting any required approval,
call refresh_tools to retry a skipped tool. Removing keys, revoking approval or deleting a
mounted tool takes effect on the server's next tool-list or tool-call request. Calls already in
flight may finish.
autotool keys list shows names. autotool tools list shows
which tools hold which credentials. If a tool needs a key you don't have, your agent is told
exactly what to run (autotool keys add STRIPE_API_KEY).
Let AutoTool write the tools
If your agent is small or not good at writing code, give AutoTool a model of its own in
~/.autotool/.env: OPENAI_API_KEY (default model gpt-6-sol), ANTHROPIC_API_KEY (default
claude-opus-5), or an OpenAI-compatible endpoint (OPENAI_BASE_URL + OPENAI_LLM, e.g. a local
Ollama model). Only a key in that file counts: a key your host happens to have in its environment
is never used, so nothing gets billed by surprise. A synthesize_tool tool then appears: your
agent describes the capability, and AutoTool writes, verifies, repairs and mounts it.
What a created tool looks like
import os
import httpx2
from mcp.server.mcpserver import MCPServer
from mcp.server.mcpserver.exceptions import ToolError
REQUIRED_ENV = ["TAVILY_API_KEY"] # the only credential this process will receive
mcp = MCPServer("tavily_tool")
API_BASE = os.environ.get("TAVILY_API_BASE", "https://api.tavily.com")
@mcp.tool()
def search(query: str, max_results: int = 5) -> str:
"""Search the web with Tavily."""
with httpx2.Client(timeout=10) as client:
r = client.post(
f"{API_BASE}/search",
json={"query": query, "max_results": max_results},
headers={"Authorization": f"Bearer {os.environ['TAVILY_API_KEY']}"},
)
if r.status_code != 200:
raise ToolError(f"Tavily returned HTTP {r.status_code}: {r.text[:200]}")
return r.text
if __name__ == "__main__":
mcp.run()A tool is a plain MCP server built on the official Python SDK
(v2). ToolError messages reach the agent; an unexpected exception's traceback goes to the
verifier, which feeds it back so the tool can be fixed.
Security
Consent. The first time a tool asks for credentials, AutoTool asks you, through your agent
app's approval prompt: "Allow tavily_tool to use TAVILY_API_KEY? It can only send them to
api.tavily.com." Nothing runs with the key until you say yes. You are asked again only when the risk changes:
Key with a host allowlist (and the guard on): rewrites of the tool don't ask again. A rewrite can't send the key anywhere new. It asks again only if the tool wants more keys or you widen the allowlist.
Key without an allowlist: every new version of the tool asks, because a rewrite could send the key anywhere. Setting allowlists means fewer prompts.
Removing a tool revokes its approval. If your app can't show prompts, the agent is told to ask you to run the approval yourself:
autotool tools approve tavily_tool TAVILY_API_KEY
autotool tools revoke tavily_tool
autotool serve --dangerously-allow-all-tools # never ask (or AUTOTOOL_CONSENT=dangerously-allow-all)Modern approval continuations expire after ten minutes and are bound to the exact request and current policy revision. Revoking an approval invalidates old continuations. Model-assisted synthesis preserves the same candidate through approval and continues its repair loop afterward.
--dangerously-allow-all-tools gives every tool the credentials it declares without asking.
Use it for CI, or if you'd rather not approve tools. The guard and host allowlists still apply,
and the server logs a warning at startup.
Per-key host allowlists. Say where a key may be sent. A tool holding that key can then only reach those hosts (plus localhost, which never leaves your machine):
autotool keys allow TAVILY_API_KEY api.tavily.com
autotool keys allow GITHUB_TOKEN api.github.com "*.githubusercontent.com"
autotool keys allow TAVILY_API_KEY # no hosts: remove the limitWhen a tool declares several restricted keys, it may reach only the host patterns explicitly present in every key's allowlist. Wildcards must match exactly across lists. Disjoint lists permit only loopback; split that capability into separate tools instead of widening either key.
The guard (on by default, optional). Every tool runs under a Python audit hook that the tool cannot remove. It enforces the allowlists and blocks:
subprocesses and shell commands;
loading native code;
the OS keychain and credential stores;
reading AutoTool's credential files and your agent apps' MCP configs;
creating, changing or deleting anything outside the temp directory.
This applies to every tool, including ones that declare no keys. Each process executes a captured copy of its approved source in its own temporary directory, which is removed when the connection closes. Tool scripts must be self-contained; use declared environment variables for settings rather than files relative to the shared tool cache.
It is a guard, not a jail: Python introspection, native code or interpreter bugs can get past it. If AutoTool already
runs inside a sandbox (a container, a VM, a devcontainer), turn it off:
autotool serve --sandbox off (or AUTOTOOL_SANDBOX=off in your host's MCP config). Only an
explicit off, 0, false or no turns it off; anything else keeps it on. Host
allowlists are then not enforced; consent still is.
Always on:
The model is only ever told credential names. Values a tool echoes back (raw, URL-encoded or JSON-escaped) are redacted. A tool written to disguise a key (e.g. base64) could still reveal it; that is what consent and host allowlists are for.
Each tool process gets only the variables in its
REQUIRED_ENV, plus an allowlist of OS basics: PATH, temp dirs, locale, proxy and CA settings, and*_API_BASEoverrides. Nothing else from your host's environment reaches it (noAWS_*, noDATABASE_URL).Before anything a tool produces reaches the model (output, errors, tracebacks, schemas), secret values are replaced with
[REDACTED:NAME]. This covers raw, URL-encoded and JSON-escaped forms.
For a hard boundary, run AutoTool in a container with the guard off.
The guard also permits reads of files outside its explicit protected list. It does not isolate untrusted users, protect all local documents, enforce CPU/RAM/disk quotas, or prevent all network exfiltration. Loopback services and allowed hosts must be trusted. For generated code you do not trust, use an OS sandbox with minimal filesystem mounts and network permissions. Do not expose this stdio server as a public, multi-user service without a separate authenticated isolation layer.
The design and its evaluation are written up in the paper. The production review records the current evidence and boundaries; the next-capability proposal covers trusted reuse across agents.
Hosts
Host | Connect | Notes |
Claude Code |
| Headless |
Codex |
| Headless |
Claude Desktop, Cursor |
| Restart the app. |
OpenClaw |
| Older releases: setup prints the config snippet to paste. |
Anything else | point it at |
AutoTool speaks both MCP protocol eras: hosts on the 2026-07-28 revision get consent through an
input-required round trip and hear about new tools on subscriptions/listen; older hosts get a
form elicitation and notifications/tools/list_changed.
Development
python -m venv venv && venv/bin/pip install -e ".[dev]" # Windows: venv\Scripts\pip
pytest # offline suite
ruff check . && ruff format --check . # lint
autotool run "What is the top story on Hacker News?" # demo agent: needs [models] + a key in ./.env;
# no consent prompts or allowlists, uses ./tools
python scripts/auth_benchmark.py --trials 3 # credentials benchmark
python scripts/host_benchmark.py --trials 3 # Claude Code + custom-agent benchmarkBuilt on the MCP Python SDK 2.x, httpx2, the OpenAI SDK 3.x (Responses API) and the Anthropic
SDK 1.x.
Available Tools
2 toolscreate_toolA
Create a new tool when none of your current tools can do what the task needs (a web API, live data, a computation). Write a complete Python MCP tool server script (MCPServer); AutoTool verifies it in a guarded subprocess, injects only the credentials it declares, and mounts it: its tools appear in your tool list (or call them through run_tool). If verification fails you get the error; fix the code and call create_tool again with the same name.
The script MUST follow this contract:
It is one self-contained file that runs as
python <file>.pyand serves MCP over stdio.It uses
from mcp.server.mcpserver import MCPServerand createsmcp = MCPServer("<tool_name>").Every tool is a function decorated with
@mcp.tool()with full type annotations and a docstring that explains what it does and each parameter. Prefer simple parameter types (str, int, float, bool) with sensible defaults. Return astr(plain text orjson.dumps(...)of the result).The file ends with: if name == "main": mcp.run()
Only import the standard library,
httpx2,pydanticandmcp.Use
httpx2with an explicit timeout of at most 10 seconds for network calls. Use public APIs, or APIs whose credentials the prompt lists as available environment variables. Never hard-code credentials.Credentials: read each one with
os.environ["NAME"]and declare every name you read at module level, e.g.REQUIRED_ENV = ["NAME"]. Only declared names are injected into the process. Send keys in headers when the API allows it; never return, log or put key values in error messages.Make every external API base URL overridable through an environment variable named
<SERVICE>_API_BASE(e.g.HN_API_BASE), defaulting to the real public URL.Report failures the caller should see (an HTTP error status, nothing found) by raising
ToolError("...")frommcp.server.mcpserver.exceptions, with a clear message that names the service and status. Let unexpected errors raise: they fail the call, and the traceback reaches the verification harness. Never return an error as a normal string, and never swallow exceptions.No subprocesses, no filesystem writes, no
eval/exec.Keep the tool fast: bound fan-out (e.g. concurrent requests for at most ~30 items).
No credentials are available: only use public, keyless APIs and do not declare REQUIRED_ENV.
Structural reference:
import os
import httpx2
from mcp.server.mcpserver import MCPServer
from mcp.server.mcpserver.exceptions import ToolError
mcp = MCPServer("example_tool")
API_BASE = os.environ.get("EXAMPLE_API_BASE", "https://api.example.com")
@mcp.tool()
def get_thing(thing_id: int, verbose: bool = False) -> str:
"""Fetch a thing by id.
Args:
thing_id: Numeric id of the thing.
verbose: Include extra fields.
"""
with httpx2.Client(timeout=10) as client:
resp = client.get(f"{API_BASE}/things/{thing_id}")
if resp.status_code != 200:
raise ToolError(f"Example API returned HTTP {resp.status_code} for thing {thing_id}")
return resp.text
if __name__ == "__main__":
mcp.run()Inputs: code (required), name (required), test_tool, test_arguments.
run_toolA
Call a tool created with create_tool by its full name (e.g. 'weather_tool__current'). Use this if a newly created tool does not show up in your tool list.
Inputs: name (required), arguments.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
TDQS
Scored across 2 tools
create_tool and run_tool have clearly distinct purposes: one writes and mounts a new Python MCP server, the other invokes an already-created tool by name. There is no overlap in intent or expected arguments.
Both names follow a clean snake_case verb_noun pattern (create_tool, run_tool), sharing the same noun and differing only in the action verb. Fully predictable.
Two tools is minimal, but for a self-extending meta-server this is the core lifecycle: author a tool, then call it. The actual capability surface is unbounded via generated tools, so the small count is justified rather than thin.
The create/execute loop is fully covered and re-calling create_tool with the same name handles regeneration. Minor gaps remain: no explicit list of generated tools, no removal or inspection of mounted tool metadata, though the host tool list largely compensates.
Maintenance
Related MCP Connectors
MCP server for your apps' tools and custom tools, plus hosted AI agents and approval-gated workflows
Search, vet & assemble MCP servers from your agent: verified tools, risk labels, and trust scores.
MCP server for mandates, delegation, policy-gated execution, credential grants, and audit.
Toolstile is a managed MCP gateway that connects remote MCP servers behind one endpoint, with per-agent permissions, shared accounts and activity logs. Connect at https://mcp.toolstile.com/mcp over Streamable HTTP with OAuth; sign in at https://toolstile.com, select a workspace and connect your upstream servers. Available tools, resources and prompts depend on that workspace and the agent's granted access.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables AI agents to discover and execute tools via a secure MCP server with JWT authentication, RBAC, rate limiting, and audit logging.1MIT
- FlicenseNot gradedqualityCmaintenanceEnables AI agents to securely discover, execute, and observe tools with role-based access control and audit logging. Serves tools over MCP stdio and HTTP for integration with Claude Desktop, Cursor, and other clients.1-
- AlicenseAqualityBmaintenanceFinds MCP servers in the MCP Rating index and connects to them on demand, proxying their tools under namespaced names and notifying the client when tools change. Each server gets a short environment allowlist plus only the variables you name for it, so other API keys in your environment aren't passed on. Files aren't isolated unless you opt into Docker containers.13338 npm1MIT
- AlicenseNot gradedqualityBmaintenanceThis MCP server lets agents inspect every Model Context Protocol server on the machine, verify tools by running them in a sandbox, and check each call against a human-approved baseline so that changed or newly appeared tools are blocked before they execute. It also surfaces token cost, capability facts, and drift history for each tool entirely locally, without uploading inventory or requiring an account.2,051 PyPI1Apache 2.0