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