> ## Documentation Index
> Fetch the complete documentation index at: https://doc.featherhq.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Stream an LLM chat turn that uses the MCP server as its toolbelt

> SSE stream of one chat turn.

The LLM (Claude) sees every tool registered on our MCP server. When
the model wants a tool, we dispatch it via ``mcp.call_tool`` — same
code path as remote MCP clients hitting ``/mcp/`` — and feed the
result back. ``end_user_id`` (optional) pins all end-user-scoped
tool calls to that contact.

The endpoint streams an event-stream of:

- ``text_delta`` — incremental assistant text (append to the bubble).
- ``tool_call`` — model decided to call a tool (name, input).
- ``tool_result`` — JSON-string result (or error).
- ``turn_end`` — one Claude turn finished (may loop again for tools).
- ``done`` — full turn complete.
- ``error`` — fatal; stream closes.

No RBAC dependency on this endpoint itself — tools enforce their
own permissions via the ``@cx_tool`` registry, so a viewer-role
caller chatting here can only invoke the read tools.



## OpenAPI

````yaml /api-reference/openapi.json post /v1/mcp-chat/stream
openapi: 3.1.0
info:
  title: Feather API
  description: >-
    Unified customer experience platform API. Manages identity, conversations,
    memory, agents, procedures, policies, model routing, knowledge bases,
    integrations, and runtime execution.
  version: 1.21.0
servers:
  - url: https://api-sandbox.featherhq.com
    description: Sandbox
  - url: http://localhost:8000
    description: Local dev
security: []
paths:
  /v1/mcp-chat/stream:
    post:
      tags:
        - mcp-chat
      summary: Stream an LLM chat turn that uses the MCP server as its toolbelt
      description: |-
        SSE stream of one chat turn.

        The LLM (Claude) sees every tool registered on our MCP server. When
        the model wants a tool, we dispatch it via ``mcp.call_tool`` — same
        code path as remote MCP clients hitting ``/mcp/`` — and feed the
        result back. ``end_user_id`` (optional) pins all end-user-scoped
        tool calls to that contact.

        The endpoint streams an event-stream of:

        - ``text_delta`` — incremental assistant text (append to the bubble).
        - ``tool_call`` — model decided to call a tool (name, input).
        - ``tool_result`` — JSON-string result (or error).
        - ``turn_end`` — one Claude turn finished (may loop again for tools).
        - ``done`` — full turn complete.
        - ``error`` — fatal; stream closes.

        No RBAC dependency on this endpoint itself — tools enforce their
        own permissions via the ``@cx_tool`` registry, so a viewer-role
        caller chatting here can only invoke the read tools.
      operationId: chat_stream_v1_mcp_chat_stream_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ChatStreamRequest'
        required: true
      responses:
        '200':
          description: Successful Response
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - APIKeyHeader: []
components:
  schemas:
    ChatStreamRequest:
      properties:
        messages:
          items:
            $ref: '#/components/schemas/ChatMessage'
          type: array
          minItems: 1
          title: Messages
        end_user_id:
          anyOf:
            - type: string
              format: uuid
            - type: 'null'
          title: End User Id
        model:
          type: string
          title: Model
          description: Chat completions model identifier (OpenAI).
          default: gpt-5.4-mini
        max_tokens:
          type: integer
          maximum: 16384
          minimum: 1
          title: Max Tokens
          default: 4096
      type: object
      required:
        - messages
      title: ChatStreamRequest
      description: |-
        Body for ``POST /v1/mcp-chat/stream``.

        ``messages`` is the full rolling history. ``end_user_id`` (optional)
        pins the bound end-user for the MCP tool calls — same semantics as
        the ``x-end-user-id`` header on the MCP HTTP endpoint.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ChatMessage:
      properties:
        role:
          type: string
          enum:
            - user
            - assistant
          title: Role
        content:
          type: string
          title: Content
      type: object
      required:
        - role
        - content
      title: ChatMessage
      description: One conversation message in the rolling history sent from the UI.
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    APIKeyHeader:
      type: apiKey
      in: header
      name: x-api-key

````