Skip to content

Add resync functionality to MCP SERVER PROXY#1377

Merged
Thenujan-Nagaratnam merged 1 commit into
wso2:mainfrom
Thenujan-Nagaratnam:mcp-tool-fetch
Jul 3, 2026
Merged

Add resync functionality to MCP SERVER PROXY#1377
Thenujan-Nagaratnam merged 1 commit into
wso2:mainfrom
Thenujan-Nagaratnam:mcp-tool-fetch

Conversation

@Thenujan-Nagaratnam

@Thenujan-Nagaratnam Thenujan-Nagaratnam commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

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.

@coderabbitai

coderabbitai Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

This PR adds a re-sync flow for backend API definitions on SERVER_PROXY MCP Server endpoints. It extends validateThirdPartyMCPServerUrl, adds a Re-sync action and status handling in the endpoint drawer, and updates related localization strings.

Changes

MCP Server backend definition re-sync

Layer / File(s) Summary
Validation API signature and request body update
portals/publisher/src/main/webapp/source/src/app/data/MCPServer.js
validateThirdPartyMCPServerUrl gains mcpServerId and endpointType params and conditionally builds the request body using securityInfo, or mcpServerId/endpointType, or a default non-secure fallback.
Component imports and re-sync state
portals/publisher/src/main/webapp/source/src/app/components/MCPServers/Details/Endpoints/EndpointCard.jsx
Adds MuiAlert and SyncIcon imports and new isSyncing/resyncAlert state, clearing resyncAlert when the definition drawer opens.
handleResync implementation
portals/publisher/src/main/webapp/source/src/app/components/MCPServers/Details/Endpoints/EndpointCard.jsx
Adds handleResync, which validates the derived endpoint URL, calls the updated validation API, pretty-prints returned content, sets editedDefinition, shows a pending alert, and handles errors and loading state.
Drawer UI wiring and editor content
portals/publisher/src/main/webapp/source/src/app/components/MCPServers/Details/Endpoints/EndpointCard.jsx
Adds a conditional Re-sync button with spinner/disabled logic, an informational alert for resyncAlert, a data-testid on the view button, updated save success text, and Monaco editor content now prefers editedDefinition.
Localization string updates
portals/publisher/src/main/webapp/site/public/locales/en.json
Updates the save success message and adds new keys for resync label, pending state, and error/no-endpoint-URL cases.

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)
Loading

Possibly related PRs

  • wso2/apim-apps#1355: Both PRs modify EndpointCard.jsx's backend API definition editing/saving UI and drawer flow, including update behavior and localized messages.

Suggested reviewers: ashera96

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main change: adding re-sync functionality for MCP SERVER PROXY endpoints.
Description check ✅ Passed The description is directly related to the code changes and accurately summarizes the new re-sync flow and UI updates.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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 unit tests (beta)
  • Create PR with unit tests

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.

@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.

🧹 Nitpick comments (2)
portals/publisher/src/main/webapp/source/src/app/data/MCPServer.js (1)

296-306: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

JSDoc not updated for new params.

The @param block still only documents url and securityInfo; mcpServerId and endpointType (and their mutual-exclusivity with securityInfo) 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 win

Fragile magic-string coupling between getEndpointUrl() and handleResync.

The no-URL check (url === 'No URL configured') is hardcoded to match the exact fallback string returned by getEndpointUrl(). 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

📥 Commits

Reviewing files that changed from the base of the PR and between cb1b249 and 30c6e0c.

📒 Files selected for processing (3)
  • portals/publisher/src/main/webapp/site/public/locales/en.json
  • portals/publisher/src/main/webapp/source/src/app/components/MCPServers/Details/Endpoints/EndpointCard.jsx
  • portals/publisher/src/main/webapp/source/src/app/data/MCPServer.js

@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
`@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

📥 Commits

Reviewing files that changed from the base of the PR and between 30c6e0c and 4f644fc.

📒 Files selected for processing (3)
  • portals/publisher/src/main/webapp/site/public/locales/en.json
  • portals/publisher/src/main/webapp/source/src/app/components/MCPServers/Details/Endpoints/EndpointCard.jsx
  • portals/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

@sonarqubecloud

sonarqubecloud Bot commented Jul 3, 2026

Copy link
Copy Markdown

@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
`@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

📥 Commits

Reviewing files that changed from the base of the PR and between 4f644fc and 075b295.

📒 Files selected for processing (3)
  • portals/publisher/src/main/webapp/site/public/locales/en.json
  • portals/publisher/src/main/webapp/source/src/app/components/MCPServers/Details/Endpoints/EndpointCard.jsx
  • portals/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

@Thenujan-Nagaratnam Thenujan-Nagaratnam merged commit 04a9db7 into wso2:main Jul 3, 2026
4 checks passed
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.

2 participants