Merge pull request #2869 from actus7/consolidate/mcp-health-v3

fix(hooks): consolidate MCP health-check fixes (3 PRs)
This commit is contained in:
haelyra
2026-08-29 00:22:27 -04:00
committed by GitHub
4 changed files with 132 additions and 4 deletions
+5 -2
View File
@@ -28,8 +28,11 @@ const MAX_BACKOFF_MS = 10 * 60 * 1000;
// Claude Code's stored OAuth bearer token. Treat auth-gated responses as
// reachable so the real MCP client can attempt the authenticated call. A
// Streamable HTTP MCP server can also return 406 to a bare GET that omits
// Accept: text/event-stream; that still proves the endpoint is alive.
const HEALTHY_HTTP_CODES = new Set([200, 201, 202, 204, 301, 302, 303, 304, 307, 308, 400, 401, 403, 405, 406]);
// Accept: text/event-stream; that still proves the endpoint is alive. Some
// POST-only Streamable HTTP servers (e.g. Paper Desktop) answer a bare GET
// with 404 instead; a routed HTTP response of any kind proves reachability,
// so treat 404 as alive and let the real MCP client validate the endpoint.
const HEALTHY_HTTP_CODES = new Set([200, 201, 202, 204, 301, 302, 303, 304, 307, 308, 400, 401, 403, 404, 405, 406]);
const RECONNECT_STATUS_CODES = new Set([401, 403, 429, 503]);
const FAILURE_PATTERNS = [
{ code: 401, pattern: /\b401\b|unauthori[sz]ed|auth(?:entication)?\s+(?:failed|expired|invalid)/i },
+10 -2
View File
@@ -423,8 +423,16 @@ function createMemoryMcpService(options = {}) {
return jsonRpcResult(message.id, {});
}
if (message.method === 'tools/list') {
if (message.params && Object.keys(message.params).length > 0) {
return jsonRpcError(message.id, -32602, 'tools/list does not accept parameters.');
const params = message.params || {};
if (
(Object.prototype.hasOwnProperty.call(params, '_meta') && !isRecord(params._meta))
|| (
Object.prototype.hasOwnProperty.call(params, 'cursor')
&& typeof params.cursor !== 'string'
)
|| Object.keys(params).some(key => !['cursor', '_meta'].includes(key))
) {
return jsonRpcError(message.id, -32602, 'Invalid tools/list parameters.');
}
return jsonRpcResult(message.id, {
tools: TOOL_DEFINITIONS.map(tool => ({ ...tool })),