Skip to content

[3595 by Claude Opus 5.5] MCP: result redaction removes token counts from cost data and hides the token-alert settings - #3611

Merged
integry merged 1 commit into
3595-epic-0-9-h9lfrom
3595/claude-opus-5-5-mcp-result-redaction-remo-20261117-0119-jch
Nov 17, 2026
Merged

integry merged 1 commit into
3595-epic-0-9-h9lfrom
3595/claude-opus-5-5-mcp-result-redaction-remo-20261117-0119-jch

Conversation

@propr-dev

@propr-dev propr-dev Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

AI Implementation Summary

Closes #3595

Branch: 3595/claude-opus-5-5-mcp-result-redaction-remo-20261117-0119-jch
Commits: ✅ Changes committed (d9399af)


AI Processing Completed

Execution Details:

Summary:
MCP tools now return token counts and the token-alert settings. Values that could be credentials under token-named keys are still removed. All 470 other MCP tests and the new ones pass, except one MCP tunnel registration test that failed once during the full run. That test passes when run alone (17/17, twice) and doesn't involve redaction. Lint and typecheck are clean.

The change (packages/api/mcp/adapter.ts): the old single key filter is split in two.

  • Other key classes (secret, password, credential, private key, API key, access key, cookie, authorization, worktree/stored path, job_data, container_env): still always dropped, whatever the value. That rule is unchanged.
  • token-named keys: kept only if the value can't hold a credential: a number, boolean or null, or a plain object or array made only of those. A string, or a container with any string inside, is still dropped. That covers access, bearer, instance and refresh tokens and tokenHash, and also number-looking strings like "1200" and JSON-encoded strings.
  • Buffers, typed arrays and dates under a token key are also dropped, because a byte array could be a token's raw bytes.
  • Old exemption removed: the one-off pr_review_max_context_tokens exemption is gone; the general rule covers it.
  • No allow-list of setting names to maintain.

Effect on the two tools in the issue:

  • get_cost_breakdown rows and totals now include input_tokens, output_tokens, cache_creation_input_tokens and cache_read_input_tokens, the same as GET /api/stats/cost.
  • get_execution_settings now includes all five token_outlier_* settings.

Tests:

  • New packages/api/test/mcpResultRedaction.test.ts: a table of keys and values that must be kept and must be removed. Each one is checked at the top level, nested in an object, inside an array, as a JSON-encoded string, and as a JSON string inside an object. It also checks that a kept token container is still redacted inside.
  • costExport.test.ts: a new test runs redaction on the get_cost_breakdown output and checks it matches the GET /api/stats/cost response.
  • mcpReviewerConcurrency.test.ts: the settings round-trip now writes and reads back the token_outlier_* values through the real MCP call path.

Against the original adapter, the new tests and the settings round-trip fail.

I didn't create a visual preview because this change only affects API data.

Review digest

Risk-tiered paths

  • High risk: none
  • Normal risk (1 file)
    • packages/api/mcp/adapter.ts (+23/−1)
  • Low risk (3 files)
    • packages/api/test/costExport.test.ts (+21/−0)
    • packages/api/test/mcpResultRedaction.test.ts (added, +89/−0)
    • packages/api/test/mcpReviewerConcurrency.test.ts (+1/−1)

Validation evidence

  • No repository validation commands ran.

Diff size: 4 files changed, +134/−2 lines

Detailed Logs:

  • Conversation: 77 messages
  • Session: 04e45199-7bd7-4c50-8543-9d1dea7283d6

Log files stored at:

  • conversation: /usr/src/app/logs/executions/issue-3595-2026-11-17T01-35-20-688Z-conversation.json
  • output: /usr/src/app/logs/executions/issue-3595-2026-11-17T01-35-20-688Z-output.txt
Latest Conversation Messages
ASSISTANT: [content unavailable]

ASSISTANT: MCP tools now return token counts and the token-alert settings. Values that could be credentials under `token`-named keys are still removed. All 470 other MCP tests and the new ones pass, except one M...


This PR was created automatically by ProPR after processing issue #3595.


💡 Need changes?

Comment on this PR to request refinements — the AI agent monitors comments and will update the implementation based on your feedback. Keep iterating until you're satisfied!

…s that could be credentials under `token`-named keys are still removed. All 470 other MCP tests and the new ones pass, except one MCP tunnel registration test that failed once during the full run. That test passes when run alone (17/17, twice) and doesn't involve redaction. Lint and typecheck are clean.

The change (`packages/api/mcp/adapter.ts`): the old single key filter is split in two.
- Other key classes (`secret`, `password`, `credential`, private key, API key, access key, `cookie`, `authorization`, worktree/stored path, `job_data`, `container_env`): still always dropped, whatever the value. That rule is unchanged.
- `token`-named keys: kept only if the value can't hold a credential: a number, boolean or null, or a plain object or array made only of those. A string, or a container with any string inside, is still dropped. That covers access, bearer, instance and refresh tokens and `tokenHash`, and also number-looking strings like `"1200"` and JSON-encoded strings.
- Buffers, typed arrays and dates under a `token` key are also dropped, because a byte array could be a token's raw bytes.
- Old exemption removed: the one-off `pr_review_max_context_tokens` exemption is gone; the general rule covers it.
- No allow-list of setting names to maintain.

Effect on the two tools in the issue:
- `get_cost_breakdown` rows and totals now include `input_tokens`, `output_tokens`, `cache_creation_input_tokens` and `cache_read_input_tokens`, the same as `GET /api/stats/cost`.
- `get_execution_settings` now includes all five `token_outlier_*` settings.

Tests:
- New `packages/api/test/mcpResultRedaction.test.ts`: a table of keys and values that must be kept and must be removed. Each one is checked at the top level, nested in an object, inside an array, as a JSON-encoded string, and as a JSON string inside an object. It also checks that a kept token container is still redacted inside.
- `costExport.test.ts`: a new test runs redaction on the `get_cost_breakdown` output and checks it matches the `GET /api/stats/cost` response.
- `mcpReviewerConcurrency.test.ts`: the settings round-trip now writes and reads back the `token_outlier_*` values through the real MCP call path.

Against the original adapter, the new tests and the settings round-trip fail.

I didn't create a visual preview because this change only affects API data.
@propr-dev

propr-dev Bot commented Nov 17, 2026

Copy link
Copy Markdown
Contributor Author

/ultrafix goal=8 max=6
Triggered automatically by the requested execution settings.

@propr-dev

propr-dev Bot commented Nov 17, 2026

Copy link
Copy Markdown
Contributor Author

🔄 Ultrafix loop started (goal: 8/10, max cycles: 6)

First action: /review

💡 Tip: Remove the ultrafix label from this PR to stop further ultrafix cycles.

@propr-dev

propr-dev Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ AI Code Review Complete requested by @propr-dev[bot]

Posted 1 review:

View Task Details

@propr-dev

propr-dev Bot commented Nov 17, 2026

Copy link
Copy Markdown
Contributor Author

🔍 AI Code Review — codex:gpt-6-astra

Overall Evaluation

The PR restores numeric token metrics and token-alert settings through a focused change to shared MCP redaction. It is merge-ready within the reviewed scope, conditional on the five pending checks completing successfully.

✅ Correct numeric contracts — The new filter preserves the numeric cost columns and all five numeric token_outlier_* settings defined by the supplied producers and schemas.

✅ Sensitive filtering retained — Other sensitive key classes remain unconditionally excluded. Token fields containing strings, including nested strings, remain excluded; Buffer, typed-array, and Date values are also rejected.

✅ Relevant regression coverage — Tests cover nested and JSON-encoded payloads, cost-response parity, and settings persistence through the real MCP execution path.

This assessment is based on static review of the supplied diff and context. No commands or tests were run.

Merge blockers

No merge blockers.

Suggestions

These are optional follow-ups and are not sent to /fix.

S1: 🟢 Cover recursive depth boundaries

Consider adding focused tests around the depth limit and cyclic token containers in packages/api/test/mcpResultRedaction.test.ts. The new holdsNoText traversal has its own depth handling alongside redact, so these cases would help preserve termination and boundary behavior during future changes. This is optional coverage; the supplied implementation bounds recursion, and no concrete failure was established.

Score

The implementation addresses the stated objective with a small production change and relevant regression tests. There are no verified merge blockers or current-head check failures; five checks remain pending.

Score: 9/10


🤖 Review Details

  • Model: GPT-6 Astra
  • Time: 22s
  • Tokens: 39,226 (38,858 in / 368 out)
  • Cost: $0.28

View Task


💡 Next step: Comment /fix to address every F# merge blocker, /fix all for every pending blocker and suggestion, or name records explicitly, as in /fix F3 S5.
F# and S# IDs increment across review comments and remain permanent, so selectors such as /fix F3 F5 stay unambiguous across cycles. S# suggestions stay optional: they are implemented only when you name them or request /fix all, and they never relax a merge blocker.

Copy and edit to choose records from this review:

/fix S1

🤖 Review by ProPR

@propr-dev propr-dev Bot removed the ultrafix label Nov 17, 2026
@propr-dev propr-dev Bot changed the title 🔨 [3595 by Claude Opus 5.5] MCP: result redaction removes token counts from cost data and hides the token-alert settings ✅⑨ [3595 by Claude Opus 5.5] MCP: result redaction removes token counts from cost data and hides the token-alert settings Nov 17, 2026
@integry
integry merged commit 46e60ef into 3595-epic-0-9-h9l Nov 17, 2026
67 checks passed
@propr-dev propr-dev Bot changed the title ✅⑨ [3595 by Claude Opus 5.5] MCP: result redaction removes token counts from cost data and hides the token-alert settings [3595 by Claude Opus 5.5] MCP: result redaction removes token counts from cost data and hides the token-alert settings Nov 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant