Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

E401

For the complete documentation index optimized for AI agents, see llms.txt.

MCP Single Value Requirement

Erroneous Code Example

This error occurs when an MCP (Model Context Protocol) query returns multiple values when only a single value is expected.

In this example, the MCP query returns multiple users, but MCP expects a single value. This is so the agent using the MCP tool can traverse from the return value of the query.

#[mcp]
Query getUsers(userId: ID, postId: ID) =>
    user <- N<User>(userId)
    post <- N<Post>(postId)
    RETURN user, post

Solution

Ensure MCP queries return exactly one value.

#[mcp]
Query getUsers(userId: ID, postId: ID) =>
    user <- N<User>(userId)
    post <- N<Post>(postId)
    RETURN user