Skip to content

Scope network interception to MCP sessions#753

Open
shaun0927 wants to merge 1 commit into
developfrom
fix/752-session-network-intercept
Open

Scope network interception to MCP sessions#753
shaun0927 wants to merge 1 commit into
developfrom
fix/752-session-network-intercept

Conversation

@shaun0927
Copy link
Copy Markdown
Owner

Summary

  • Routes network_intercept through the canonical src/network-interceptor.ts implementation.
  • Scopes network interception/offline state by MCP session id to prevent cross-session rule leakage.
  • Adds optional device_id targeting and tests for session isolation / clear behavior.

Closes #752.

Direction/scope review

  • Aligned with OpenSafari reliability: stale intercept rules can break later Safari/webview QA flows.
  • Minimal and low-risk: preserves block/modify user-facing actions and adds no dependencies.
  • Avoids unrelated network feature expansion; per-rule removal remains a future decision.

Verification

  • npm test -- --runTestsByPath tests/unit/network-interceptor.test.ts tests/unit/network-intercept-tool.test.ts
  • npm run lint -- --quiet src/tools/network-intercept.ts src/tools/network-offline.ts tests/unit/network-intercept-tool.test.ts
  • npm run build

Live validation after merge

  • Start two MCP sessions; add a rule in session A and confirm session B has no state leakage.
  • Add a modify rule and confirm mocked fetch response.
  • Clear session A and confirm fetch/XHR behavior is restored.

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

Constraint: Preserve existing network_intercept block/modify behavior while preventing cross-session rule leakage.
Rejected: Keep module-global activeRules | long-lived MCP processes can leak stale rules into unrelated sessions.
Confidence: high
Scope-risk: narrow
Directive: Future per-rule removal should build on session-scoped interceptors rather than reintroducing module-global state.
Tested: npm test -- --runTestsByPath tests/unit/network-interceptor.test.ts tests/unit/network-intercept-tool.test.ts; npm run lint -- --quiet src/tools/network-intercept.ts src/tools/network-offline.ts tests/unit/network-intercept-tool.test.ts; npm run build
Not-tested: Live two-session Safari interception.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant