Skip to content

FEATURE - Wrap fetch-service-metadata errors in the structured response shape #4652

@marianfoo

Description

@marianfoo

generate-fiori-ui-application's handler wraps its body in try/catch and returns a structured status: "Error". fetch-service-metadata doesn't, so any inner throw (typically a missing entry in @sap-ux/store) bubbles into the MCP framework's generic error wrapper and the actual message never reaches the caller. Small consistency fix; big DX win for first-time and non-VS-Code users.

Technical Design

Wrap the executeFunctionality body of fetch-service-metadata in try/catch and mirror the success-path shape on error:

try {
  // existing body unchanged
  return { functionalityId, status: "Success", parameters: {...}, appPath, timestamp };
} catch (err) {
  return {
    functionalityId,
    status: "Error",
    message: err?.message ?? String(err),
    parameters: e.parameters,
    appPath: e.appPath,
    timestamp: new Date().toISOString(),
  };
}

Same pattern is already in the generator handler. Optional: lift it into a shared wrapExecuteHandler(fn) so future functionalities don't need to remember. No API surface change; strictly additive on the error path.

Notes

Repro on @sap-ux/fiori-mcp-server@0.6.55, node 22, macOS, Cursor as MCP client, empty @sap-ux/store:

execute_functionality({
  name: "fetch-service-metadata",
  parameters: {
    sapSystemQuery: "a4h",
    servicePath: "/sap/opu/odata4/sap/zui_dm_projects_o4/srvd/sap/zui_dm_projects_o4/0001/"
  },
  appPath: "/Users/me/dm-projects-fe"
})

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions