Skip to content

MCP: introduce a structured error envelope (code, message, stage, retryable) with secret redaction for every tool call #2593

Closed

Description

@propr-dev

Context

Today, when an MCP tool call fails, callers usually see one of two things:

  1. An McpError thrown by a tool (for example STALE_HEAD, PRECONDITION_FAILED) that carries only a code, a message and an HTTP-like status.
  2. Anything else (a GitHub RequestError, a Knex error, a Zod error, a timeout, a queue failure) which McpOperations.run in packages/api/mcp/operations.ts collapses into a single opaque value:
{ "error": { "code": "OUTCOME_UNKNOWN", "message": "Outcome uncertain. Inspect the target before issuing a new action." } }

This is exactly what happened repeatedly with publish_plan: the plan failed, the receipt said OUTCOME_UNKNOWN, and nobody could tell whether GitHub rejected the request, the database was locked, or the process was restarted. An agent cannot relay anything useful to the user from that.

This issue is the foundation for the whole "observable MCP surface" epic. Later issues (operation lifecycle, publish failure detail, merge precondition detail, preview tools, docs tools) all throw and store errors through the envelope introduced here, so it must land first.

Requirements

  1. Define one error envelope type used for every failed MCP tool call (mutating or read-only) and for every stored operation failure:
    interface McpErrorEnvelope {
      code: string;            // stable, UPPER_SNAKE_CASE, documented
      message: string;         // human readable, safe to show the user
      stage: McpErrorStage | null; // where it failed, when known
      retryable: boolean;      // is it safe to call again with a NEW idempotency key?
      status: number;          // HTTP-like status (400/403/404/409/429/5xx)
      details?: Record<string, unknown>; // optional structured, redacted detail
      cause?: { code: string; message: string }; // for OUTCOME_UNKNOWN: what actually happened underneath
    }
  2. Extend McpError (in packages/api/mcp/config.ts) so that tools can attach stage, retryable and details without changing any existing call site (all new arguments optional, existing new McpError(code, message, status) keeps working).
  3. Add a single classifier classifyError(error, { sideEffectsPossible }) that maps:
    • McpError → its own fields.
    • Zod validation errors → INVALID_INPUT, stage validation, not retryable, details.issues (path + message only).
    • Octokit/GitHub RequestErrors → GITHUB_AUTH_FAILED (401), GITHUB_FORBIDDEN (403), GITHUB_RATE_LIMITED (403/429 with rate-limit headers, retryable), GITHUB_NOT_FOUND (404), GITHUB_REJECTED (409/422, with GitHub's message and errors[].message), GITHUB_UNAVAILABLE (5xx, retryable); stage github.
    • Network/time-out errors (ECONNRESET, ETIMEDOUT, ECONNREFUSED, AbortError, TimeoutError) → UPSTREAM_TIMEOUT / UPSTREAM_UNREACHABLE, stage transport, retryable.
    • SQLite busy/locked errors (SQLITE_BUSY, SQLITE_LOCKED) → DATABASE_BUSY, stage database, retryable.
    • Anything else → INTERNAL_ERROR, stage internal, not retryable.
    • When sideEffectsPossible is true (a mutating tool failed with a non-McpError), the envelope code stays OUTCOME_UNKNOWN (so existing safety semantics are not weakened: never blindly retry a possibly-applied mutation) and retryable is forced to false, but the underlying classification is preserved in cause and stage. This is the key change: the caller still learns "GitHub rejected with 422: Validation Failed" instead of nothing.
  4. All messages and details pass through redactSecrets / redactDetails. Redaction must remove GitHub tokens (ghp_, gho_, ghs_, ghu_, ghr_, github_pat_), Bearer … values, credentialed git URLs (https://x-access-token:…@), MCP tokens (pia_mcp_…), signed URL query parameters (X-Amz-Signature, token, access_token, signature), and any detail key whose name matches /token|secret|password|authorization|cookie|private.?key|credential/i. Local filesystem paths must never be echoed in details (strip absolute paths to their basename).
  5. McpOperations.run stores the full envelope (result.error) instead of the fixed opaque message.
  6. The MCP transport (packages/api/mcp/toolExecution.ts / packages/api/mcp/server.ts) returns failed tool calls as isError: true with both a text content block containing {"error": envelope} and structuredContent: { error: envelope } so both old and new SDK clients can read it.
  7. The access log (mcp_access_log.error_code) keeps recording the envelope code (no payloads, as today).

Implementation Specification

  • New file packages/api/mcp/errorEnvelope.ts with McpErrorStage, McpErrorEnvelope, classifyError, redactSecrets, redactDetails, toToolErrorResult.
  • Edit packages/api/mcp/config.ts → McpError gains stage, retryable, details, and toEnvelope().
  • Edit packages/api/mcp/operations.ts → the catch block in run uses classifyError(error, { sideEffectsPossible: true }).
  • Edit packages/api/mcp/toolExecution.ts (the executeTool re-exported from tools.ts) and wherever server.ts converts a thrown error into a CallToolResult → use toToolErrorResult(classifyError(error, { sideEffectsPossible: false })) for read-only tools and non-operation paths.
  • New test file packages/api/test/mcpErrorEnvelope.test.ts.
  • Add the new file to the test:mcp script list if that script enumerates files explicitly.

Acceptance Criteria

  • A thrown new McpError('STALE_HEAD', 'Pull request head changed.', 409) produces { code: 'STALE_HEAD', stage: null, retryable: false, status: 409 } — no existing call site changed.
  • new McpError('CHECKS_PENDING', '…', 409, { stage: 'precondition', retryable: true, details: { pending: 2 } }) round-trips all fields.
  • A GitHub 422 thrown inside a mutating tool yields a stored receipt whose result.error is { code: 'OUTCOME_UNKNOWN', retryable: false, stage: 'github', cause: { code: 'GITHUB_REJECTED', message: 'Validation Failed: …' } }.
  • A GitHub 422 thrown inside a read-only tool yields isError: true with structuredContent.error.code === 'GITHUB_REJECTED'.
  • Unit tests prove that ghp_…, github_pat_…, Bearer abc, https://x-access-token:[email protected]/…, ?X-Amz-Signature=… and a details.accessToken field never appear in any envelope.
  • npm run test:mcp, npm run typecheck -w @propr/api and API lint pass.

Created by ProPR AI Planner

Activity

  1. propr-dev commented on Sep 28, 2026

    @propr-dev
    ContributorAuthor

    Suggested Implementation:

    Implementation Approach

    We centralise error classification in one module (errorEnvelope.ts) and make every failure path — the operation ledger, the tool executor and the SDK transport — go through it. The alternative of teaching each tool to catch and describe its own failures was rejected: there are ~150 tools, the result would drift, and forgetting one reproduces the OUTCOME_UNKNOWN black hole we are trying to close. A consistent envelope also means one place to audit for secret leakage.

    Key decisions:

    • Backwards compatible McpError. Existing new McpError(code, message, status) calls keep compiling; the new 4th argument is an optional options bag. This lets later issues add stage/retryable/details incrementally.
    • OUTCOME_UNKNOWN is kept for mutating tools. A transport failure after a POST to GitHub may already have created the issue/comment. Reporting it as retryable would invite duplicates. We keep the code and retryable: false, but add cause + stage so the agent can still tell the user what failed. This preserves the existing safety contract documented in docs/mcp.md ("an interrupted or uncertain external operation is not blindly replayed").
    • Redaction by default. Messages from Octokit can include request URLs with tokens, and error details could carry anything. We redact by pattern and by key name, and strip absolute paths, before the envelope leaves the process or is persisted.

    File: packages/api/mcp/errorEnvelope.ts (new file)

    Why this file: Single source of truth for the envelope shape, classification rules and redaction. Every other MCP module imports from here, so the rules cannot diverge.

    import { ZodError } from 'zod';
    import { McpError } from './config.js';
    
    /**
     * Where a failure happened. Kept deliberately coarse so the set stays stable
     * for clients that branch on it; finer detail belongs in `details`.
     */
    export type McpErrorStage =
      | 'validation'     // arguments rejected before any work
      | 'authorization'  // scope, permission or repository grant
      | 'precondition'   // target in the wrong state (stale head, not open, busy plan)
      | 'github'         // GitHub REST/GraphQL call
      | 'queue'          // BullMQ enqueue / Redis
      | 'database'       // SQLite / Knex
      | 'workflow'       // an existing REST workflow handler rejected the request
      | 'transport'      // network / timeout talking to an upstream
      | 'internal';
    
    export interface McpErrorEnvelope {
      code: string;
      message: string;
      stage: McpErrorStage | null;
      retryable: boolean;
      status: number;
      details?: Record<string, unknown>;
      /** Present when `code` is OUTCOME_UNKNOWN: the classified underlying failure. */
      cause?: { code: string; message: string };
    }
    
    // Patterns are ordered from most to least specific so that e.g. a credentialed
    // git URL is collapsed before the generic token pattern sees its fragments.
    const SECRET_PATTERNS: Array<[RegExp, string]> = [
      [/(https?:\/\/)[^\s/@:]+:[^\s/@]+@/gi, '$1[redacted]@'],
      [/\bgithub_pat_[A-Za-z0-9_]{20,}/g, '[redacted-token]'],
      [/\bgh[pousr]_[A-Za-z0-9]{20,}/g, '[redacted-token]'],
      [/\bpia_mcp_[A-Za-z0-9._-]+/g, '[redacted-token]'],
      [/\bBearer\s+[A-Za-z0-9._~+/=-]+/gi, 'Bearer [redacted]'],
      [/([?&](?:token|access_token|signature|X-Amz-Signature|X-Amz-Credential|jwt)=)[^&\s"']+/gi, '$1[redacted]'],
      // Absolute POSIX paths leak host layout (worktrees, credential dirs). Keep the basename.
      [/(^|[\s"'(=])\/(?:[\w.-]+\/)+([\w.-]+)/g, '$1…/$2'],
    ];
    
    const SECRET_KEY = /token|secret|password|authorization|cookie|private.?key|credential|api.?key/i;
    const MAX_MESSAGE = 1000;
    const MAX_DETAIL_DEPTH = 4;
    
    export function redactSecrets(text: string): string {
      let result = String(text ?? '');
      for (const [pattern, replacement] of SECRET_PATTERNS) result = result.replace(pattern, replacement);
      // Bound message size so an upstream HTML error page cannot flood the client context.
      return result.length > MAX_MESSAGE ? `${result.slice(0, MAX_MESSAGE)}…` : result;
    }
    
    /** Recursively redact detail objects: drop secret-named keys, redact strings, bound depth/size. */
    export function redactDetails(value: unknown, depth = 0): unknown {
      if (value == null || typeof value === 'number' || typeof value === 'boolean') return value;
      if (typeof value === 'string') return redactSecrets(value);
      if (depth >= MAX_DETAIL_DEPTH) return '[truncated]';
      if (Array.isArray(value)) return value.slice(0, 50).map(item => redactDetails(item, depth + 1));
      if (typeof value === 'object') {
        const out: Record<string, unknown> = {};
        for (const [key, item] of Object.entries(value as Record<string, unknown>).slice(0, 50)) {
          // Drop the key entirely rather than masking: the key name alone is enough
          // for debugging and a masked value still invites "copy it from the log".
          if (SECRET_KEY.test(key)) continue;
          out[key] = redactDetails(item, depth + 1);
        }
        return out;
      }
      return undefined;
    }
    
    function githubEnvelope(error: { status: number; message?: string; response?: { headers?: Record<string, string>; data?: unknown } }): McpErrorEnvelope {
      const headers = error.response?.headers ?? {};
      const data = (error.response?.data ?? {}) as { message?: string; errors?: Array<{ message?: string; code?: string; field?: string }> };
      // GitHub puts the useful explanation in response.data.errors[], not in error.message.
      const reasons = (data.errors ?? []).map(entry => entry.message || [entry.field, entry.code].filter(Boolean).join(' ')).filter(Boolean);
      const message = redactSecrets([data.message || error.message || 'GitHub request failed', ...reasons].join(': '));
      const rateLimited = error.status === 429 || (error.status === 403 && (headers['x-ratelimit-remaining'] === '0' || 'retry-after' in headers));
      if (rateLimited) {
        return { code: 'GITHUB_RATE_LIMITED', message, stage: 'github', retryable: true, status: 429,
          details: { retryAfterSeconds: Number(headers['retry-after'] ?? 60) || 60 } };
      }
      const byStatus: Record<number, [string, boolean]> = {
        401: ['GITHUB_AUTH_FAILED', false], 403: ['GITHUB_FORBIDDEN', false], 404: ['GITHUB_NOT_FOUND', false],
        409: ['GITHUB_REJECTED', false], 422: ['GITHUB_REJECTED', false],
      };
      const [code, retryable] = byStatus[error.status] ?? (error.status >= 500 ? ['GITHUB_UNAVAILABLE', true] : ['GITHUB_REJECTED', false]);
      return { code, message, stage: 'github', retryable, status: error.status >= 500 ? 502 : error.status };
    }
    
    function isGithubError(error: unknown): error is { status: number; message?: string; response?: { headers?: Record<string, string>; data?: unknown } } {
      // Octokit RequestError has a numeric status and a request object; checking
      // shape avoids importing @octokit/request-error into the MCP layer.
      return !!error && typeof error === 'object' && typeof (error as { status?: unknown }).status === 'number'
        && ('request' in (error as object) || 'response' in (error as object)) && !(error instanceof McpError);
    }
    
    /** Classify without the side-effect rule; used directly for read-only paths. */
    function baseClassify(error: unknown): McpErrorEnvelope {
      if (error instanceof McpError) return error.toEnvelope();
      if (error instanceof ZodError) {
        return { code: 'INVALID_INPUT', message: 'The arguments did not match the tool schema.', stage: 'validation', retryable: false, status: 400,
          details: { issues: error.issues.slice(0, 20).map(issue => ({ path: issue.path.join('.'), message: issue.message })) } };
      }
      if (isGithubError(error)) return githubEnvelope(error);
      const code = (error as { code?: string })?.code;
      const name = (error as { name?: string })?.name;
      const message = redactSecrets(error instanceof Error ? error.message : String(error));
      if (name === 'AbortError' || name === 'TimeoutError' || code === 'ETIMEDOUT') {
        return { code: 'UPSTREAM_TIMEOUT', message, stage: 'transport', retryable: true, status: 504 };
      }
      if (code === 'ECONNRESET' || code === 'ECONNREFUSED' || code === 'ENOTFOUND' || code === 'EAI_AGAIN') {
        return { code: 'UPSTREAM_UNREACHABLE', message, stage: 'transport', retryable: true, status: 503 };
      }
      if (code === 'SQLITE_BUSY' || code === 'SQLITE_LOCKED') {
        return { code: 'DATABASE_BUSY', message: 'The instance database was busy. Try again shortly.', stage: 'database', retryable: true, status: 503 };
      }
      return { code: 'INTERNAL_ERROR', message, stage: 'internal', retryable: false, status: 500 };
    }
    
    /**
     * Classify any thrown value into the public envelope.
     * `sideEffectsPossible`: a mutating tool failed after it may have touched an
     * external system. Such failures keep the conservative OUTCOME_UNKNOWN code
     * and are never marked retryable, but carry the real cause for diagnosis.
     */
    export function classifyError(error: unknown, options: { sideEffectsPossible?: boolean } = {}): McpErrorEnvelope {
      const envelope = baseClassify(error);
      const deliberate = error instanceof McpError && error.status < 500;
      if (options.sideEffectsPossible && !deliberate && !(error instanceof ZodError)) {
        return {
          code: 'OUTCOME_UNKNOWN',
          message: 'The action may or may not have taken effect. Inspect the target before issuing a new action.',
          stage: envelope.stage,
          retryable: false,
          status: 502,
          cause: { code: envelope.code, message: envelope.message },
          ...(envelope.details ? { details: redactDetails(envelope.details) as Record<string, unknown> } : {}),
        };
      }
      return envelope.details ? { ...envelope, details: redactDetails(envelope.details) as Record<string, unknown> } : envelope;
    }
    
    /** SDK CallToolResult for a failed call; text for legacy clients, structured for new ones. */
    export function toToolErrorResult(envelope: McpErrorEnvelope) {
      return {
        isError: true as const,
        content: [{ type: 'text' as const, text: JSON.stringify({ error: envelope }) }],
        structuredContent: { error: envelope },
      };
    }

    File: packages/api/mcp/config.ts

    Why this file: McpError is the error type every tool already throws. Extending it (rather than introducing a second error class) means later issues can add stage/retryable detail to existing throws with a one-line change.

    Locate export class McpError extends Error and replace it with the version below. Keep the existing constructor parameter order.

    --- a/packages/api/mcp/config.ts
    +++ b/packages/api/mcp/config.ts
    @@
    -export class McpError extends Error {
    -  constructor(readonly code: string, message: string, readonly status = 400) {
    -    super(message);
    -    this.name = 'McpError';
    -  }
    -}
    +import type { McpErrorEnvelope, McpErrorStage } from './errorEnvelope.js';
    +
    +export interface McpErrorOptions {
    +  /** Where the failure happened, when the thrower knows. */
    +  stage?: McpErrorStage;
    +  /**
    +   * Whether calling again (with a new idempotency key) is safe and may succeed.
    +   * Defaults: 5xx and 429 retryable, everything else not — deliberate
    +   * precondition failures need the caller to change something first.
    +   */
    +  retryable?: boolean;
    +  /** Structured, non-secret detail. Redacted again before leaving the process. */
    +  details?: Record<string, unknown>;
    +}
    +
    +export class McpError extends Error {
    +  readonly stage: McpErrorStage | null;
    +  readonly retryable: boolean;
    +  readonly details?: Record<string, unknown>;
    +
    +  constructor(readonly code: string, message: string, readonly status = 400, options: McpErrorOptions = {}) {
    +    super(message);
    +    this.name = 'McpError';
    +    this.stage = options.stage ?? (status === 403 ? 'authorization' : status === 409 ? 'precondition' : null);
    +    this.retryable = options.retryable ?? (status >= 500 || status === 429);
    +    this.details = options.details;
    +  }
    +
    +  toEnvelope(): McpErrorEnvelope {
    +    return { code: this.code, message: this.message, stage: this.stage, retryable: this.retryable, status: this.status,
    +      ...(this.details ? { details: this.details } : {}) };
    +  }
    +}

    Note: errorEnvelope.ts imports McpError at runtime and config.ts imports only types from errorEnvelope.ts, so there is no runtime import cycle.

    File: packages/api/mcp/operations.ts

    Why this file: This is where the opaque OUTCOME_UNKNOWN is manufactured today. Storing the classified envelope makes every receipt (get_operation) explain its failure.

    --- a/packages/api/mcp/operations.ts
    +++ b/packages/api/mcp/operations.ts
    @@ -3,6 +3,7 @@ import type { Knex } from 'knex';
     import { McpError } from './config.js';
     import { digest } from './store.js';
     import type { McpPrincipal } from './policy.js';
    +import { classifyError } from './errorEnvelope.js';
    @@ -48,12 +49,14 @@ export class McpOperations {
         } catch (error) {
    -      // A transport failure can follow an external side effect. Never replay it
    -      // automatically or claim it was rolled back. The handle remains durable.
    -      const code = error instanceof McpError && error.status < 500 ? error.code : 'OUTCOME_UNKNOWN';
    -      await this.db('mcp_operations').where({ id }).update({ state: code === 'OUTCOME_UNKNOWN' ? 'unknown' : 'failed',
    -        result: JSON.stringify({ error: { code, message: error instanceof McpError ? error.message : 'Outcome uncertain. Inspect the target before issuing a new action.' } }), updated_at: Date.now() });
    +      // A transport failure can follow an external side effect. Never replay it
    +      // automatically or claim it was rolled back. The handle remains durable.
    +      // classifyError keeps OUTCOME_UNKNOWN for those cases but now records the
    +      // real cause (e.g. GITHUB_REJECTED: Validation Failed) and failing stage,
    +      // so the receipt is diagnosable instead of opaque.
    +      const envelope = classifyError(error, { sideEffectsPossible: true });
    +      await this.db('mcp_operations').where({ id }).update({ state: envelope.code === 'OUTCOME_UNKNOWN' ? 'unknown' : 'failed',
    +        result: JSON.stringify({ error: envelope }), updated_at: Date.now() });
         }

    File: packages/api/mcp/toolExecution.ts and packages/api/mcp/server.ts

    Why these files: executeTool (re-exported from tools.ts) is the single dispatch point for every tool call and access-log record; server.ts registers tools with the SDK and converts thrown errors into CallToolResult. Converting there makes the envelope apply to every tool, including read-only ones that never go through McpOperations.

    In executeTool, wrap the non-operation branch (read-only tools and any code before operations.run) so that thrown values are classified once and re-thrown as an McpError carrying the envelope:

    // packages/api/mcp/toolExecution.ts (inside executeTool)
    import { classifyError } from './errorEnvelope.js';
    import { McpError } from './config.js';
    
    // ...existing authorization + dispatch code...
    try {
      return await dispatch();
    } catch (error) {
      // Read-only tools cannot have external side effects, so the real
      // classification is reported directly (no OUTCOME_UNKNOWN downgrade).
      const envelope = classifyError(error, { sideEffectsPossible: false });
      // Keep recording only the code in mcp_access_log (existing behaviour).
      recordAccess({ outcome: envelope.status === 403 ? 'denied' : 'error', errorCode: envelope.code });
      throw new McpError(envelope.code, envelope.message, envelope.status,
        { stage: envelope.stage ?? undefined, retryable: envelope.retryable, details: envelope.details });
    }

    In server.ts, where the tool callback catches an error and builds the SDK result, replace the ad-hoc text error with:

    import { classifyError, toToolErrorResult } from './errorEnvelope.js';
    
    // inside the registered tool handler's catch
    } catch (error) {
      // Both eras: legacy clients read content[0].text, 2026 clients read structuredContent.
      return toToolErrorResult(classifyError(error));
    }

    Also when an operation receipt with state failed/unknown is returned, include result.error untouched (it is already an envelope after this change).

    File: packages/api/test/mcpErrorEnvelope.test.ts (new file)

    Why this file: Locks down the public contract (codes, retryable flags) and, most importantly, redaction — regressions there would leak credentials into agent transcripts.

    import assert from 'node:assert/strict';
    import { test } from 'node:test';
    import { z } from 'zod';
    import { McpError } from '../mcp/config.js';
    import { classifyError, redactSecrets, toToolErrorResult } from '../mcp/errorEnvelope.js';
    
    const githubError = (status: number, data: unknown, headers: Record<string, string> = {}) =>
      Object.assign(new Error('HttpError'), { status, request: { url: 'https://api.github.com/x' }, response: { data, headers } });
    
    test('McpError keeps backwards-compatible defaults and optional detail', () => {
      assert.deepEqual(classifyError(new McpError('STALE_HEAD', 'Head changed.', 409)),
        { code: 'STALE_HEAD', message: 'Head changed.', stage: 'precondition', retryable: false, status: 409 });
      const rich = classifyError(new McpError('CHECKS_PENDING', 'Wait', 409, { stage: 'precondition', retryable: true, details: { pending: 2 } }));
      assert.equal(rich.retryable, true);
      assert.deepEqual(rich.details, { pending: 2 });
    });
    
    test('GitHub errors are classified with the real reason', () => {
      const env = classifyError(githubError(422, { message: 'Validation Failed', errors: [{ message: 'label name is invalid' }] }));
      assert.equal(env.code, 'GITHUB_REJECTED');
      assert.match(env.message, /label name is invalid/);
      assert.equal(classifyError(githubError(403, {}, { 'x-ratelimit-remaining': '0' })).code, 'GITHUB_RATE_LIMITED');
      assert.equal(classifyError(githubError(502, {})).retryable, true);
    });
    
    test('mutations keep OUTCOME_UNKNOWN but expose the cause', () => {
      const env = classifyError(githubError(422, { message: 'Validation Failed' }), { sideEffectsPossible: true });
      assert.equal(env.code, 'OUTCOME_UNKNOWN');
      assert.equal(env.retryable, false);
      assert.equal(env.stage, 'github');
      assert.deepEqual(env.cause, { code: 'GITHUB_REJECTED', message: 'Validation Failed' });
      // Deliberate precondition failures stay as-is even for mutations.
      assert.equal(classifyError(new McpError('STALE_HEAD', 'x', 409), { sideEffectsPossible: true }).code, 'STALE_HEAD');
    });
    
    test('zod errors become INVALID_INPUT with paths', () => {
      const result = z.object({ a: z.number() }).safeParse({ a: 'x' });
      assert.ok(!result.success);
      const env = classifyError(result.error);
      assert.equal(env.code, 'INVALID_INPUT');
      assert.deepEqual((env.details as { issues: Array<{ path: string }> }).issues.map(i => i.path), ['a']);
    });
    
    test('secrets never leave the process', () => {
      const secrets = ['ghp_' + 'a'.repeat(36), 'github_pat_' + 'b'.repeat(40), 'pia_mcp_abc.def'];
      const text = `${secrets.join(' ')} Bearer xyz https://x-access-token:[email protected]/a/b.git https://s3/x?X-Amz-Signature=deadbeef /home/node/.claude/creds.json`;
      const redacted = redactSecrets(text);
      for (const value of [...secrets, 'xyz', 's3cr3t', 'deadbeef', '/home/node/.claude']) assert.ok(!redacted.includes(value), value);
      const env = classifyError(new McpError('X', 'y', 400, { details: { accessToken: 'ghp_' + 'c'.repeat(36), nested: { password: 'p' }, ok: 1 } }));
      assert.deepEqual(env.details, { nested: {}, ok: 1 });
      const result = toToolErrorResult(env);
      assert.equal(result.isError, true);
      assert.deepEqual(JSON.parse(result.content[0].text).error, result.structuredContent.error);
    });
  2. propr-dev commented on Sep 28, 2026

    @propr-dev
    ContributorAuthor

    🤖 AI processing has started for this issue using codex agent with gpt-5.6-sol model.

    I'll analyze the problem and work on a solution. This may take a few minutes.

    Processing Details:

    • Agent: codex
    • Model: gpt-5.6-sol
    • Branch: 2593/gpt-5.6-sol-mcp-introduce-a-structure-20260928-2357-n39
    • Base Branch: 2593-epic-mcp-observability-cf6
    • Worktree: issue-2593-20260928-2357-gpt-5.6-sol-n39

    🔍 Track Task Execution

  3. added a commit that references this issue on Sep 29, 2026
  4. added a commit that references this issue on Sep 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions