Skip to content

feat(mcp-guardrails): ui changes - #5739

Closed
Madhuvod wants to merge 1 commit into
07-19-feat_mcp-guardrails_add_mcp_log_redaction_changesfrom
07-20-feat_mcp-guardrails_ui_changes
Closed

Madhuvod wants to merge 1 commit into
07-19-feat_mcp-guardrails_add_mcp_log_redaction_changesfrom
07-20-feat_mcp-guardrails_ui_changes

Conversation

@Madhuvod

Copy link
Copy Markdown
Contributor

Revives #5366 on the restored MCP guardrails stack. This PR is stacked above #5738, whose base is dev.

## Summary

Adds a "Show original values" toggle to the MCP log detail sheet, allowing users with the `Logs:Reveal` permission to view redacted placeholders replaced with their original values. Redaction utility functions are extracted into a shared module and extended to support recursive reveal over structured JSON-like values.

## Changes

- Extracted `hasRedactionMappingEntries` and `applyRedactionMapping` from `logDetailView.tsx` into a new shared `ui/lib/utils/redaction.ts` module, removing the inline definitions.
- Added `applyRedactionMappingToValue` for recursive reveal over nested objects and arrays without mutating the fetched log data.
- Added `mergeRedactionMappings` to combine input and output phase maps for fields like error details that may contain content from both phases.
- Introduced a `RedactionMapping` interface in `logs.ts` and applied it to both `LogEntry` and `MCPToolLogEntry` (the latter now includes `redaction_mapping` on detail responses).
- Added a `canReveal` prop to `MCPLogDetailSheet`, gated by the `Logs:Reveal` RBAC permission checked in `MCPLogsPage`.
- Rendered a `Switch` toggle labeled "Show original values" in the sheet header when reveal data is available; toggling it applies the redaction mapping to arguments, result, and error details before display.
- Reset the toggle state whenever the displayed log ID changes or reveal availability changes.
- Added unit tests covering `hasRedactionMappingEntries`, `applyRedactionMappingToValue` (including immutability), and `mergeRedactionMappings` conflict resolution.

## Type of change

- [ ] Bug fix
- [x] Feature
- [ ] Refactor
- [ ] Documentation
- [ ] Chore/CI

## Affected areas

- [ ] Core (Go)
- [ ] Transports (HTTP)
- [ ] Providers/Integrations
- [ ] Plugins
- [x] UI (React)
- [ ] Docs

## How to test

1. Open the MCP Logs page as a user with the `Logs:Reveal` permission.
2. Click a log entry that has redacted fields (placeholders like `[EMAIL-1]`).
3. Verify the "Show original values" toggle appears in the sheet header.
4. Toggle it on and confirm placeholders in Arguments, Result, and Error Details are replaced with original values.
5. Toggle it off and confirm placeholders are restored.
6. Navigate to a different log and confirm the toggle resets to off.
7. As a user without `Logs:Reveal`, confirm the toggle does not appear.

```sh
cd ui
pnpm i || npm i
pnpm test || npm test
pnpm build || npm run build
```

## Screenshots/Recordings

_Add before/after screenshots showing the toggle and revealed values in the MCP log detail sheet._

## Breaking changes

- [ ] Yes
- [x] No

## Related issues

_Link related issues here._

## Security considerations

The reveal toggle is gated behind the `Logs:Reveal` RBAC permission. Original values are only substituted client-side when the backend includes `redaction_mapping` in the response, which itself is only returned to callers with the appropriate permission. No original values are persisted or logged by the UI.

## Checklist

- [ ] I read `docs/contributing/README.md` and followed the guidelines
- [x] I added/updated tests where appropriate
- [ ] I updated documentation where needed
- [x] I verified builds succeed (Go and UI)
- [ ] I verified the CI pipeline passes locally if applicable
@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 8c4ffda9-9650-4eab-b320-8686ccdf998b

📥 Commits

Reviewing files that changed from the base of the PR and between 9d41022 and baab059.

📒 Files selected for processing (6)
  • ui/app/workspace/logs/sheets/logDetailView.tsx
  • ui/app/workspace/mcp-logs/page.tsx
  • ui/app/workspace/mcp-logs/views/mcpLogDetailsSheet.tsx
  • ui/lib/types/logs.ts
  • ui/lib/utils/redaction.test.ts
  • ui/lib/utils/redaction.ts

📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Added permission-controlled reveal options for redacted MCP log details.
    • Users with access can reveal original values in MCP log arguments, results, and errors.
    • Redaction mappings are applied consistently across displayed log data.
  • Bug Fixes

    • Improved handling of redacted values, including nested data and conflicting mappings.
  • Tests

    • Added coverage for redaction detection, replacement, conflict handling, and immutability.

Walkthrough

Adds shared redaction mapping types and utilities. MCP log details now support RBAC-controlled reveal of original arguments, results, and error details. Existing log details use the shared utilities.

Changes

MCP log redaction

Layer / File(s) Summary
Shared redaction contract and utilities
ui/lib/types/logs.ts, ui/lib/utils/redaction.ts, ui/lib/utils/redaction.test.ts, ui/app/workspace/logs/sheets/logDetailView.tsx
Adds the shared RedactionMapping type and redaction helpers. Tests cover recursive replacement, conflict handling, and non-mutating behavior. The log detail view imports the shared helpers.
RBAC-controlled MCP reveal UI
ui/app/workspace/mcp-logs/page.tsx, ui/app/workspace/mcp-logs/views/mcpLogDetailsSheet.tsx
Checks Logs/Reveal permission, passes canReveal, and renders a reveal switch. Arguments, results, and error details use redaction-aware values.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant MCPLogsPage
  participant MCPLogDetailSheet
  participant RedactionUtilities
  participant MCPToolLogEntry
  MCPLogsPage->>MCPLogsPage: Check Logs/Reveal permission
  MCPLogsPage->>MCPLogDetailSheet: Pass canReveal
  MCPLogDetailSheet->>MCPToolLogEntry: Read log values and redaction_mapping
  MCPLogDetailSheet->>RedactionUtilities: Apply redaction mappings
  RedactionUtilities-->>MCPLogDetailSheet: Return transformed values
  MCPLogDetailSheet-->>MCPLogsPage: Render log details
Loading

Possibly related PRs

Suggested reviewers: akshaydeo, impoiler, pratham-mishra04

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description only states issue and stacking context and omits the required summary, changes, testing, security, and checklist details. Complete the template with the feature purpose, changed areas, test steps and results, screenshots, security considerations, related issues, and checklist selections.
Title check ❓ Inconclusive The title refers to UI changes but is too generic to identify the MCP log redaction reveal feature. Use a specific title such as "feat(mcp-guardrails): add MCP log redaction reveal controls".
✅ Passed checks (3 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 07-20-feat_mcp-guardrails_ui_changes

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

@Madhuvod Madhuvod closed this Jul 31, 2026
@Madhuvod
Madhuvod deleted the 07-20-feat_mcp-guardrails_ui_changes branch July 31, 2026 11:43
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