Skip to content

Conversation

@mattt
Copy link
Contributor

@mattt mattt commented Mar 30, 2025

The MCP SDK depends on the swift-system package for its FileDescriptor type. However, this creates incompatibilities when attempting to use this library with other libraries like this experimental Subprocess package (SF-0007) that conditionally import the swift-system package like so:

#if canImport(System)
    import System
#else
    @preconcurrency import SystemPackage
#endif

Trying to use both in the same project results in the following error:

Cannot convert value of type 'SystemPackage.FileDescriptor' to expected argument type 'System.FileDescriptor'

This PR replaces the existing instances of import SystemPackage with the same pattern, which should resolve the issue without any other side effects.

This PR also adds a isResourceTemporarilyUnavailable helper method to MCP.Error to eliminate the need for Client and Server to import System.Errno. Additional test coverage is provided.

See also apple/swift-system#60

@mattt mattt merged commit d55140b into main Mar 31, 2025
1 check passed
@mattt mattt deleted the mattt/import-system branch March 31, 2025 12:30
devyhan pushed a commit to devyhan/swift-sdk that referenced this pull request Apr 4, 2025
* Import System package when available

* Add isResourceTemporarilyUnavailable helper method to reduce number of imports of System / SystemPackage
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