# UnifAPI streaming support

Unif API documents streaming support for agents at predictable URLs. Streaming is available in the agent transport layer through Streamable HTTP MCP and in the public `/ask` endpoint through Server-Sent Events.

## When to use streaming

- Use MCP Streamable HTTP when Codex, Claude Code, Cursor, Claude Desktop, or another MCP client needs live public-data tools.
- Use `/ask` SSE when a crawler, agent, or integration wants a progressive answer from UnifAPI discovery content.
- Use direct REST JSON when application code wants one normalized response envelope from a public-data operation.

## Supported streaming surfaces

- [MCP Streamable HTTP](https://unifapi.com/mcp) - Use the hosted UnifAPI MCP server when an agent needs progress-aware tool discovery and tool calls. Connector URL: https://mcp.unifapi.com.
- [NLWeb ask SSE](https://unifapi.com/ask) - Use Server-Sent Events on /ask for lightweight discovery answers that emit start, result, and complete events.
- [Direct REST JSON](https://api.unifapi.com) - Use direct HTTP API routes for product code that wants one normalized JSON envelope per public-data call.

## SSE quick start

```bash
curl -N https://unifapi.com/ask \
  -H "Content-Type: application/json" \
  -H "Accept: text/event-stream" \
  -d '{"query":{"text":"Where is the UnifAPI OpenAPI spec?"},"prefer":{"streaming":true}}'
```

The stream emits:

- `start` - Confirms the stream has opened and includes UnifAPI NLWeb-style metadata.
- `result` - Carries one answer result with title, URL, snippet, and source metadata.
- `complete` - Marks the end of the stream so an agent can stop waiting and summarize.

## Direct REST behavior

Direct REST API operations currently return one JSON envelope per call. For long-running REST workflows, agents should use pagination, request ids, retries, and the documented error envelope. Use MCP when the task benefits from an agent-held session and progressive tool work.

## Related resources

- MCP setup: https://unifapi.com/mcp
- Developer resources: https://unifapi.com/developers.md
- Full LLM context: https://unifapi.com/llms-full.txt
- OpenAPI spec: https://unifapi.com/openapi.json
