Improve redMCP server operations
This commit is contained in:
@@ -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
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user