Skip to content

Streaming a response back to the client #42

@mbklein

Description

@mbklein

I'm new to MCP in general and Anubis MCP in particular, so please let me know if this question is off the mark.

Is there a way for a server to stream the results of a long-running operation back to the client, or am I misunderstanding how StreamableHTTP and SSE work? For example, if I have a datastore with several hundred thousand items in it, and a tool to expose all of its unique identifiers, it would be great to

MyDataStore.unique_ids()
|> Stream.chunk_every(50)
|> Stream.each(fn chunk -> do_something(chunk) end) # send a chunk of 50 IDs to the client through the transport and tell it to await more
|> Stream.run()

{:noreply, frame} # finish and tell the client we're done

But I haven't been able to find anything that will send events to the client if those events aren't already compiled into a structured binary.

Is this a feasible approach, or will I have to implement pagination (and instruct the agent how to use it in my tool description)?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions