Improve redMCP server operations

This commit is contained in:
Jason Thistlethwaite
2026-04-25 02:46:58 +00:00
parent 05c1a4bc97
commit d54319a5bb
14 changed files with 420 additions and 24 deletions
+13 -2
View File
@@ -47,7 +47,7 @@ final class McpHttpHandler
$responses[] = $this->errorResponse(null, -32600, 'Invalid request.');
continue;
}
$response = $this->dispatcher->handleMessage($message);
$response = $this->dispatcher->handleMessage($message, $this->logContext());
if ($response !== null) {
$responses[] = $response;
}
@@ -60,7 +60,7 @@ final class McpHttpHandler
return;
}
$response = $this->dispatcher->handleMessage($decoded);
$response = $this->dispatcher->handleMessage($decoded, $this->logContext());
if ($response === null) {
http_response_code(202);
return;
@@ -79,6 +79,17 @@ final class McpHttpHandler
return hash_equals($this->token, substr($header, 7));
}
/**
* @return array<string,mixed>
*/
private function logContext(): array
{
return [
'transport' => 'http',
'client_ip' => $_SERVER['REMOTE_ADDR'] ?? null,
];
}
/**
* @param mixed $payload
*/