n8n-io/n8n · error · Error

This tool is only available when running inside the n8n gate

Error message

This tool is only available when running inside the n8n gateway context.

What it means

Thrown by requireSecretsBuffer when context.secretsBuffer is undefined — the tool is being executed outside the n8n gateway context that provides a SecretsBuffer. The browser_capture_secret and browser_create_credential tools depend on gateway-injected infrastructure; without it they cannot function. This is an environment/initialization error, not a usage error.

Source

Thrown at packages/@n8n/mcp-browser/src/tools/credential.ts:172

			}

			return formatCallToolResult({ ok: true, credentialId: credential.credentialId });
		},
		getAffectedResources() {
			return [CREATE_CREDENTIAL_RESOURCE];
		},
	};
}

// ---------------------------------------------------------------------------
// Helpers
// ---------------------------------------------------------------------------

function requireSecretsBuffer(
	context: ToolContext,
): asserts context is ToolContext & { secretsBuffer: SecretsBuffer } {
	if (!context.secretsBuffer) {
		throw new Error('This tool is only available when running inside the n8n gateway context.');
	}
}

function requireCreateCredential(context: ToolContext): asserts context is ToolContext & {
	createCredential: (payload: CreateCredentialPayload) => Promise<{ credentialId: string }>;
} {
	if (!context.createCredential) {
		throw new Error('This tool is only available when running inside the n8n gateway context.');
	}
}

/**
 * Recursively walk `resolveData`. Every leaf string value is a field name to
 * look up in `captured`. Throws if a field name is not found.
 */
function resolveSecrets(
	resolveData: Record<string, unknown>,
	captured: Map<string, string>,

View on GitHub (pinned to 5ac6606e81)

Solutions

  1. Run these tools only within the n8n gateway that injects secretsBuffer into ToolContext.
  2. If testing, provide a mock secretsBuffer in the ToolContext before invoking the tool.
  3. Upgrade the gateway/host to a version that wires secretsBuffer into the tool context.

Example fix

// before — no secretsBuffer in context
tool.execute(args, {}); // throws — context.secretsBuffer undefined

// after — provide secretsBuffer (gateway or mock)
tool.execute(args, { secretsBuffer: new SecretsBuffer(), createCredential: async () => ({ credentialId: 'x' }) });
Defensive patterns

Strategy: type-guard

Validate before calling

if (!('secretsBuffer' in context) || !context.secretsBuffer) {
  throw new Error('Run this tool inside the n8n gateway context.');
}

Type guard

function hasSecretsBuffer(c: ToolContext): c is ToolContext & { secretsBuffer: SecretsBuffer } {
  return !!c.secretsBuffer;
}

Prevention

When it happens

Trigger: Invoking browser_capture_secret when the ToolContext was not constructed with a secretsBuffer (e.g. running the MCP browser server standalone, or a test harness that omitted the gateway wiring).

Common situations: Running the browser MCP tools in a non-gateway host (standalone CLI, direct adapter test). Gateway version mismatch where secretsBuffer injection was not yet implemented. Misconfigured tool registry that instantiates credential tools without gateway context.

Related errors


AI-assisted analysis of n8n-io/n8n@5ac6606e81 (2026-08-12). Data as JSON: /api/errors/36fbfe9ab068843d. Report an issue: GitHub.