Skip to content

Commit fbb6cfc

Browse files
committed
fix: disable unicode escaping in JSON encoding for MCP tools results
1 parent f574c9c commit fbb6cfc

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/Server/Request/ToolsCallHandler.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function execute(string $method, ?array $params = null): array
2929
}
3030

3131
$tool = $this->toolRepository->getTool($name);
32-
if (! $tool) {
32+
if (!$tool) {
3333
throw new JsonRpcErrorException(message: "Tool '{$name}' not found", code: JsonRpcErrorCode::METHOD_NOT_FOUND);
3434
}
3535

@@ -41,7 +41,7 @@ public function execute(string $method, ?array $params = null): array
4141
'content' => [
4242
[
4343
'type' => 'text',
44-
'text' => is_string($result) ? $result : json_encode($result),
44+
'text' => is_string($result) ? $result : json_encode($result, JSON_UNESCAPED_UNICODE),
4545
],
4646
],
4747
];

src/Transports/SseTransport.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public function initialize(): void
9797
private function sendEvent(string $event, string $data): void
9898
{
9999
// 헤더 설정이 이미 전송되었는지 확인
100-
if (! headers_sent()) {
100+
if (!headers_sent()) {
101101
// 버퍼링 비활성화
102102
ini_set('output_buffering', 'off');
103103
ini_set('zlib.output_compression', false);
@@ -146,7 +146,7 @@ public function send(string|array $message): void
146146
*/
147147
public function close(): void
148148
{
149-
if (! $this->connected) {
149+
if (!$this->connected) {
150150
return;
151151
}
152152

@@ -306,7 +306,7 @@ public function pushMessage(string $clientId, array $message): void
306306
throw new Exception('Cannot push message: SSE Adapter is not configured.');
307307
}
308308

309-
$messageString = json_encode($message);
309+
$messageString = json_encode($message, JSON_UNESCAPED_UNICODE);
310310
if ($messageString === false) {
311311
throw new Exception('Failed to JSON encode message for pushing: '.json_last_error_msg());
312312
}

0 commit comments

Comments
 (0)