n8n-io/n8n · error · OperationalError

Require a sessionId for the listing of tools

Error message

Require a sessionId for the listing of tools

What it means

ListTools request handler guard: the MCP SDK's request context carries no sessionId, but the trigger's tool listing is per-session (tools come from the session manager). Without a session there is no toolset to list, so an OperationalError is thrown to the client.

Solutions

  1. Have the client complete the initialize handshake so a session id is assigned
  2. Ensure the proxy/gateway forwards the session id header
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at packages/@n8n/nodes-langchain/nodes/mcp/McpTrigger/McpServer.ts:600 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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

Appendix: source

Thrown at packages/@n8n/nodes-langchain/nodes/mcp/McpTrigger/McpServer.ts:600

			} catch (error) {
				this.logger.warn(
					`Credential gate elicitation failed, falling back to text response: ${
						error instanceof Error ? error.message : String(error)
					}`,
				);
			}
		}

		if (this.resolveFunctions[callId]) this.resolveFunctions[callId]();
		return MessageFormatter.formatCredentialGate(gateResult);
	}

	private setupHandlers(server: Server): void {
		server.setRequestHandler(
			ListToolsRequestSchema,
			(_, extra: RequestHandlerExtra<ServerRequest, ServerNotification>) => {
				if (!extra.sessionId) {
					throw new OperationalError('Require a sessionId for the listing of tools');
				}

				const tools = this.sessionManager.getTools(extra.sessionId) ?? [];
				return {
					tools: tools.map((tool) => ({
						name: tool.name,
						description: tool.description,
						// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-argument
						inputSchema: zodToJsonSchema(tool.schema as any, {
							removeAdditionalStrategy: 'strict',
						}),
					})),
				};
			},
		);

		server.setRequestHandler(CallToolRequestSchema, async (request, extra) => {
			if (!extra.sessionId) {

View on GitHub (pinned to 5ac6606e81)