Repository navigation
fix: unable to import mcp from local - #16590
Conversation
📝 WalkthroughWalkthroughThis PR simplifies comments in MCP handler and service files without altering logic, and adds authorization_token support to ImportServers so a config's root-level token is stored as a variable and injected as an Authorization bearer header when none exists. ChangesMCP Handler and Service Updates
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested labels: Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
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.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
internal/service/mcp.go (1)
521-541: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick winTreat Authorization detection case-insensitively.
headersandheaderValscan diverge here when the input already has anauthorization-cased header or a non-string value, so this block may inject a bearer header even though auth is already present and persist a different value than the one used for discovery. Use onestrings.EqualFoldcheck over the raw headers and apply the same result to both maps.🤖 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/service/mcp.go` around lines 521 - 541, The Authorization header check in mcp.go is case-sensitive and can treat existing authorization headers as missing when the input uses different casing or non-string values. Update the header handling in the block that builds headers and headerVals to inspect the raw headers with a single strings.EqualFold-based Authorization presence check, then use that same result to decide whether to inject the Bearer ${authorization_token} value into both maps. Keep the behavior aligned between headers and headerVals so discovery and persistence always match.
🧹 Nitpick comments (1)
internal/service/mcp.go (1)
532-533: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueRedundant assignment:
authorization_tokenis already copied by the generic loop above.The loop at lines 503-511 copies every
configkey excepttype,url,headersintovariables/stringVars—authorization_tokenisn't excluded, so it's already present there. Line 532'svariables["authorization_token"] = tokenjust re-assigns the same value.🤖 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/service/mcp.go` around lines 532 - 533, Remove the redundant authorization_token re-assignment in the MCP config handling: the generic copy loop already populates variables and stringVars for this key. In the code around the token setup in the MCP service, keep the existing loop behavior and only preserve the separate stringVars["authorization_token"] assignment if it is still needed for string-specific handling; otherwise delete the duplicate variables["authorization_token"] = token line.
🤖 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.
Outside diff comments:
In `@internal/service/mcp.go`:
- Around line 521-541: The Authorization header check in mcp.go is
case-sensitive and can treat existing authorization headers as missing when the
input uses different casing or non-string values. Update the header handling in
the block that builds headers and headerVals to inspect the raw headers with a
single strings.EqualFold-based Authorization presence check, then use that same
result to decide whether to inject the Bearer ${authorization_token} value into
both maps. Keep the behavior aligned between headers and headerVals so discovery
and persistence always match.
---
Nitpick comments:
In `@internal/service/mcp.go`:
- Around line 532-533: Remove the redundant authorization_token re-assignment in
the MCP config handling: the generic copy loop already populates variables and
stringVars for this key. In the code around the token setup in the MCP service,
keep the existing loop behavior and only preserve the separate
stringVars["authorization_token"] assignment if it is still needed for
string-specific handling; otherwise delete the duplicate
variables["authorization_token"] = token line.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 02878278-77c5-49f1-9985-993da0845ecc
📒 Files selected for processing (2)
internal/handler/mcp.gointernal/service/mcp.go
### Summary As title
### Summary As title
Summary
As title