Skip to content

fix(dashboard): hide MCP when disabled - #577

Merged
SantiagoDePolonia merged 2 commits into
mainfrom
fix/hide-mcp-when-disabled
Jul 22, 2026
Merged

fix(dashboard): hide MCP when disabled#577
SantiagoDePolonia merged 2 commits into
mainfrom
fix/hide-mcp-when-disabled

Conversation

@SantiagoDePolonia

@SantiagoDePolonia SantiagoDePolonia commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Summary

  • expose the effective MCP_ENABLED configuration through the dashboard runtime-config allowlist
  • hide the MCP Servers navigation item when MCP is disabled
  • cover the backend-to-frontend flag contract and sidebar gate

Testing

  • go test ./internal/admin ./internal/app
  • make test-dashboard

Summary by CodeRabbit

  • New Features

    • Added an admin-dashboard feature flag for the MCP Servers page, controlling both navigation visibility and availability status.
    • Dashboard runtime configuration now reports whether MCP is enabled or disabled.
  • Bug Fixes

    • Prevents unnecessary MCP Servers requests when the page is not meant to be shown, keeping the page in a clean “unavailable” state.
  • Tests

    • Added/updated unit tests covering MCP flag-driven navigation visibility and the MCP Servers page’s request/availability behavior.

Copilot AI review requested due to automatic review settings July 22, 2026 15:34

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The dashboard runtime configuration now exposes MCP_ENABLED from cfg.MCP.Enabled. The frontend loads the flag, uses it to control MCP Servers navigation and server fetching, and adds coverage for enabled, disabled, and rendered navigation states.

Changes

MCP dashboard feature flag

Layer / File(s) Summary
Expose MCP runtime configuration
internal/admin/handler.go, internal/admin/handler_test.go, internal/app/app.go, internal/app/app_test.go
The admin runtime configuration contract accepts, normalizes, serializes, and tests MCP_ENABLED; the application maps cfg.MCP.Enabled to "on" or "off".
Gate MCP navigation
internal/admin/dashboard/static/js/..., internal/admin/dashboard/templates/sidebar.html
The frontend loads MCP_ENABLED, evaluates mcpServersPageVisible(), conditionally renders the MCP Servers link, and tests the navigation behavior.
Skip disabled MCP requests
internal/admin/dashboard/static/js/modules/mcp-servers.js, internal/admin/dashboard/static/js/modules/mcp-servers.test.cjs, internal/admin/dashboard/static/js/dashboard.js
MCP server loading waits for runtime configuration and skips the endpoint request when MCP is disabled, leaving the module unavailable and idle.

Estimated code review effort: 2 (Simple) | ~15 minutes

Sequence Diagram(s)

sequenceDiagram
  participant DashboardRuntimeConfig
  participant mcpServersPageVisible
  participant fetchMcpServersPage
  participant MCPServersEndpoint
  DashboardRuntimeConfig-->>fetchMcpServersPage: Load runtime configuration
  fetchMcpServersPage->>mcpServersPageVisible: Check MCP_ENABLED
  mcpServersPageVisible-->>fetchMcpServersPage: Return visibility
  alt MCP enabled
    fetchMcpServersPage->>MCPServersEndpoint: Request MCP server list
  else MCP disabled
    fetchMcpServersPage-->>fetchMcpServersPage: Clear state and skip request
  end
Loading

Possibly related PRs

Suggested reviewers: copilot

Poem

I’m a rabbit guarding the MCP door,
Flags hop from config to the floor.
“On,” and the link appears with cheer;
“Off,” no server requests draw near.
Tests twitch their noses: all is clear!

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description omits the required ## Description section and does not briefly explain the change and its rationale. Rename ## Summary to ## Description and add a brief explanation of what changed and why; keep Testing as a separate section if desired.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately summarizes the main change: hiding MCP when disabled.
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 fix/hide-mcp-when-disabled

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.

Copilot AI review requested due to automatic review settings July 22, 2026 15:41

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@internal/admin/dashboard/static/js/modules/mcp-servers.js`:
- Around line 294-308: Update fetchMcpServersPage so mcpServersLoading is set to
true before awaiting ensureWorkflowRuntimeConfig. Preserve the existing clearing
behavior in the disabled return path and the finally path, ensuring the loading
state remains active while runtime configuration resolves.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 408299bf-1b4a-41d5-b817-fa9b1225735f

📥 Commits

Reviewing files that changed from the base of the PR and between 878ee7c and 759527b.

📒 Files selected for processing (3)
  • internal/admin/dashboard/static/js/dashboard.js
  • internal/admin/dashboard/static/js/modules/mcp-servers.js
  • internal/admin/dashboard/static/js/modules/mcp-servers.test.cjs

Comment on lines 294 to +308
async fetchMcpServersPage() {
// dashboardDataFetches starts feature-backed requests in
// parallel, so wait for the shared runtime-config request
// before deciding whether the MCP admin API is available.
if (typeof this.ensureWorkflowRuntimeConfig === 'function') {
await this.ensureWorkflowRuntimeConfig();
}
if (typeof this.mcpServersPageVisible === 'function' && !this.mcpServersPageVisible()) {
this.mcpServersAvailable = false;
this.mcpServers = [];
this.mcpServerError = '';
this.mcpServersLoading = false;
return;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Set the MCP loading state before awaiting runtime configuration.

mcpServersLoading remains false while ensureWorkflowRuntimeConfig() is pending, so a direct visit can render the empty state before the feature flag resolves. Move the existing loading assignment before the await and keep clearing it in the disabled and finally paths.

Proposed fix
 async fetchMcpServersPage() {
+    this.mcpServersLoading = true;
     if (typeof this.ensureWorkflowRuntimeConfig === 'function') {
         await this.ensureWorkflowRuntimeConfig();
     }
...
-    this.mcpServersLoading = true;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
async fetchMcpServersPage() {
// dashboardDataFetches starts feature-backed requests in
// parallel, so wait for the shared runtime-config request
// before deciding whether the MCP admin API is available.
if (typeof this.ensureWorkflowRuntimeConfig === 'function') {
await this.ensureWorkflowRuntimeConfig();
}
if (typeof this.mcpServersPageVisible === 'function' && !this.mcpServersPageVisible()) {
this.mcpServersAvailable = false;
this.mcpServers = [];
this.mcpServerError = '';
this.mcpServersLoading = false;
return;
}
async fetchMcpServersPage() {
this.mcpServersLoading = true;
// dashboardDataFetches starts feature-backed requests in
// parallel, so wait for the shared runtime-config request
// before deciding whether the MCP admin API is available.
if (typeof this.ensureWorkflowRuntimeConfig === 'function') {
await this.ensureWorkflowRuntimeConfig();
}
if (typeof this.mcpServersPageVisible === 'function' && !this.mcpServersPageVisible()) {
this.mcpServersAvailable = false;
this.mcpServers = [];
this.mcpServerError = '';
this.mcpServersLoading = false;
return;
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/admin/dashboard/static/js/modules/mcp-servers.js` around lines 294 -
308, Update fetchMcpServersPage so mcpServersLoading is set to true before
awaiting ensureWorkflowRuntimeConfig. Preserve the existing clearing behavior in
the disabled return path and the finally path, ensuring the loading state
remains active while runtime configuration resolves.

@greptile-apps

greptile-apps Bot commented Jul 22, 2026

Copy link
Copy Markdown

Confidence Score: 5/5

The changed flow looks mergeable after making the MCP navigation gate handle unloaded or unavailable runtime config.

The backend flag matches the configuration used to enable MCP.

The sidebar can still show MCP while runtime config is loading or unavailable.

T-Rex T-Rex Logs

What T-Rex did

  • T-Rex exercised the real server-rendered dashboard at /admin/dashboard/overview using the repository JavaScript, templates, and stylesheets to exercise end-to-end UI flow.
  • Browser assertions confirmed the UI behavior by showing visible elements before interactions and the expected hidden state afterward, validating before/after scope.
  • Server startup logs verified the effective configuration reported mcp gateway disabled.
  • During general dashboard initialization, the expected MCP API request returned 503, representing a pre-existing surface that is not reported as a finding.

View all artifacts

T-Rex Ran code and verified through T-Rex

Reviews (1): Last reviewed commit: "fix(dashboard): skip disabled MCP fetche..." | Re-trigger Greptile

Comment thread internal/admin/dashboard/static/js/dashboard.js
@SantiagoDePolonia
SantiagoDePolonia merged commit be05734 into main Jul 22, 2026
20 checks passed
@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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.

3 participants