Skip to content

refactor: standardize error handling and raise ToolError per MCP policy#275

Open
ChinmayPande48 wants to merge 1 commit intoneo4j-contrib:mainfrom
ChinmayPande48:enhancement/error-handling-mcp-94
Open

refactor: standardize error handling and raise ToolError per MCP policy#275
ChinmayPande48 wants to merge 1 commit intoneo4j-contrib:mainfrom
ChinmayPande48:enhancement/error-handling-mcp-94

Conversation

@ChinmayPande48
Copy link

@ChinmayPande48 ChinmayPande48 commented Feb 26, 2026

Description

Note

This PR improves error handling across the Cloud Aura API MCP server to ensure compliance with the Anthropic MCP Directory Policy as suggested in issue #94
The previous implementation returned error dictionaries from the service layer, which does not align with MCP error-handling standards.

This update ensures:

  • Service layer exceptions are no longer swallowed or converted into error dicts.
  • MCP tools act as the error boundary and consistently raise ToolError.
  • Stack traces are preserved using raise ... from e.

This aligns the server behavior with MCP Directory requirements for structured and predictable error responses.

Type of Change

  • New feature
  • Bug fix
  • Breaking change
  • Documentation update
  • Project configuration change

Complexity

  • LOW
  • MEDIUM
  • HIGH

Complexity:

The change required refactoring error propagation across multiple layers (API client → service layer → MCP tool layer) to ensure consistent and policy-compliant behavior without altering functional behavior.

How Has This Been Tested?

  • Unit tests
  • Integration tests
  • Manual tests

Manual testing included:

  • Triggering validation errors (e.g., invalid input parameters)
  • Simulating API failures (invalid credentials, network errors)
  • Verifying that tools now raise ToolError instead of returning error dictionaries
  • Confirming proper logging and preserved exception chaining

Checklist

The following requirements should have been met (depending on the changes in the branch):

  • Documentation has been updated
  • Unit tests have been updated
  • Integration tests have been updated
  • Server has been tested in an MCP application
  • CHANGELOG.md updated if appropriate

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.

1 participant