Add resync functionality to MCP SERVER PROXY#1377
Conversation
📝 WalkthroughWalkthroughThis PR adds a re-sync flow for backend API definitions on SERVER_PROXY MCP Server endpoints. It extends ChangesMCP Server backend definition re-sync
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant User
participant EndpointCard
participant MCPServer as MCPServer.validateThirdPartyMCPServerUrl
participant API as Backend API
User->>EndpointCard: Click "Re-sync" button
EndpointCard->>EndpointCard: setIsSyncing(true)
EndpointCard->>EndpointCard: derive endpoint URL
alt No endpoint URL configured
EndpointCard->>User: Show localized error alert
else URL available
EndpointCard->>MCPServer: validateThirdPartyMCPServerUrl(url, null, mcpServerId, endpointType)
MCPServer->>API: Send request with mcpServerId/endpointType or securityInfo
API-->>MCPServer: Return validation result with content
MCPServer-->>EndpointCard: content
EndpointCard->>EndpointCard: pretty-print content, setEditedDefinition
EndpointCard->>User: Show pending resyncAlert
end
EndpointCard->>EndpointCard: setIsSyncing(false)
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 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.
🧹 Nitpick comments (2)
portals/publisher/src/main/webapp/source/src/app/data/MCPServer.js (1)
296-306: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winJSDoc not updated for new params.
The
@paramblock still only documentsurlandsecurityInfo;mcpServerIdandendpointType(and their mutual-exclusivity withsecurityInfo) aren't documented, making the three-way branching in the body below non-obvious to future callers.📝 Suggested doc update
/** * Validate the MCP Server URL. * `@param` {string} url - The URL of the MCP Server to validate. * `@param` {Object} [securityInfo] - Security information for the MCP Server. * `@param` {boolean} [securityInfo.isSecure] - Whether security is enabled. * `@param` {string} [securityInfo.header] - The security header name. * `@param` {string} [securityInfo.value] - The security header value. + * `@param` {string} [mcpServerId] - Existing MCP Server ID, used with `endpointType` to re-validate + * a stored endpoint (ignored when `securityInfo` is provided). + * `@param` {string} [endpointType] - Endpoint type ('PRODUCTION'/'SANDBOX') paired with `mcpServerId`. * `@returns` {Promise} A promise that resolves to the validation result. */🤖 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 `@portals/publisher/src/main/webapp/source/src/app/data/MCPServer.js` around lines 296 - 306, Update the JSDoc for validateThirdPartyMCPServerUrl to document the new mcpServerId and endpointType parameters, including their purpose and how they interact with securityInfo. Make sure the comment clearly reflects the branching logic in validateThirdPartyMCPServerUrl so callers can understand when each argument should be used and that securityInfo is mutually exclusive with the other two inputs.portals/publisher/src/main/webapp/source/src/app/components/MCPServers/Details/Endpoints/EndpointCard.jsx (1)
211-218: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winFragile magic-string coupling between
getEndpointUrl()andhandleResync.The no-URL check (
url === 'No URL configured') is hardcoded to match the exact fallback string returned bygetEndpointUrl(). If that fallback text ever changes (e.g., for localization or wording tweaks), this guard silently breaks and the literal string'No URL configured'would be sent to the backend as the endpoint URL instead of being caught here.♻️ Suggested fix using a sentinel constant
- const getEndpointUrl = () => { + const NO_URL_CONFIGURED = 'No URL configured'; + + const getEndpointUrl = () => { let endpointConfig; if (typeof endpoint.endpointConfig === 'string') { endpointConfig = JSON.parse(endpoint.endpointConfig); } else { endpointConfig = endpoint.endpointConfig; } if (endpointType === 'PRODUCTION') { - return endpointConfig.production_endpoints?.url || 'No URL configured'; + return endpointConfig.production_endpoints?.url || NO_URL_CONFIGURED; } else if (endpointType === 'SANDBOX') { - return endpointConfig.sandbox_endpoints?.url || 'No URL configured'; + return endpointConfig.sandbox_endpoints?.url || NO_URL_CONFIGURED; } - return 'No URL configured'; + return NO_URL_CONFIGURED; } ... const handleResync = () => { const url = getEndpointUrl(); - if (!url || url === 'No URL configured') { + if (!url || url === NO_URL_CONFIGURED) {🤖 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 `@portals/publisher/src/main/webapp/source/src/app/components/MCPServers/Details/Endpoints/EndpointCard.jsx` around lines 211 - 218, The no-URL guard in handleResync is coupled to the literal fallback string from getEndpointUrl(), so replace the magic string check with a shared sentinel or constant used by both getEndpointUrl and handleResync. Update EndpointCard to centralize the “no URL” value in a named symbol and compare against that instead of 'No URL configured', ensuring the backend is never called with the placeholder.
🤖 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.
Nitpick comments:
In
`@portals/publisher/src/main/webapp/source/src/app/components/MCPServers/Details/Endpoints/EndpointCard.jsx`:
- Around line 211-218: The no-URL guard in handleResync is coupled to the
literal fallback string from getEndpointUrl(), so replace the magic string check
with a shared sentinel or constant used by both getEndpointUrl and handleResync.
Update EndpointCard to centralize the “no URL” value in a named symbol and
compare against that instead of 'No URL configured', ensuring the backend is
never called with the placeholder.
In `@portals/publisher/src/main/webapp/source/src/app/data/MCPServer.js`:
- Around line 296-306: Update the JSDoc for validateThirdPartyMCPServerUrl to
document the new mcpServerId and endpointType parameters, including their
purpose and how they interact with securityInfo. Make sure the comment clearly
reflects the branching logic in validateThirdPartyMCPServerUrl so callers can
understand when each argument should be used and that securityInfo is mutually
exclusive with the other two inputs.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: e156d799-97ea-471f-8ff5-3c03e9951061
📒 Files selected for processing (3)
portals/publisher/src/main/webapp/site/public/locales/en.jsonportals/publisher/src/main/webapp/source/src/app/components/MCPServers/Details/Endpoints/EndpointCard.jsxportals/publisher/src/main/webapp/source/src/app/data/MCPServer.js
30c6e0c to
4f644fc
Compare
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
`@portals/publisher/src/main/webapp/source/src/app/components/MCPServers/Details/Endpoints/EndpointCard.jsx`:
- Around line 353-386: The EndpointCard action buttons can trigger overlapping
requests because the Re-sync button does not consider isSaving and the Update
button does not consider isSyncing, which can let stale state overwrite newer
changes. Update the disabled logic for the Re-sync and
endpoint-definition-update-btn buttons in EndpointCard so each action is blocked
while the other is in flight, using the existing isSyncing, isSaving,
handleDefinitionSave, and resync-related button logic as the anchor points.
🪄 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: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: b4acca69-0873-43bb-9d03-8afe9d7ba87d
📒 Files selected for processing (3)
portals/publisher/src/main/webapp/site/public/locales/en.jsonportals/publisher/src/main/webapp/source/src/app/components/MCPServers/Details/Endpoints/EndpointCard.jsxportals/publisher/src/main/webapp/source/src/app/data/MCPServer.js
✅ Files skipped from review due to trivial changes (1)
- portals/publisher/src/main/webapp/site/public/locales/en.json
🚧 Files skipped from review as they are similar to previous changes (1)
- portals/publisher/src/main/webapp/source/src/app/data/MCPServer.js
4f644fc to
5e27a96
Compare
5e27a96 to
075b295
Compare
|
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
`@portals/publisher/src/main/webapp/source/src/app/components/MCPServers/Details/Endpoints/EndpointCard.jsx`:
- Around line 219-243: Clear the stale re-sync success state before starting a
new validateThirdPartyMCPServerUrl request in EndpointCard so a failed retry
does not leave resyncAlert showing the old success message. Update the
EndpointCard re-sync flow to reset resyncAlert to false when the fetch begins
(or immediately in the catch path) alongside setIsSyncing(true), while keeping
setEditedDefinition and setIsSyncing(false) behavior unchanged.
🪄 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: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 0e2022d4-cd03-4adb-936a-125112364e3c
📒 Files selected for processing (3)
portals/publisher/src/main/webapp/site/public/locales/en.jsonportals/publisher/src/main/webapp/source/src/app/components/MCPServers/Details/Endpoints/EndpointCard.jsxportals/publisher/src/main/webapp/source/src/app/data/MCPServer.js
✅ Files skipped from review due to trivial changes (1)
- portals/publisher/src/main/webapp/site/public/locales/en.json
🚧 Files skipped from review as they are similar to previous changes (1)
- portals/publisher/src/main/webapp/source/src/app/data/MCPServer.js



Resolves:wso2/api-manager#5103
This PR adds a re-sync capability for backend API definitions on SERVER_PROXY MCP Server endpoints. The validateThirdPartyMCPServerUrl method signature is extended with mcpServerId and endpointType parameters and its request body logic is changed accordingly. The UI adds a Re-sync button, loading state, informational alert, and updated localization strings.