Skip to content

Rename Error to MCPError #44

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Apr 3, 2025
Merged

Rename Error to MCPError #44

merged 7 commits into from
Apr 3, 2025

Conversation

mattt
Copy link
Contributor

@mattt mattt commented Apr 3, 2025

Resolves #32

@mattt
Copy link
Contributor Author

mattt commented Apr 3, 2025

This is a breaking API change. The impact of this breaking change should be low, as most API, as I suspect that API callers are less likely to catch on specific MCP errors.

We could mitigate the impact of this breaking change by introducing a top-level Error typealias with a deprecation notice. However, I'm concerned that would create even more confusion with the Swift.Error namespace collision.

Instead, we can introduce a new top-level MCP enum with a nested Error typealias (fully-qualified MCP.MCP.Error), so that existing usage of MCP.Error gets the proper warning.

@mattt
Copy link
Contributor Author

mattt commented Apr 3, 2025

One unintended consequence of the MCP enum mitigation is that it breaks fully-qualified access to other types in the MCP module (i.e. MCP.Method).

We could declare a public typealias MCPMethod = Method and then declare a nested public typealias MCP.Method = MCPMethod, but that seems excessive. The top-level MCP is provided as a short-term compromise, so I think we can leave it at that.

Comment on lines +1 to +4
import class Foundation.JSONEncoder
import class Foundation.JSONDecoder
import struct Foundation.Data
import struct Foundation.POSIXError
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The reason why someone might need to fully-qualify MCP.Method or MCP.Notification is to fix a different namespace collision with Foundation.

As a workaround, you can import individual declarations as needed. Apologies in advance for any inconvenience this causes 🙇

@mattt mattt merged commit 09da2a1 into main Apr 3, 2025
1 check passed
@mattt mattt deleted the mattt/mcp-error branch April 3, 2025 12:25
devyhan pushed a commit to devyhan/swift-sdk that referenced this pull request Apr 4, 2025
* Rename Error to MCPError

* Conform MCPError to Swift.Error

* Use unqualified Error instead of Swift.Error

* Use unqualified MCPError instead of MCP.MCPError

* Rename file back to Error.swift

* Introduce top-level MCP namespace with nested Error typealias to provide deprecation notice for existing usage of MCP.Error

* Fix markup for MCP enum warning
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.

Rename Error to MCPError to remove namespace collision with Swift.Error
1 participant