You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat(mcp): add guided setup and per-tool approval management - #1284
Add guided MCP connection setup and per-tool permissions through ocr mcp, reusing the project's MCP Go SDK integration and Bubble Tea components.
Users can add or import a connection, confirm startup, discover its tools, select the tools they want, and choose when execution needs approval. The manager uses one full-screen session with separate server and action areas.
Main changes
Add connection management for stdio and remote Streamable HTTP, plus Cursor JSON / Codex TOML import. Import saves a disabled connection without starting it.
Separate model-visible tool selection from the independent execution-time authorization check. Automatic approval never enables additional tools.
Resolve global, server and tool permissions with parent deny taking precedence. Non-interactive / CI runs hide ask tools.
Provide Allow once, Allow this review, Deny once and Deny this review. Review-scoped decisions stay in memory. Approval timeout is configurable from 1–600 seconds, default 60.
Bind tool definitions and providers to the same fingerprinted, qualified identity. Changed definitions require acceptance; collisions cannot silently select another executor.
Bound discovery and results, validate connections, restrict inherited environment variables, redact credentials, and save configuration atomically with stale-write protection.
Preserve unknown JSON fields across model/MCP configuration updates using shared serialization helpers. Unknown fields do not grant access or restore revoked tools; the atomic private-file save path remains in place.
Preserve upstream's unified execution/failure reporting, bounded concurrent MCP shutdown, and native model replay support. Sensitive transcript copies and compression input are sanitized; raw traffic logging is disabled when a review exposes MCP tools. Ordinary tool calls retain upstream extra_content, while sensitive transcript copies omit opaque metadata without changing the live replay payload.
Update MCP guides, configuration, CLI and CI documentation in English, Chinese, Japanese, Russian and Korean, with documentation contract tests.
Compatibility changes
Empty or omitted tool lists now mean no enabled tools, not every server tool.
Legacy configuration cannot silently become unattended authorization; missing or changed fingerprints require review.
Legacy setup commands are no longer executed automatically during review.
Follow upstream's removal of OCR_CONFIG_PATH: configuration commands and review use the default user config. Tests and isolated examples use a dedicated HOME / USERPROFILE.
Non-loopback plaintext HTTP needs explicit opt-in. Server safety annotations are not authorization.
Review map
internal/mcp: policy, identity, discovery, authorization and transport boundaries.
cmd/opencodereview: manager, wizard/import, atomic configuration and review integration.
internal/llmloop / internal/session: sensitive-call reporting, native transcript and compression handling.
Tests and documentation account for approximately 46% and 11% of added lines respectively; implementation and supporting configuration account for the remainder.
Type of Change
Bug fix (non-breaking change that fixes an issue)
New feature (non-breaking change that adds functionality)
Breaking change (fix or feature that would cause existing functionality to change)
Refactoring (no functional changes)
Documentation update
CI / Build / Tooling
How Has This Been Tested?
Latest upstream-sync validation (5f8e5ab): make check, make build, full make test with race detection, make coverage (91.0%), action/plugin/MCP-documentation contracts, launcher/update tests, real-terminal management and all nine review-approval scenarios, Linux build, Windows CLI-test cross-compilation, and git diff --check passed.
The validation history for this PR also includes:
make check, make build, go test ./..., go vet ./... and git diff --check passed.
make test passed with race detection across all packages. Targeted race tests also passed for MCP, the LLM loop, sessions and the CLI.
make coverage passed at 91.0% after the latest upstream merge, above the 90% threshold.
Action/plugin/documentation contracts, launcher tests and update tests passed.
Documentation-site lint, typecheck, 38 tests, build and size checks passed. Two pre-existing React Hook lint warnings and Webpack size advisories remain; the enforced size check is 93.58 kB / 150 kB.
Linux and Windows cross-compilation passed. The latest update also recompiles the CLI test binary for Windows.
Based on 5f8e5ab, including #1031's shared frontend extraction, the narrowed English-only exemptions, upstream configuration-field preservation, removal of OCR_CONFIG_PATH, and tool-call extra_content replay. This PR does not modify extensions/. MCP argument redaction remains compatible with upstream tool-failure handling, JSON argument recovery, and aggregate token-budget enforcement.
The real-terminal regression harness covers setup/import, discovery with zero business calls, tool selection and revocation, save/back/cancel/timeout, all four approval choices, per-review cache reset, and CI ask/allow behavior. Integration tests additionally cover EOF, disabled/unselected tools, parent deny and fingerprint drift. Denied or canceled cases assert zero underlying MCP calls.
A small live-service smoke test used the locally configured fast-context MCP and deepseek-ai/deepseek-v4-flash through an OpenAI-compatible endpoint:
Scenario
Approval prompts
Actual MCP calls
Review result
Allow once
1
1
Completed; found the intended boundary regression
Deny this review
1
0
Completed from the existing diff; did not retry the search
The input was one nine-line Go file with a one-line change. Six model requests were made in total. An isolated forwarding/counting harness was used; model replies and MCP results were not simulated. Persistent configuration stayed unchanged, and credential checks passed. Other permission combinations are covered by automated tests, not by additional live-model runs.
make test passes locally
Terminal interaction testing through automated PTY harnesses, including the two live-service scenarios above
Checklist
My code follows the project's coding style (go fmt, go vet)
I have performed a self-review of my code
I have added tests that prove my fix is effective or my feature works
New and existing unit tests pass locally with my changes
I have updated the documentation accordingly (if applicable)
CLA check passes (license/cla)
Related to #1281. This PR does not close the issue.
Heads up — #1031 just landed on main and moved the VS Code webview and shared types into a new extensions/frontend/ package, so please rebase onto the latest main and relocate any changes under extensions/vscode/src/webview/ or extensions/vscode/src/shared/ to extensions/frontend/src/.
Heads up — #1031 just landed on main and moved the VS Code webview and shared types into a new extensions/frontend/ package, so please rebase onto the latest main and relocate any changes under extensions/vscode/src/webview/ or extensions/vscode/src/shared/ to extensions/frontend/src/.注意—— #1031 刚刚合并到主分支,并将 VS Code webview 和共享类型移到了一个新的 extensions/frontend/ 包中,因此请基于最新的主分支进行 rebase,并将 extensions/vscode/src/webview/ 或 extensions/vscode/src/shared/ 的任何更改迁移到 extensions/frontend/src/ 。
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
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.
Description
Add guided MCP connection setup and per-tool permissions through
ocr mcp, reusing the project's MCP Go SDK integration and Bubble Tea components.Users can add or import a connection, confirm startup, discover its tools, select the tools they want, and choose when execution needs approval. The manager uses one full-screen session with separate server and action areas.
Main changes
denytaking precedence. Non-interactive / CI runs hideasktools.extra_content, while sensitive transcript copies omit opaque metadata without changing the live replay payload.Compatibility changes
setupcommands are no longer executed automatically during review.OCR_CONFIG_PATH: configuration commands and review use the default user config. Tests and isolated examples use a dedicatedHOME/USERPROFILE.Review map
internal/mcp: policy, identity, discovery, authorization and transport boundaries.cmd/opencodereview: manager, wizard/import, atomic configuration and review integration.internal/llmloop/internal/session: sensitive-call reporting, native transcript and compression handling.Type of Change
How Has This Been Tested?
Latest upstream-sync validation (
5f8e5ab):make check,make build, fullmake testwith race detection,make coverage(91.0%), action/plugin/MCP-documentation contracts, launcher/update tests, real-terminal management and all nine review-approval scenarios, Linux build, Windows CLI-test cross-compilation, andgit diff --checkpassed.The validation history for this PR also includes:
make check,make build,go test ./...,go vet ./...andgit diff --checkpassed.make testpassed with race detection across all packages. Targeted race tests also passed for MCP, the LLM loop, sessions and the CLI.make coveragepassed at 91.0% after the latest upstream merge, above the 90% threshold.Based on
5f8e5ab, including #1031's shared frontend extraction, the narrowed English-only exemptions, upstream configuration-field preservation, removal ofOCR_CONFIG_PATH, and tool-callextra_contentreplay. This PR does not modifyextensions/. MCP argument redaction remains compatible with upstream tool-failure handling, JSON argument recovery, and aggregate token-budget enforcement.The real-terminal regression harness covers setup/import, discovery with zero business calls, tool selection and revocation, save/back/cancel/timeout, all four approval choices, per-review cache reset, and CI ask/allow behavior. Integration tests additionally cover EOF, disabled/unselected tools, parent deny and fingerprint drift. Denied or canceled cases assert zero underlying MCP calls.
A small live-service smoke test used the locally configured fast-context MCP and
deepseek-ai/deepseek-v4-flashthrough an OpenAI-compatible endpoint:The input was one nine-line Go file with a one-line change. Six model requests were made in total. An isolated forwarding/counting harness was used; model replies and MCP results were not simulated. Persistent configuration stayed unchanged, and credential checks passed. Other permission combinations are covered by automated tests, not by additional live-model runs.
make testpasses locallyChecklist
go fmt,go vet)license/cla)Related to #1281. This PR does not close the issue.