Skip to content

Commit 7c1c255

Browse files
authored
fix: make sure we can convert Request and Notification to string (#14)
* make sure we can convert Request and Notification to string This is already used when we are logging * fix: minor * fix: revert minor * fix: rector
1 parent 93edec4 commit 7c1c255

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/Message/Notification.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace PhpLlm\McpSdk\Message;
66

7-
final readonly class Notification implements \JsonSerializable
7+
final readonly class Notification implements \JsonSerializable, \Stringable
88
{
99
/**
1010
* @param array<string, mixed>|null $params
@@ -37,4 +37,9 @@ public function jsonSerialize(): array
3737
'params' => $this->params,
3838
];
3939
}
40+
41+
public function __toString(): string
42+
{
43+
return sprintf('%s', $this->method);
44+
}
4045
}

src/Message/Request.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace PhpLlm\McpSdk\Message;
66

7-
final class Request implements \JsonSerializable
7+
final class Request implements \JsonSerializable, \Stringable
88
{
99
/**
1010
* @param array<string, mixed>|null $params
@@ -40,4 +40,9 @@ public function jsonSerialize(): array
4040
'params' => $this->params,
4141
];
4242
}
43+
44+
public function __toString(): string
45+
{
46+
return sprintf('%s: %s', $this->id, $this->method);
47+
}
4348
}

0 commit comments

Comments
 (0)