Commit graph

81 commits

Author SHA1 Message Date
Carl Peaslee
609cdc709b
Add Client.listResourceTemplates method (#125)
* adds listResourceTemplates to client for #124

* add pagination to resources/templates/list

from @mattt

Co-authored-by: Mattt <mattt@loopwork.com>

* adds cursor functionality to ListResourceTemplates

* updates the client method to use the updated signature

---------

Co-authored-by: Mattt <mattt@loopwork.com>
2025-05-30 12:35:34 -07:00
Mattt
14fddc44c4
Move Sampling from Server to Client directory (#121) 2025-05-26 06:36:23 -07:00
Mattt Zmuda
9742933d2f
Bump version to 0.9.0 0.9.0 2025-05-26 06:07:28 -07:00
Mattt
a59b50bf5a
Update Client.connect(transport:) to automatically send initialize request (#100)
* Update Client to automatically call initialize in connect

* Make Client.connect(transport:) return value discardable

* Fix example usage in README

* Update example code in transports to remove initialize call

* Deprecate initialize method

* Update tests

* Update README

* Fix sampling tests

* Fix race condition tests
2025-05-26 06:04:38 -07:00
Mattt
3b505ee575
Improve ergonomics of prompt and sampling message initialization (#120)
* Improve ergonomics of prompt and sampling message initialization

* Deprecate previous / existing Message initializers
2025-05-26 05:25:02 -07:00
Mattt
fac4df6b1a
Add support for sampling (#119)
* Add UnitInterval type

* Add test coverage for UnitInterval

* Add support for sampling

* Add integration tests for sampling
2025-05-26 04:57:24 -07:00
Mattt
ddde66dc08
Add test coverage for base64 data helper methods (#114) 2025-05-26 04:36:13 -07:00
Mattt
fec680a243
Prevent double continuation resumption in client (#113)
* Prevent double continuation resumption in client

Consolidate request removal and continuation resumption logic to ensure each request's continuation is resumed exactly once, preventing "SWIFT TASK CONTINUATION MISUSE" errors during network failures.

* Fix race condition test
2025-05-26 04:36:01 -07:00
Mattt
87f33d022a
Improve NetworkTransport and add test coverage (#108)
* Improve NetworkTransport and add test coverage

* Remove the weakTransport check since actors have special memory management rules

* Use Task.sleep(for:) consistently

* Always start connection in connect

* Run NetworkTransportTests serially
2025-05-07 10:36:54 -07:00
Mattt Zmuda
266c02d2d1
Bump version to 0.8.2 0.8.2 2025-05-07 05:59:20 -07:00
Mattt
720a8102e9
Implement client protocol version negotiation in server initialization (#107)
* Implement client version negotiation in server initialization

* Add test coverage for version negotiation

* Make Version.supported and Version.negotiate() APIs internal to not create new surface area
2025-05-07 05:58:11 -07:00
Mattt Zmuda
3690509fa0
Bump version to 0.8.1 0.8.1 2025-05-07 03:26:31 -07:00
Mattt
bc5360ecce
Revert "Remove deprecated MCP.Error typealias (#102)" (#104)
This reverts commit d3f061dacd.
2025-05-07 03:26:07 -07:00
Mattt
800131fb9c
Don't throw error if there's a protocol mismatch between client and server (#103) 2025-05-06 11:53:02 -07:00
Mattt
d3f061dacd
Remove deprecated MCP.Error typealias (#102) 2025-05-06 11:23:04 -07:00
Mattt Zmuda
305cf7e13f
Bump version to 0.8.0 0.8.0 2025-05-06 09:30:43 -07:00
Mattt
23cb19268a
Set latest version to 2025-03-26 (#80)
* Set latest version to 2025-03-26

* Specify support for 2025-03-26 (latest) version
2025-05-06 09:30:21 -07:00
Mattt
32cf6cb7e6
Expand README with more information about client and server usage (#99)
* Expand README with more information about client and server usage

* Add discussion of initialize hook for server

* Add section about request batching

* Trim trailing whitespace

* Rename section to Request Batching
2025-05-06 09:24:20 -07:00
Mattt
daef492821
Improve documentation comments for transport types (#98)
* Add example usage to HTTPClientTransport documentation comments

* Add documentation comments to NetworkTransport

* Improve documentation comments for StdioTransport
2025-05-06 06:56:24 -07:00
Mattt
bdaa2585c5
Delay SSE GET connection until after session ID is established (#97)
* Delay SSE GET connection until after session ID is established

- Add a signaling mechanism to ensure the SSE streaming task waits for the initial session ID to be set before attempting the GET connection.
- Use a TaskGroup to race between session ID signal and a 10-second timeout, logging the outcome.
- Trigger the signal when a session ID is received for the first time from any response.
- Add detailed logging for all code paths to aid debugging and clarify connection timing.
- Clean up signal resources on disconnect to prevent leaks.

This addresses the initialization timing issue where the SSE GET could be attempted before the session was established, as discussed in MCP PR #91.

* Update tests for SSE timing

* Use configurable timeout for acquiring session ID

* Remove Actor protocol conformance for HTTPClientTransport

* Configure shorter session ID timeout for tests

* Add documentation comments to HTTPClientTransport

* Rename sessionIDWaitTimeout to sseInitializationTimeout
2025-05-06 06:49:48 -07:00
Mattt
3ff1085e01
Use EventSource for SSE implementation (#96)
* Add package dependency for github.com/loopwork-ai/EventSource

* Use EventSource for SSE implementation

* Refactor response stream and content type handling

Co-authored-by: Stephen Tallent <stallent@mercury.io>

* Conditionalize use of streaming for supported platforms

* Refactor conditional platform handling

* Conditionalize code and package dependency on Linux

---------

Co-authored-by: Stephen Tallent <stallent@mercury.io>
2025-05-06 05:45:40 -07:00
Mattt
2b67a1233f
Resume with EOF instead of throwing error when no data is received (#94) 2025-05-02 14:24:37 -07:00
Mattt
48c19c282b
Document Client usage with HTTPClientTransport (#77)
* Add test coverage for Client with HTTPClientTransport

* Configure HTTP client transport to stream by default

* Add example usage of streaming HTTP transport to README

* Explicitly set streaming to false in test
2025-04-27 09:29:24 -07:00
Stephen Tallent
ccb070f2f0
support 405 response from servers that don’t support streaming (#90)
* support 405 response from servers that don’t support streaming

* Rephrase comment

---------

Co-authored-by: Stephen Tallent <stallent@mercury.io>
Co-authored-by: Mattt Zmuda <mattt@loopwork.com>
2025-04-27 07:27:14 -07:00
Ayal Spitz
f6e401aa97
Fix event stream line parsing to handle CRLF and empty lines correctly (#89)
* Optimized code in `connectToEventStream` to use `.lines` computed value of `AsyncSequence` to produce a `AsyncLineSequence` instead of building a lines manually.

* - Reverter use of `lines` (it swallows newlines)
- Fiexed original issue I experienced with line 229 `while let newlineIndex = buffer.firstIndex(of: "\n") {` not handling "\r\n" properly
- Added unit test to test for "\r\n" scenario
- Simplified `end of event` test - `line` creation trims newline, added code trims carriage return. Only thing that should be left is an empty line
2025-04-27 06:50:08 -07:00
Stephen Tallent
99517b0564
Update AnyNotification to include notification params (#86)
* Update AnyNotification to not wipe out params that come with a notification

* Add test coverage for notification with params

* Allow params to be omitted when empty

---------

Co-authored-by: Stephen Tallent <stallent@mercury.io>
Co-authored-by: Mattt Zmuda <mattt@loopwork.com>
2025-04-27 06:47:38 -07:00
Mattt
25dee3bb4c
Send initialized notification from client instead of server (#85) 2025-04-21 14:43:33 -07:00
Mattt
29aa74d137
Simplify receive implementation for transports (#78) 2025-04-18 02:37:31 -07:00
Mattt
046fa3ee96
Update README with information about transports and platform availability (#76)
* Update README with information about transports and platform availability

* Add footnote about WIP Alpine Linux and Windows support

* Move discussion of platform availability to separate section

* Add link from requirements to platform availability section
2025-04-15 10:26:26 -07:00
Mattt
d583151871
Add streamable HTTP transport for clients (#70)
* Rename file to Transport.swift

* Rename file to StdioTransportTests.swift

* Add .index-build/ to .gitignore

* Implement HTTP client transport

* Add test coverage for streamable HTTP client transport

* Conditionally import FoundationNetworking

* Conditionalize streaming for unsupported platforms

* Import FoundationNetworking in tests

* Add 5 minute timeout to CI jobs

* Remove debug logging

* Formatting

* Skip SSE tests on platforms that don't support streaming
2025-04-15 09:06:29 -07:00
Mattt
4143f35b41
Implement Tool.Annotations (#47) 2025-04-15 05:42:44 -07:00
Mattt
c748bc1549
Add support for audio content in prompts and tool results (#73) 2025-04-15 05:41:28 -07:00
Mattt
82f4fd29b3
Add support for JSON-RPC batching (#67)
* Update StdioTransport documentation comments to indicate support for JSON-RPC batches

* Add server support for JSON-RPC batching

* Add client support for JSON-RPC batching

* Fix bug that caused error messages to be wrapped unnecessarily
2025-04-10 12:13:41 -07:00
Mattt
2a978d175e
Fix testServerHandleInitialize flake (#68) 2025-04-10 12:09:06 -07:00
Mattt
960c1dda0b
Conditionalize availability of StdioTransport (#65)
* Conditionalize availability of StdioTransport

* Update README with information about platform support
2025-04-10 09:15:13 -07:00
Mattt
1e61f205a1
Add support for Linux with glibc (#61)
* Conditionally import Glibc on Linux for fcntl calls

* Extract transport implementations into separate files

* Fix warning in test

* Add ubuntu-latest to CI test matrix

* Switch to vapor/swiftly-action for setup step

* Configure Prettier extension to format GitHub Actions workflows

* Setup with different actions depending on platform

* Rename step

* Rename job

* Update README
2025-04-10 05:22:56 -07:00
Mattt
20d4fe6f5a
Update Client.listTools return type to include next cursor (#54) 2025-04-09 16:20:55 -07:00
Mattt Zmuda
cfcead8121
Bump version to 0.7.1 0.7.1 2025-04-04 12:11:49 -07:00
Mattt
0725c46969
Remove top-level MCP enumeration (#53) 2025-04-04 12:11:27 -07:00
Mattt Zmuda
402904eab2
Bump version to 0.7.0 0.7.0 2025-04-03 05:33:06 -07:00
Mattt
7c84c20faf
Add Changelog section to README (#45) 2025-04-03 05:32:30 -07:00
Mattt
09da2a1c01
Rename Error to MCPError (#44)
* 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
2025-04-03 05:25:00 -07:00
Mattt
a9bcbf9ad9
Update transports to send and receive data instead of strings (#42)
* Update transports to send and receive data instead of strings

* Rename MockTransport helper methods

* Adopt Task.sleep(for:...) instead of variant taking nanoseconds

* Update comment

* Revert inadvertant change to visibility of send method
2025-04-03 04:42:56 -07:00
Mattt
de829ee648
Add configurable strict mode for MCP client initialization (#43)
* Add configurable strict mode for MCP client initialization

* Rename checkCapability to validateServerCapability
2025-04-03 04:33:50 -07:00
Mattt
5551f66d0e
Update README to reflect MIT License (#41) 2025-04-03 02:16:05 -07:00
Mattt Zmuda
3372a14a10
Bump version to 0.6.0 0.6.0
Update README
2025-03-31 10:24:53 -07:00
Mattt
daa7dad30a
Update platform requirements (#30)
* Relax platform requirements to macOS 13 and iOS 16

* Expand supported platforms
2025-03-31 10:22:39 -07:00
Adam Wulf
19857af5bf
Fix/decode tool call (#36)
* Adding unit test

* Decode entire request to strongly typed Method call. This allows NotRequired parameters to properly decode from null, which wouldn't be possible when decoding from the 'null' JSON encoding directly.
2025-03-31 05:34:33 -07:00
Mattt
d55140bc46
Import System package when available (#34)
* Import System package when available

* Add isResourceTemporarilyUnavailable helper method to reduce number of imports of System / SystemPackage
2025-03-31 05:30:45 -07:00
Adam Wulf
97b756c0f4
Add waitUntilComplete() method to Server (#26)
* Add waitUntilComplete() method to Server

* Update Sources/MCP/Server/Server.swift

Co-authored-by: Mattt <mattt@me.com>

---------

Co-authored-by: Mattt <mattt@me.com>
2025-03-29 04:26:16 -07:00