Skip to main content

keyexec

PyPI Python CI License: MIT

Claude Code keeps the tokens you give an MCP server, the env and headers values of a server added with claude mcp add, in plaintext in ~/.claude.json. keyexec moves them into the operating system's credential store (Windows Credential Manager or the macOS Keychain) and leaves a command in their place, so the config file no longer holds any secret and a token is handed to its server only when the server starts.

It is a launcher, not a password manager: no vault, no sync, no daemon, no runtime dependencies. It protects the file, not your account: any program running as you can still read the credential store (Security model).

keyexec in Windows Terminal: the migrate plan for three servers lists each token by name and length only, the apply stores them and names the backup, and doctor finds every entry the rewritten config refers to

Status: in daily use on Windows, and checked end to end on macOS, where a Claude Code session connected one stdio and one http server through keyexec.

How it works

Each token becomes an entry: a named item in the credential store, such as github-token. keyexec migrate --apply stores the token as that entry and rewrites the server to start through keyexec:

 "github": {
-  "command": "npx",
-  "args": ["-y", "gh-mcp"],
-  "env": { "GITHUB_TOKEN": "ghp_..." }
+  "command": "C:\\Users\\me\\.local\\bin\\keyexec.exe",
+  "args": ["run", "--env", "GITHUB_TOKEN=github-token", "--", "npx", "-y", "gh-mcp"]
 }

When Claude Code starts the server, keyexec run reads github-token from the store, starts npx -y gh-mcp with GITHUB_TOKEN set, and stays out of the way: it writes nothing to the server's stdio stream, ends the server when it is itself stopped, and returns the server's exit code. An http server gets a headersHelper instead, a command whose output Claude Code sends as request headers: "<keyexec>" headers --header "Authorization=Bearer {acme-authorization}".

keyexec reads the user and local scopes in ~/.claude.json. A repo's .mcp.json is not touched; keep its tokens out of the repo by hand.

run is not tied to MCP: keyexec run --env GH_TOKEN=github-token -- gh pr status gives any command a token without it sitting in your shell profile.

Quickstart

You need uv (it fetches a suitable Python) and Claude Code on Windows or macOS.

uv tool install keyexec
keyexec migrate              # the plan: which plaintext tokens would move, to which entries; changes nothing
keyexec migrate --apply      # store them, back up the config, rewrite it; asks first

Then restart your Claude Code sessions, or reconnect each server from /mcp, and check that the servers connect. keyexec doctor confirms every entry the config refers to exists:

Config: C:\Users\me\.claude.json
github  [stdio]
  ok       github-token

Once the servers work, delete the backup migrate named (~/.claude.json.keyexec-backup-<timestamp>): it still holds the plaintext tokens, and doctor warns until it is gone.

If the plan is empty, no token was found in plaintext. If --apply stops because the config changed, Claude Code wrote the file meanwhile; run it again.

To add a server by hand, store the token first, then point the server at keyexec:

keyexec set github-token     # prompts for the value; never read from argv or a pipe
claude mcp add github -- keyexec run --env GITHUB_TOKEN=github-token -- <server command> [args...]

A rotated token is replaced with keyexec set <entry> --force; the config does not change.

Install and upgrade

Install it as a tool rather than running it through uvx: migrate --apply writes the absolute path of the installed keyexec into the config, and a uvx cache path can disappear.

Upgrade with uv tool upgrade keyexec. It updates the tool in place and works while Claude Code runs. On Windows, uv tool upgrade is the only change to make while it runs: uv tool install --force, --reinstall, and a uv tool install that changes where keyexec comes from (a checkout to PyPI, say) can each delete and recreate the tool environment, whose python.exe every running server holds open, and leave the tool without its packages. Make those with Claude Code closed.

Releases are built by GitHub Actions and published to PyPI through trusted publishing, with attestations, so no long-lived upload token exists.

Commands

Besides migrate and doctor, set, list and delete manage entries by hand, and run and headers are what a rewritten config calls. The commands that report something print JSON when their output is piped. docs/cli.md lists every command with its flags, and has the JSON formats, the exit codes, and exactly what migrate treats as a secret, how it names entries and what it skips.

Security model

What it protects against: tokens sitting in plaintext in ~/.claude.json, and leaking from there through backups, dotfile syncs, screenshares, pasted configs, or tools and agents that read the file.

What it does not protect against:

  • Any process running as you can read the credential store. On Windows, Credential Manager entries are readable by every process of the logged-in user without a prompt; on macOS the Keychain may prompt per application, but "Always Allow" removes that barrier. An agent with shell access can read an entry with a few lines of code.
  • A running server holds its token in its environment, visible to same-user tools that inspect process environments.
  • The migrate backup holds the plaintext tokens until you delete it.
  • A secret passed in a server's command-line arguments rather than env or headers is not moved; migrate warns when it sees one.

keyexec makes no network requests and writes no log or file of its own besides the migrate backup. Report a vulnerability privately as described in SECURITY.md.

Troubleshooting

  • A server does not connect after the migration. Run keyexec doctor: a MISSING entry is one the store does not hold; store it with keyexec set <entry>. To see why a server will not start, run its command and args from the config in a terminal: keyexec says what is wrong before it starts anything.
  • keyexec exits 4. The credential store refused or is locked; on macOS, unlock the login Keychain. Over SSH the login Keychain usually stays locked: doctor and list, which read no value, still work, but a server started there cannot get its token. On Linux keyexec refuses to run rather than fall back to a plaintext store.
  • macOS asks for your password. Entries keyexec wrote are read without a prompt, because the Keychain lets the program that created an item read it. Deleting an entry asks for your login password, and a different Python executable, for instance after a uv tool upgrade that replaces it, may be asked to confirm access.
  • A value is refused as too long. Credential Manager limits the size of one entry; Platform notes has the number.

Undoing it

For one server: set its command back to the first word after -- in args, set args to the rest, and put the token back under env (for an http server, remove headersHelper and put the header back under headers). Then keyexec delete <entry>. Restoring the backup instead would undo whatever Claude Code wrote since.

For everything: undo each server, delete each entry keyexec list shows, then uv tool uninstall keyexec.

Platform notes

Windows. Each entry is a generic credential with the target keyexec:<entry>, kept on this machine only rather than roaming with a domain profile, and holding at most 2560 bytes; cmdkey /list shows the names without the values. When Claude Code exits, or keyexec is killed outright, the server and everything it started end with it.

macOS. Each entry is a generic password in the login Keychain with the service keyexec and the entry name as account. An update changes the item in place, so an "Always Allow" survives a rotated token. run forwards SIGINT, SIGTERM and SIGHUP to the server.

Linux. Not supported: keyexec talks to Windows Credential Manager and the macOS Keychain only. envchain does the same job well on Linux and macOS.

Development

See CONTRIBUTING.md for setup and the checks CI runs, and docs/design.md for why the code is shaped the way it is.

Not affiliated with Anthropic

keyexec is an independent tool for Claude Code users. It is not made, endorsed or supported by Anthropic.

License

MIT

Metadata

Release files for keyexec 0.1.1

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

Source distribution (sdist)

Source distribution for keyexec 0.1.1
File Size Uploaded Provenance Actions
keyexec-0.1.1.tar.gz 25.0 kB With provenance Details for keyexec-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for keyexec 0.1.1
File Interpreter ABI Platform Actions
keyexec-0.1.1-py3-none-any.whl Python 3 none any Details for keyexec-0.1.1-py3-none-any.whl

Total release size: 54.3 kB

Release files / keyexec-0.1.1.tar.gz

Download URL keyexec-0.1.1.tar.gz
Size 25.0 kB
Tags Source
SHA-256 checksum
How to use checksums
d19136fc011b6feb121851f354832d53f061365cd63059101d3ed41c8cfa6832
BLAKE2b-256 checksum
How to use checksums
fac005fdc7a22777e868ca813f4f0d644ca19bebdaf3ee99fc34bbd048c12b18
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 30, 2026.

Transparency log

Release files / keyexec-0.1.1-py3-none-any.whl

Download URL keyexec-0.1.1-py3-none-any.whl
Size 29.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b3afa3dbe13b4d1f3757d6336ec0b978735af2d8ac0434f1fe560e988a276323
BLAKE2b-256 checksum
How to use checksums
c4d4eefb1142b636b6fdb3d746cb5ec3252ea07ca324b223730613993ec95ae0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 30, 2026.

Transparency log

Security for keyexec 0.1.1

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 keyexec-0.1.1.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 Nov 30, 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.1.1 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