Skip to content

feat: allow session-only inherited MCP exclusions - #4761

Merged
zeval merged 21 commits into
mainfrom
feature/allow-session-only-i-2gn
Oct 29, 2026
Merged

zeval merged 21 commits into
mainfrom
feature/allow-session-only-i-2gn

Conversation

@zeval

@zeval zeval commented Oct 24, 2026 •

Copy link
Copy Markdown
Member

Tip

PR walkthrough: Open the visual walkthrough

Inherited MCP servers can now be excluded from one existing agent session and restored without changing shared defaults or sibling sessions. Saved exclusions survive restarts and apply at idle or the next start, preserving the active turn's delivered tools.

Important Changes

Validation

  • MCP race tests, real PostgreSQL concurrency/collation checks, frontend tests, desktop/phone journeys, typecheck, translations, docs/spec checks, and normal hooks passed. Detailed receipts and earlier failures are in the plan.
  • Review fix: Retry preserves rejected drafts and requires Reload choices after failed saves. Recovery tests pass; screenshots show the corrected flow.
  • CI remediation covers stale Settings hydration and browser fixture ordering, gesture targeting, cleanup and exact assertions. Reproducing regressions failed before the fixes; affected checks pass without retries. Fresh CI is tracked on this PR.

Checklist

  • If I do not have repository write access and this is a large architectural change, I discussed the direction in a linked issue before opening this PR.
  • This PR contains one logical change; unrelated work is split into separate PRs.
  • I have performed a self-review of my code.
  • I have manually tested my changes and they work as expected.
  • My changes have tests that cover the new functionality and edge cases.
  • If my change touches UI files (apps/web/), I have added or updated Playwright e2e tests in apps/web/e2e/ and verified them with make test-e2e.
  • I checked whether this affects public docs in docs/public/** and updated them or noted why no docs change is needed.

Screenshots

Desktop: reload saved MCP choices before application retry

Phone: touch-sized Reload choices recovery

@coderabbitai

coderabbitai Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Summary

Summary by CodeRabbit

  • New Features
    • Customize MCP servers for an individual task session by excluding inherited servers or restoring inheritance without changing workspace selections. Updates apply at a safe reconnect point.
    • View saved exclusions, including dormant exclusions for disabled servers, and see when a server is excluded. Choices persist across reloads and restarts.
    • Restoring inheritance does not add servers that are no longer inherited or enable disabled servers. Required tools and provider-managed servers remain controlled separately.
  • Bug Fixes
    • Excluded servers stay out of the setup sent to the agent, including when they have alternate names.
    • Failed applications retain the last accepted setup for comparison. Conflicting updates preserve saved choices and drafts; reload choices before retrying a rejected save.

This change adds task-session MCP exclusions. The backend stores exclusions with session selections and removes excluded definitions during resolution. The web interface supports exclusion and restoration with revision-aware saves. Tests and documentation cover persistence, lifecycle application, recovery, and responsive controls.

Changes: Task-session MCP exclusions

Layer / File(s) Summary
Persist and validate exclusions
apps/backend/internal/agent/mcpconfig/*, apps/backend/internal/agent/settings/handlers/*, apps/backend/internal/agent/settings/store/*, apps/backend/internal/backendapp/*
Selection conditions and snapshots carry exclusion IDs. Handlers parse and return them. The store validates, persists, reads, and cleans up exclusions.
Resolve exclusions and apply session updates
apps/backend/internal/agent/mcpconfig/*, apps/backend/internal/agent/runtime/lifecycle/*, apps/backend/internal/agentctl/types/streams/*
Resolution omits excluded definitions and records session_excluded decisions. Comparisons include exclusions. Tests cover deferred, accepted, and failed application states.
Expose session controls and revision-aware saves
apps/web/components/task/chat/mcp-explorer/*, apps/web/components/task/mcp-session-selector.tsx, apps/web/hooks/domains/session/*, apps/web/hooks/domains/workspace/*, apps/web/lib/api/domains/mcp-api.*, apps/web/lib/types/http-mcp.ts, apps/web/src/locales/*
The web API and selection hooks save exclusions. The picker supports exclusion, restoration, dormant, and pending states. Locales describe session scope and limits.
Verify flows and document behavior
apps/web/e2e/*, apps/backend/internal/agent/settings/store/*, docs/*
Tests cover conflicts, persistence, restoration, dormant exclusions, lifecycle recovery, and responsive controls. Requirements, design, plans, and public guidance describe the behavior.

Priority: Normal

Estimated code review effort: 4 (Complex) | ~60 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant MCPSessionSelector
  participant useTaskSessionMCPSelection
  participant replaceMCPSelections
  participant mcpSelectionHandlers
  participant SelectionService
  participant sqliteRepository
  MCPSessionSelector->>useTaskSessionMCPSelection: Save excluded definition IDs
  useTaskSessionMCPSelection->>replaceMCPSelections: Send revision and exclusions
  replaceMCPSelections->>mcpSelectionHandlers: PUT selection condition
  mcpSelectionHandlers->>SelectionService: Validate condition and context
  SelectionService->>sqliteRepository: Write selections and exclusions
Loading

Suggested reviewers: jcfs, carlosflorencio

Merge Risk: Low · up to 289c2

The remaining concerns affect test reliability rather than production behavior, but should be addressed to keep capture artifacts independent and recovery checks causally synchronized.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 24.49% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title is concise, specific, and accurately describes the main change: session-only exclusions for inherited MCP servers.
Description check Passed The description includes the required summary, important changes, validation, and checklist sections. It explains the session-only exclusion behavior, persistence, UI changes, and test coverage. Optio…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description includes the required summary, important changes, validation, and checklist sections. It explains the session-only exclusion behavior, persistence, UI changes, and test coverage. Optional sections are appropriately omitted.

Full details: Docstring Coverage

Explanation

Docstring coverage is 24.49% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 49 functions across 56 files. (1 skipped: 1 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

I hop through catalogs, neat and bright
Exclusions hide one server from sight
Revisions guard each careful choice
Restore lets inheritance rejoice
Tests watch the session trail
A rabbit cheers when saves prevail

Comment @coderabbitai help to get the list of available commands.

@zeval

zeval commented Oct 24, 2026

Copy link
Copy Markdown
Member Author

Screenshots

Desktop: exclude an inherited server for this session while preserving its origins.

Phone: restore inheritance using the session-only controls.

@claude

claude Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Claude encountered an error after 0s —— View job


I'll analyze this and get back to you.

@github-actions github-actions Bot added the big Pull request changes 51 or more application files label Oct 24, 2026
@zeval
zeval force-pushed the feature/clarify-mcp-assignme-mhh branch from 6faaa61 to fe08307 Compare October 25, 2026 15:03
@zeval

zeval commented Oct 25, 2026

Copy link
Copy Markdown
Member Author

Refreshed desktop and phone evidence after integration with assignment WO03.

Desktop: session exclusion after assignment integration

Phone: restore inheritance for this session

@zeval
zeval force-pushed the feature/allow-session-only-i-2gn branch from 69be161 to 9d5a525 Compare October 25, 2026 15:30
@zeval
zeval force-pushed the feature/clarify-mcp-assignme-mhh branch from fe08307 to f3be6a5 Compare October 25, 2026 20:14
@zeval
zeval force-pushed the feature/allow-session-only-i-2gn branch from 9d5a525 to 77a3e83 Compare October 25, 2026 20:20
@zeval
zeval force-pushed the feature/clarify-mcp-assignme-mhh branch from f3be6a5 to 7604e81 Compare October 26, 2026 01:32
@zeval
zeval force-pushed the feature/allow-session-only-i-2gn branch from 77a3e83 to fd8bb59 Compare October 26, 2026 01:44
@zeval
zeval force-pushed the feature/clarify-mcp-assignme-mhh branch 7 times, most recently from e14cef8 to 33d0c75 Compare October 27, 2026 02:08
@zeval
zeval force-pushed the feature/allow-session-only-i-2gn branch from fd8bb59 to 359158d Compare October 27, 2026 23:03
Base automatically changed from feature/clarify-mcp-assignme-mhh to main October 28, 2026 14:20
@zeval
zeval marked this pull request as ready for review October 28, 2026 14:50
@zeval
zeval temporarily deployed to opencode-review-trusted October 28, 2026 14:50 — with GitHub Actions Inactive
@greptile-apps

greptile-apps Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 4/5

[Medium impact] The PR changes MCP configuration for individual sessions and adds a bounded server-assignment path.

The PR appears safe to merge, with a non-blocking recovery issue where application Retry clears rejected checkbox edits.

Findings

  1. P2 Application Retry clears edits ▶

Summary

Adds persistent, reversible exclusions for inherited MCP servers in one existing session.

  • Each task session can hide an inherited MCP server and restore it later.
  • After registering an MCP server, members can open its settings for a chosen destination.
  • Unrelated review, task, and test-helper edits keep their existing behavior.

Review used source and test inspection. No tests or browser checks were run.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Session Customize] --> B[Check saved revision]
  B -->|Matches| C[Save additions and exclusions together]
  B -->|Changed| D[Keep choices and offer reload]
  C --> E[Advance desired revision]
  E --> F{Agent can apply now?}
  F -->|Busy or unsupported| G[Wait for idle or next start]
  F -->|Eligible idle| H[Resolve inherited set minus exclusions]
  G --> H
  H --> I[Deliver desired setup]
  I -->|Accepted| J[Save accepted setup]
  I -->|Failed| K[Keep saved choice and last accepted baseline]
Loading

Reviews (1) · Last reviewed commit: "chore: integrate reviewed assignment upd..." · Reviewed by Greptile

Comment thread apps/web/hooks/domains/session/use-task-session-mcp-selection.ts Outdated
@zeval
zeval force-pushed the feature/allow-session-only-i-2gn branch from 8a71af4 to c8ea290 Compare October 28, 2026 15:15
@zeval
zeval had a problem deploying to opencode-review-trusted October 28, 2026 15:15 — with GitHub Actions Error
@zeval

zeval commented Oct 28, 2026

Copy link
Copy Markdown
Member Author

Screenshots

Recovery after a rejected save, captured from b1d7055 on isolated synthetic test data. Reload choices restores the accepted revision before application retry becomes available.

Desktop: reload saved MCP choices before application retry

Phone: touch-sized Reload choices recovery

@zeval
zeval temporarily deployed to opencode-review-trusted October 28, 2026 15:28 — with GitHub Actions Inactive
@zeval

zeval commented Oct 28, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@zeval

zeval commented Oct 28, 2026

Copy link
Copy Markdown
Member Author

@claude review

Please review the current head b1d7055, including session-only exclusions and the application-retry draft-preservation correction. Report findings as comments only.

@zeval
zeval force-pushed the feature/allow-session-only-i-2gn branch from fe1e2b0 to d7b7dc4 Compare October 28, 2026 22:22
@zeval
zeval temporarily deployed to opencode-review-trusted October 28, 2026 22:22 — with GitHub Actions Inactive
@zeval

zeval commented Oct 28, 2026

Copy link
Copy Markdown
Member Author

Rebased onto current main a33ff4139ada169271a8177fa181c45b0c0176e7 after upstream translation additions conflicted. All eight task catalogs preserve the exact semantic union; the exclusion reason now sits beside the other MCP reasons, with unchanged values. Backup: backup/exclusions-before-main-a33ff-20261028.

Validation: 73 frontend cases, typecheck, translations, five affected backend race packages, two desktop and two phone MCP journeys, harness/spec checks and normal hooks pass. Seven focused smoke cases and translations pass again at the final commit. No feature or fixture logic changed in this rebase.

The previous head's complete 118-report audit contains 4,444 passing attempts, 40 skips and zero retries/errors. Its final E2E aggregation job was still queued when this conflict-resolution push superseded it; those results are historical. Fresh CI is required for the new head.

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@zeval
zeval temporarily deployed to opencode-review-trusted October 29, 2026 00:10 — with GitHub Actions Inactive
@zeval

zeval commented Oct 29, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

Please review 83c1ff0. It refreshes stale Settings workspace snapshots and corrects two browser fixtures. Focused tests and normal hooks passed; fresh CI is running.

@coderabbitai

coderabbitai Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@zeval
zeval temporarily deployed to opencode-review-trusted October 29, 2026 01:12 — with GitHub Actions Inactive
@zeval

zeval commented Oct 29, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

Please review 289c244. Two test-only corrections wait for the runtime update request after touch approval and target the declared Threads question scroll owner. Controlled reproductions failed before and passed after each fix; the probes were removed. Normal hooks and focused browser cases passed.

@coderabbitai

coderabbitai Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔇 Additional comments: 1
docs/plans/session-mcp-exclusions/plan.md-1086-1086: 1

1086-1086: Minor · Maintainability & Code Quality · Quick win

⚠️ Unverified finding
Verification ran but could not confirm this finding. It is shown for review, not as a verified issue.

Replace the unclear compound phrase.

request-admission delay is flagged as a spelling error and is unclear. Use delay before request admission or another established term.

Source: Linters/SAST tools


Review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: QUIET
  • Plan: Advanced
  • Run ID: 836df24a-871d-437f-8e61-656e8aaeb1a2
Commits

Reviewing files that changed from the base of the PR and between 83c1ff0 and 289c244.

Files selected for processing: 3
  • apps/web/e2e/tests/settings/mobile-agent-runtime-update.spec.ts
  • apps/web/e2e/tests/task/threads-clarification-helpers.ts
  • docs/plans/session-mcp-exclusions/plan.md

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review.

@zeval

zeval commented Oct 29, 2026

Copy link
Copy Markdown
Member Author

Reviewed the grouped note in review 5691743635. The phrase “request-admission delay” means a temporary 250 ms delay before the mocked request reaches its handler. The surrounding verification record gives the delay, the exact expected-one/actual-zero failure, and both reproduction logs. This is an optional wording suggestion, not a verified defect; the historical test receipt remains unchanged. No production API or user-facing copy uses this phrase.

The two test-reliability concerns retained in the summary are already addressed: distinct capture keys and verified manifests, and default recovery visibility timeout after causal state/error checks. The generic docstring-percentage advisory was also dispositioned in the first reply; no missing behavioral contract was identified. There are no unresolved inline threads at 289c244. Fresh CI remains in progress.

@zeval
zeval merged commit f2e47b5 into main Oct 29, 2026
111 checks passed
@zeval
zeval deleted the feature/allow-session-only-i-2gn branch October 29, 2026 10:30

This branch was previously deployed

1 inactive deployment
opencode-review-trusted — 289c2445 Deployed Oct 29, 2026 by zeval via pr-walkthrough-generate #9292
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

big Pull request changes 51 or more application files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant