Skip to content

Conversation

@alexhancock
Copy link
Collaborator

Converts all usages of our internal MCP crate ToolError concept to rmcp's ErrorData

There were some conversions which were automated and uses the ErrorData { ... } variant, which requires providing the message manually as a std::borrow::Cow vs the ErrorData::new(...) option which allows strings.

Related #3578

@alexhancock alexhancock requested review from DOsinga and jamadeo August 12, 2025 18:32
@github-actions
Copy link
Contributor

github-actions bot commented Aug 12, 2025

PR Preview Action v1.6.0
Preview removed because the pull request was closed.
2025-08-12 20:20 UTC

@alexhancock alexhancock force-pushed the alexhancock/rmcp-error-data branch 2 times, most recently from 8b8d07b to d2d3488 Compare August 12, 2025 19:20
@jamadeo jamadeo requested a review from Copilot August 12, 2025 19:22
Copy link
Collaborator

@jamadeo jamadeo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case, landing with a bug or two might be preferable to keeping up with merge conflicts. Added copilot as a reviewer to see if it catches anything -- might not, but worth a shot.

Good stuff!

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR migrates all internal usage of the MCP crate's ToolError concept to rmcp's ErrorData type. The migration includes both automated conversions using the ErrorData { ... } variant and the preferred ErrorData::new(...) method for new error constructions.

  • Migration from ToolError enum to ErrorData struct across all tool implementations
  • Updated error handling patterns to use proper error codes from rmcp's ErrorCode enum
  • Conversion of test assertions to check for new error structure

Reviewed Changes

Copilot reviewed 34 out of 35 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
documentation/docs/goose-architecture/extensions-design.md Updated documentation to reference ErrorData instead of ToolError
crates/mcp-server/src/router.rs Updated router trait to use ErrorData in tool execution signatures
crates/mcp-server/src/main.rs Converted example router implementation to use ErrorData
crates/mcp-core/src/lib.rs Removed ToolError from public exports
crates/mcp-core/src/handler.rs Replaced ToolError enum with ErrorData usage in helper functions
crates/goose/tests/private_tests.rs Updated test assertions to check ErrorData fields instead of ToolError variants
crates/goose/src/providers/formats/*.rs Migrated provider format handlers to use ErrorData
crates/goose/src/conversation/*.rs Updated conversation handling to use new error format
crates/goose/src/agents/*.rs Converted all agent tool implementations to use ErrorData
crates/goose-mcp/src/*/mod.rs Updated MCP extension implementations to use ErrorData
Comments suppressed due to low confidence (1)

crates/mcp-core/src/handler.rs:59

  • Error message is incorrect - should say 'must be a number' but the parameter name suggests it should be 'must be required'. This appears to be a copy-paste error from the require_str_parameter function.
            format!("The parameter {name} is required"),

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

ToolError::ExecutionError(format!("Sub-recipe task createion failed: {}", e))
.map_err(|e| ErrorData {
code: ErrorCode::INTERNAL_ERROR,
message: Cow::from(format!("Sub-recipe task createion failed: {}", e)),
Copy link

Copilot AI Aug 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spelling error: 'createion' should be 'creation'.

Suggested change
message: Cow::from(format!("Sub-recipe task createion failed: {}", e)),
message: Cow::from(format!("Sub-recipe task creation failed: {}", e)),

Copilot uses AI. Check for mistakes.
Err(ErrorData {
code: ErrorCode::INTERNAL_ERROR,
message: Cow::from(
format!("Suported mimeType {}, for {}", mime_type, uri,),
Copy link

Copilot AI Aug 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spelling error: 'Suported' should be 'Supported'.

Suggested change
format!("Suported mimeType {}, for {}", mime_type, uri,),
format!("Supported mimeType {}, for {}", mime_type, uri,),

Copilot uses AI. Check for mistakes.

Err(ToolError::InvalidParameters(error_msg))
Err(ErrorData::new(
ErrorCode::RESOURCE_NOT_FOUND,
Copy link

Copilot AI Aug 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using RESOURCE_NOT_FOUND error code for an invalid parameters scenario is semantically incorrect. Should use INVALID_PARAMS instead.

Suggested change
ErrorCode::RESOURCE_NOT_FOUND,
ErrorCode::INVALID_PARAMS,

Copilot uses AI. Check for mistakes.
@alexhancock alexhancock force-pushed the alexhancock/rmcp-error-data branch 2 times, most recently from 857a296 to eaea319 Compare August 12, 2025 19:30
@alexhancock alexhancock force-pushed the alexhancock/rmcp-error-data branch from eaea319 to 29e751d Compare August 12, 2025 19:53
@alexhancock alexhancock merged commit bd1eff5 into main Aug 12, 2025
12 checks passed
@alexhancock alexhancock deleted the alexhancock/rmcp-error-data branch August 12, 2025 20:18
katzdave added a commit that referenced this pull request Aug 12, 2025
* 'main' of github.com:block/goose:
  feat: ToolError migration to ErrorData (#4051)
  docs: rename sessions (#4053)
  Add mcp automated testing blog (#4004)
  MCP session replay integration test (#3939)
  Docs: Cost tracking in CLI (#4043)
  sanitize message content on deserialization (#3966)
michaelneale added a commit that referenced this pull request Aug 13, 2025
* main:
  docs: mcp-ui support (#4049)
  fix: delete dialog layout (#4037)
  ci: fix markdown file pattern to skip builds for all .md files (#4061)
  docs: add window title (#4059)
  blog: cleaning up some posts (#4050)
  fix: this should be a debug message not a warn (#4024)
  Better provider logging (#4052)
  feat: ToolError migration to ErrorData (#4051)
  docs: rename sessions (#4053)
  Add mcp automated testing blog (#4004)
zanesq added a commit that referenced this pull request Aug 13, 2025
* 'main' of github.com:block/goose: (120 commits)
  Docs: Troubleshooting tip - Nodejs path on windows (#4065)
  fix: flag out uncompilable bit in windows (#4068)
  ci: fix docs-only filter to properly skip tests for documentation changes (#4066)
  fix: ctrl-C interruption in the CLI (#4057)
  docs: mcp-ui support (#4049)
  fix: delete dialog layout (#4037)
  ci: fix markdown file pattern to skip builds for all .md files (#4061)
  docs: add window title (#4059)
  blog: cleaning up some posts (#4050)
  fix: this should be a debug message not a warn (#4024)
  Better provider logging (#4052)
  feat: ToolError migration to ErrorData (#4051)
  docs: rename sessions (#4053)
  Add mcp automated testing blog (#4004)
  MCP session replay integration test (#3939)
  Docs: Cost tracking in CLI (#4043)
  sanitize message content on deserialization (#3966)
  Move summarize button inside of context view (#4015)
  blog: post on lead/worker model (#3994)
  Actually send cancellation to MCP servers (#3865)
  ...
ayax79 pushed a commit to ayax79/goose that referenced this pull request Aug 21, 2025
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.

3 participants