Commit c63a872
Fix client parsing (#8)
* Allow decoding Decodable type directly from Value
Summary: I noticed we are not converting value associated with response to the strong types requests recorded
This change will help to decode the value type later once we support the rest of plumbing (next commit)
* Store and pass original request when response arrives
Summary: Looks like there were multiple issues with parsing response:
1. It appears that we would mistakenly pass response both for response and request arguments in the private func handleResponse(_ response: Response<AnyMethod>, for request: Any)
2. Later I couldn't figure out how to win against swift type system, so ended up creating a type-erased request to store in the pendingRequests instead of original type under Any (that wouldn't allow to downcast original type later)
Test Plan:
1. Standup iMCP client from https://github.com/loopwork-ai/iMCP
2. Create a dummy project setting up MCP client against "/private/var/folders/26/8gncz37x7slbfrr95d9jcr400000gn/T/AppTranslocation/62ADEC4D-3545-4E98-A612-0E6DF52CE525/d/iMCP.app/Contents/MacOS/imcp-server" and call initialize
Note response is being parsed correctly and client.initialize() does not hang indefinitely
* Fix warning: 'Cast from Client.AnyPendingRequest to unrelated type Client.PendingRequest<Any> always fails'
* Fix warning: 'Conditional cast from NWError to NWError always succeeds'
* Uncomment code in RoundtripTests
* Formatting
* Reorganize declarations
* Inline JSONDecoder extension
* Expand roundtrip tests
---------
Co-authored-by: Sash Zats [email protected] <>
Co-authored-by: Mattt Zmuda <[email protected]>1 parent 9ebe125 commit c63a872
File tree
3 files changed
+122
-45
lines changed- Sources/MCP
- Base
- Client
- Tests/MCPTests
3 files changed
+122
-45
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
396 | 396 | | |
397 | 397 | | |
398 | 398 | | |
399 | | - | |
400 | | - | |
401 | | - | |
402 | | - | |
403 | | - | |
404 | | - | |
405 | | - | |
| 399 | + | |
406 | 400 | | |
407 | 401 | | |
408 | 402 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
90 | 93 | | |
91 | 94 | | |
92 | 95 | | |
93 | 96 | | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
94 | 130 | | |
95 | | - | |
| 131 | + | |
96 | 132 | | |
97 | 133 | | |
98 | 134 | | |
| |||
129 | 165 | | |
130 | 166 | | |
131 | 167 | | |
132 | | - | |
133 | | - | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
134 | 172 | | |
135 | 173 | | |
136 | 174 | | |
| |||
158 | 196 | | |
159 | 197 | | |
160 | 198 | | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
| 199 | + | |
166 | 200 | | |
167 | 201 | | |
168 | 202 | | |
| |||
220 | 254 | | |
221 | 255 | | |
222 | 256 | | |
223 | | - | |
| 257 | + | |
224 | 258 | | |
225 | 259 | | |
226 | 260 | | |
227 | 261 | | |
228 | | - | |
| 262 | + | |
229 | 263 | | |
230 | 264 | | |
231 | 265 | | |
| |||
320 | 354 | | |
321 | 355 | | |
322 | 356 | | |
323 | | - | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
324 | 360 | | |
325 | 361 | | |
326 | 362 | | |
327 | 363 | | |
328 | | - | |
329 | | - | |
330 | | - | |
331 | 364 | | |
332 | 365 | | |
333 | | - | |
| 366 | + | |
334 | 367 | | |
335 | | - | |
| 368 | + | |
336 | 369 | | |
337 | 370 | | |
338 | 371 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
12 | 11 | | |
13 | 12 | | |
14 | | - | |
| 13 | + | |
15 | 14 | | |
16 | 15 | | |
17 | 16 | | |
| |||
36 | 35 | | |
37 | 36 | | |
38 | 37 | | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
39 | 64 | | |
40 | 65 | | |
41 | 66 | | |
42 | 67 | | |
43 | 68 | | |
44 | | - | |
45 | | - | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
46 | 102 | | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
65 | 115 | | |
66 | 116 | | |
67 | 117 | | |
| |||
0 commit comments