feat: add op_run and op_check_ref (use secrets without revealing plaintext)#12
Open
u2giants wants to merge 2 commits into
Open
feat: add op_run and op_check_ref (use secrets without revealing plaintext)#12u2giants wants to merge 2 commits into
u2giants wants to merge 2 commits into
Conversation
…vealing plaintext op_run executes a local command with op://vault/item/field references resolved into environment variables. The resolved plaintext is injected into the child process env only, redacted from all returned stdout/stderr and error messages, and never logged — the MCP equivalent of `op run`. This lets an agent USE a secret in a command/API call without ever placing the plaintext in the model context or transcript. op_check_ref validates an op:// reference and returns only non-secret metadata (vault, item, field label/type) confirming it resolves, so a reference can be checked before use without revealing the value. Both accept an optional OP_MCP_ALLOWED_VAULTS / --allowed-vaults allow-list; when unset (the default) any accessible vault is permitted, matching existing tool behavior. Adds a shared secret-ref parser and 19 tests (build + 98 tests green). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
u2giants
added a commit
to u2giants/1Password-MCP
that referenced
this pull request
Jul 16, 2026
…sitory#11; CakeRepository#12/CakeRepository#13 open) PR CakeRepository#7 is closed — the maintainer merged its item tools upstream through his own PR CakeRepository#11 (2026-07-04), so feat/item-get-edit-list is now historical, not the base for an open PR. Adds an "Upstream contributions" section documenting how new contributions are cut from fresh branches off upstream/master (genericizing fork-only defaults like the vibe_coding vault allow-list) and tracking the two currently-open PRs: CakeRepository#12 (op_run/op_check_ref) and CakeRepository#13 (reveal-default hardening). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
Adds two tools that let an agent use a 1Password secret without ever placing its plaintext into the model context or transcript — closing the gap between "read a secret" and "safely act with it."
op_runThe MCP equivalent of
op run -- <command>. Runs a local command withop://vault/item/fieldreferences (supplied inenv) resolved into the child process's environment variables. The resolved plaintext is:stdout/stderrand error messages (literal string replacement, so values with regex-special characters are handled), andSupports
command(via shell) orargv(no shell, safer against quoting), pluscwd,stdin,timeout_ms, and a customshell. Output is size-capped per stream.op_check_refValidates an
op://vault/item/fieldreference and returns only non-secret metadata (vault name, item title, field label/type) confirming it resolves. The field value is deliberately never returned — so a reference can be sanity-checked before use instead of reaching forpassword_read/item_getwithreveal.Why bulk secret resolution is needed
An
op_runcommand can require several secret environment variables: for example, an API key, database URL, webhook token, and service credential. The original implementation resolved eachop://reference independently. That was safe, but it meant one command generated one serial 1Password SDK request per environment value. Repeated agent calls and multiple MCP sessions can therefore consume request capacity unnecessarily.This change collects every
op://reference needed by oneop_runrequest, validates the vault allow-list first, then calls the SDK'ssecrets.resolveAll(...)once. The individual results are mapped back to the requested environment names only after the bulk response succeeds; the child process is never started on a resolution failure.This is deliberately a narrow, low-complexity improvement:
Resolved values remain in memory only for the active request and child-process environment, and are still redacted from returned output.
Optional vault allow-list
Both tools accept an optional
OP_MCP_ALLOWED_VAULTSenv var (or--allowed-vaults), a comma-separated list of vault names/IDs. When unset (the default), any accessible vault is permitted, matching the existing tools' behavior — so this is purely additive and non-breaking. Setting it restrictsop://resolution to the listed vaults.Implementation notes
src/secret-ref.tsparses/validatesop://references (reused by both tools).op_runnow callsclient.secrets.resolveAll(references)once per secret-bearing command rather than looping through individual resolutions.registerAllTools(); README tool table updated to 15.anyon public surfaces,errorResult/log/logError, conceal-by-default, no secrets in logs.Tests
Adds coverage for redaction, literal-passthrough, allow-list enforcement, metadata-only guarantees, and bulk environment resolution.
npm run build && npm testwere green when the change was prepared.🤖 Generated with Claude Code