Skip to content

Commit 4e906a6

Browse files
dcherreraclaude
andcommitted
Fix JSON encoding: Disable forward slash escaping
MCP servers cannot handle escaped forward slashes (\/) in paths. Changed JSONEncoder to use .withoutEscapingSlashes formatting. This fixes tool execution timeouts where tools/call requests were sent but servers never responded due to malformed path arguments. Bug: Path '/Users/...' was encoded as '\/Users\/...' causing 30s timeout 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent c5451f2 commit 4e906a6

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

Sources/MCP/Client/Client.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,11 @@ public actor Client {
155155
/// A dictionary of type-erased pending requests, keyed by request ID
156156
private var pendingRequests: [ID: AnyPendingRequest] = [:]
157157
// Add reusable JSON encoder/decoder
158-
private let encoder = JSONEncoder()
158+
private let encoder: JSONEncoder = {
159+
let encoder = JSONEncoder()
160+
encoder.outputFormatting = .withoutEscapingSlashes
161+
return encoder
162+
}()
159163
private let decoder = JSONDecoder()
160164

161165
public init(

0 commit comments

Comments
 (0)