n8n-io/n8n · error · OperationalError

Require a sessionId for the tool call

Error message

Require a sessionId for the tool call

What it means

CallTool request handler guard: the request context has no sessionId, so the tool call cannot be tied to a session's toolset and pending-call tracking. The handler refuses the call with this OperationalError before looking up any tool.

Solutions

  1. Initialize the MCP session first so calls carry a session id
  2. Check middleware/proxy stripping of session headers
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at packages/@n8n/nodes-langchain/nodes/mcp/McpTrigger/McpServer.ts:619 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/2d87fe0d7d6afb9d. Report an issue: GitHub.

Appendix: source

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

				}

				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) {
				throw new OperationalError('Require a sessionId for the tool call');
			}

			const callId = extra.requestId ? `${extra.sessionId}_${extra.requestId}` : extra.sessionId;

			try {
				if (!request.params?.name || !request.params?.arguments) {
					throw new OperationalError('Require a name and arguments for the tool call');
				}

				const toolName = request.params.name;
				const toolArguments =
					typeof request.params.arguments === 'object' && request.params.arguments !== null
						? request.params.arguments
						: {};

				const tools = this.sessionManager.getTools(extra.sessionId) ?? [];
				const requestedTool = tools.find((tool) => tool.name === toolName);
				if (!requestedTool) {

View on GitHub (pinned to 5ac6606e81)