Repository navigation
Migrate MCP Server to Newer Mounted Implementation - #78
Conversation
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughBlackbox MCP moves from a separate-port SSE server to a mounted /mcp streamable HTTP endpoint; settings and admin UI now surface a derived endpoint and server-wide bearer token, origin validation is enforced for browser requests, and legacy mcp_port is removed across code, tests, seed data, and docs. ChangesMCP Mounted Endpoint Migration
Sequence Diagram(s) sequenceDiagram
participant AdminPage
participant MainServer
participant MCPManager
participant DB
AdminPage->>MainServer: updateMCPSettings(acknowledge or mcp_enabled)
MainServer->>DB: persist mcp_enabled / mcp_auth_token / ack flag
MainServer->>MCPManager: ApplySettings(enabled, token)
MCPManager->>MCPManager: update internal enabled/token state
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
server/main.go (1)
11-11:⚠️ Potential issue | 🔴 Critical | ⚡ Quick winRemove the unused
strconvimport at line 11 to unblock the build.The compiler has flagged this one:
strconvis imported but never referenced anywhere in the file. That's a compile error waiting to happen. Go doesn't tolerate unused imports, so this needs to come out.Fix
import ( "context" "embed" "errors" "log" "net/http" "os" "os/signal" - "strconv" "strings" "syscall" "time"🤖 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 `@server/main.go` at line 11, Remove the unused strconv import from main.go: delete the "strconv" entry in the import block (the unused symbol is strconv) so the file compiles; ensure no other code in functions like main or any helpers references strconv before removing.
🤖 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 `@server/internal/mcp/origin.go`:
- Around line 37-53: The inferRequestOrigin function currently trusts
X-Forwarded-Proto and X-Forwarded-Host unconditionally; change it to prefer
r.URL.Scheme and r.Host and only accept X-Forwarded-Proto / X-Forwarded-Host
when the request comes from a trusted proxy. Implement or call a trusted-proxy
check (e.g., isTrustedProxy(r.RemoteAddr) or a trustedProxies list) inside
inferRequestOrigin and gate the r.Header.Get("X-Forwarded-Proto") and
r.Header.Get("X-Forwarded-Host") usage behind that check so forwarded headers
are ignored for non-trusted clients; keep trimming logic and fallback to
r.TLS/"https" and "http" as currently done.
In `@web/tests/admin-mcp.test.ts`:
- Around line 13-16: The test swallows module loader errors by doing
import('../src/pages/adminMcp.ts').catch(() => null); remove the .catch(...) so
the dynamic import can throw and surface resolver diagnostics; update usages of
helperModule (the const helperModule and the subsequent assert.ok that
references adminMcpHelperPath.pathname) to assume import either succeeds or
fails by exception (i.e., drop the null-check/assert that expects a nullable
helperModule).
---
Outside diff comments:
In `@server/main.go`:
- Line 11: Remove the unused strconv import from main.go: delete the "strconv"
entry in the import block (the unused symbol is strconv) so the file compiles;
ensure no other code in functions like main or any helpers references strconv
before removing.
🪄 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: Repository UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: e5427a23-c7a7-43b4-96f8-72760f09c210
⛔ Files ignored due to path filters (2)
go.work.sumis excluded by!**/*.sumserver/go.sumis excluded by!**/*.sum
📒 Files selected for processing (22)
README.mddemo/worker/src/seed-data.tsdemo/worker/src/types.tsdocs/site/docs/data-sources/komodo.mddocs/site/docs/deployment/reverse-proxy-and-tls.mddocs/site/docs/getting-started/first-login-and-setup.mddocs/site/docs/integrations/mcp-server.mddocs/superpowers/specs/2026-05-19-mcp-mounted-streamable-http-design.mdserver/go.modserver/internal/handlers/admin_config.goserver/internal/handlers/admin_config_test.goserver/internal/mcp/auth.goserver/internal/mcp/origin.goserver/internal/mcp/origin_test.goserver/internal/mcp/server.goserver/internal/mcp/server_test.goserver/internal/mcp/tools.goserver/main.goweb/src/api/client.tsweb/src/pages/AdminPage.tsxweb/src/pages/adminMcp.tsweb/tests/admin-mcp.test.ts
There was a problem hiding this comment.
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 `@server/internal/mcp/origin.go`:
- Around line 59-65: When reading X-Forwarded-Proto and X-Forwarded-Host in
origin.go (the block using isTrustedProxy(r.RemoteAddr) and r.Header.Get), guard
against comma-appended values from multiple proxies by splitting the header
value on ',', trimming each token, and using the first non-empty token as the
effective scheme/host (instead of using the whole header string). Update the
forwardedProto and forwardedHost handling to parse and select that first token
before assigning scheme and host so composed origin is valid behind multi-proxy
chains.
🪄 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: Repository UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 533f2d3a-a702-4bcf-902e-eea6397c2f08
📒 Files selected for processing (4)
server/internal/mcp/origin.goserver/internal/mcp/origin_test.goserver/main.goweb/tests/admin-mcp.test.ts
💤 Files with no reviewable changes (1)
- server/main.go
Summary by CodeRabbit
New Features
Bug Fixes
Documentation