Skip to content

fix(read_console): allow excluding MCP diagnostics from project checks - #1448

Open
MohammediYunus wants to merge 1 commit into
CoplayDev:betafrom
MohammediYunus:fix/read-console-mcp-log-filter
Open

MohammediYunus wants to merge 1 commit into
CoplayDev:betafrom
MohammediYunus:fix/read-console-mcp-log-filter

Conversation

@MohammediYunus

@MohammediYunus MohammediYunus commented Oct 7, 2026 •

Copy link
Copy Markdown

Description

MCP for Unity's own transport diagnostics can consume read_console limits before project warnings and errors are returned. This adds include_mcp_logs=false to exclude those entries before filtering limits and pagination, with the equivalent CLI flag --no-mcp-logs.

The existing default remains unchanged: MCP diagnostics are included unless explicitly excluded. This keeps bridge troubleshooting compatible while giving project checks the filter requested in #1434. Happy to discuss changing the default separately.

Type of Change

  • Bug fix
  • Test update
  • Documentation update

Changes Made

  • Recognize the logger's actual rich-text prefixes and its plain prefix, without removing ordinary project messages that mention MCP for Unity.
  • Forward the option through the Python MCP tool, CLI and C# handler.
  • Apply exclusion before count and cursor/page-size limits.
  • Regenerate the tool reference and add usage examples.

Compatibility / Package Source

  • Unity tested: 6000.3.24f1, macOS.
  • Package source: local file: reference in TestProjects/UnityMCPTests.
  • Based on current beta; no package/version changes included.

Testing

  • Reproduced in the real Editor before the C# fix: 25 ReadConsole tests passed, 3 new regressions failed because bridge logs occupied the count limit and first page.
  • After the fix: all 33 ReadConsole EditMode tests passed, including the five prefix variants.
  • Python/CLI: 8 new option regressions failed before implementation. Complete Python suite after the fix: 1,583 passed, 18 skipped (Python 3.13.13).
  • Generated reference check passed; git diff --check passed.
  • Multi-version check was invoked but all four configured Editor versions were unavailable locally. This is not a multi-version pass. No PlayMode, Windows or live MCP transport session was tested.

Related Issues

Related to #1434.

Additional Notes

The tests above were run locally; broader platform compatibility remains for CI and maintainer review.

Summary by CodeRabbit

  • New Features
    • Console-reading options now let you include or exclude MCP for Unity diagnostic messages. Diagnostics are included by default; when excluded, they don’t count toward result limits or pagination.
    • The CLI offers matching options to include or exclude these messages.
  • Documentation
    • Updated console-reading guidance with the new option and examples.

@coderabbitai

coderabbitai Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 8555cee3-3843-4dc4-b7dc-39d24c2adbbb
📥 Commits

Reviewing files that changed from the base of the PR and between ef713af and 789ca9e.

📒 Files selected for processing (8)
  • MCPForUnity/Editor/Helpers/McpLog.cs
  • MCPForUnity/Editor/Tools/ReadConsole.cs
  • Server/src/cli/commands/editor.py
  • Server/src/services/tools/read_console.py
  • Server/tests/integration/test_read_console_truncate.py
  • Server/tests/test_cli.py
  • TestProjects/UnityMCPTests/Assets/Tests/EditMode/Tools/ReadConsoleTests.cs
  • website/docs/reference/tools/core/read_console.md

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


📝 Walkthrough

Walkthrough

Console reads now support an option to include or exclude recognized MCP for Unity diagnostics. The option is available through the server tool and editor CLI. Filtering occurs before count and paging limits.

Changes

Console MCP log filtering

Layer / File(s) Summary
Recognize and filter Unity console entries
MCPForUnity/Editor/Helpers/McpLog.cs, MCPForUnity/Editor/Tools/ReadConsole.cs, TestProjects/UnityMCPTests/Assets/Tests/EditMode/Tools/ReadConsoleTests.cs
McpLog.IsMcpLogMessage recognizes the plain MCP prefix and four formatted prefixes. When MCP logs are disabled, Unity skips matching entries before count and paging limits. Tests cover recognized prefixes, inclusion defaults, filtering order, pagination, and project messages that mention MCP.
Propagate the MCP log option
Server/src/services/tools/read_console.py, Server/src/cli/commands/editor.py, Server/tests/integration/test_read_console_truncate.py, Server/tests/test_cli.py, website/docs/reference/tools/core/read_console.md
The server tool and editor CLI pass the MCP log setting to Unity. Tests cover boolean and string values, defaults, and CLI flags. Documentation describes the option and provides examples.

Priority: ⬇️ Low

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

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant ReadConsoleTool
  participant UnityHandleCommand
  participant GetConsoleEntries
  ReadConsoleTool->>UnityHandleCommand: includeMcpLogs option
  UnityHandleCommand->>GetConsoleEntries: includeMcpLogs setting
  GetConsoleEntries->>GetConsoleEntries: Skip matching entries when false
Loading

Suggested reviewers: scriptwonder

Merge Risk: ⚪ Minimal · up to 789ca

The console filtering option reaches Unity as intended. No identified issue prevents merging after normal checks.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 30.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 20 functions across 7 files. (1 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title clearly identifies the main change: allowing callers to exclude MCP diagnostics from read_console results.
Description check ✅ Passed The description is complete and aligned with the template. It explains the change, identifies the change types, lists implementation details, documents compatibility and testing, notes documentation u…
Full details: Docstring Coverage

Explanation

Docstring coverage is 30.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 20 functions across 7 files. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autopilot · 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

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

@MohammediYunus
MohammediYunus marked this pull request as ready for review October 7, 2026 12:33

This branch has not been deployed

No deployments
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