Skip to main content
Glama

chat

Synchronous AI chat that can rewrite specific paragraphs, add or remove table rows, restructure sections, generate new content from templates, or transform an entire document. Pass document_html only to load or replace the document; once a session holds a document the server persists it across turns, so omit it on follow-up turns. To replace the whole document with EXACT content you already hold, pass that content in document_html (a verbatim load — the AI never re-types it) or upload it via upload_document_base64; describing the content only in message makes the AI author it, which can drift from your text. Returns AI response text plus structural document changes (HTML edits, additions, deletions) with chunk IDs. One billable operation per document-modifying turn; very large multi-section edits bill one operation per 25 sections changed. For long-running edits or human-in-the-loop approval, use chat_async. Optional: model_tier (core/turbo/pro/max), thinking_depth (fast/balanced/deep), image_attachments for multimodal vision. RECOMMENDED for AI agents working with large documents (>20 pages): set response_mode='compact' to skip the full HTML in the response (the AI returns only per-section diffs in chunk_diffs) and save thousands of tokens per turn. To read sections in compact mode, just send a natural-language request like 'show me the force majeure section' — the AI returns the content in the reply text. Always use natural language to describe what you want; the AI handles all internal section lookups. If a call times out or drops, do not send it again: the turn keeps running and its reply is kept for 1 hour. Call get_session_jobs (same session_id), pick the 'sync_chat' job whose created_at matches when you sent the call, and poll it with get_job until completed (read its result), awaiting_approval (approve or reject its pending changes; if its metadata.awaiting_kind is 'continue_prompt', call continue_chat instead), or failed/cancelled (read its error).

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "message": "<message>",
      "session_id": "<session_id>"
    },
    "name": "chat"
  }
}

Input Schema

NameRequiredDescriptionDefault
messageYesYour message to the AI assistant.
upload_idNoOptional upload_id from request_upload_url (after the PUT): the file is loaded into this session (replacing its focused document) before the turn, so one call loads and edits it. Needs upload_filename.
model_tierNoAI model to use: 'core' (default, fast), 'turbo' (fastest), 'pro' (advanced reasoning), 'max' (most capable).
session_idYesUnique session identifier. Reuse to continue a conversation.
document_idNoTarget a specific open document by id (ids come from /v1/sessions/{session_id}/documents). Omit to target the focused document (default — unchanged single-document behaviour). When set, that document becomes the focus for this turn.
approval_modeNoChange review mode: 'approve_all' (default, auto-applies changes) or 'ask_every_time' (pauses for your review).
document_htmlNoCurrent document HTML. OMIT this when the session already holds the document — the server persists it across turns, so you don't re-send it every turn; pass it only to load new content or replace the document wholesale (a verbatim load — the AI never re-types content passed here). Include data-chunk-id attributes on elements to enable targeted AI edits.
export_formatNoOptional: the reply also carries `download` (a short-lived URL and curl_example) for the document in this format, so no request_download_url call is needed. While changes are held, it is the document before this turn.
response_modeNoResponse shape control. 'full' (default) returns the complete updated document HTML — required by web app editors and recommended for small documents (<20 pages). 'compact' (recommended for AI agents editing large documents) suppresses the full HTML and returns only per-section diffs (chunk_diffs) for changed sections, saving thousands of tokens per turn. To read sections in compact mode, just send a natural-language request like 'show me the force majeure section' — the AI returns the content in the chat reply text. 'summary' (agent jobs): no HTML or diffs, only the reply, change counts, ids of held changes and turn_index; its size does not grow with the document.full
thinking_depthNoReasoning depth: 'fast', 'balanced' (default), or 'deep'. Controls how much analysis the AI performs.
upload_filenameNoThe filename given to request_upload_url for upload_id.
image_attachmentsNoInline images for vision-based analysis (base64-encoded).
cross_session_scopeNoOptional list of session ids to restrict cross-session SEARCH to (e.g. one end-customer's sessions). Omit to search all of this account's sessions. Only narrows within the API-key owner; ignored unless cross_session_search is on.
cross_session_memoryNoWhen true, the AI carries a private rolling memory of context across THIS account's chats (off by default). Per-request override of your saved Settings default.
cross_session_searchNoWhen true, the AI may search your PAST chats and documents on demand to reuse prior work and open a found document (off by default). Per-request override of your saved Settings default; never affects the always-on search of the open document.
deleted_part_chunk_idsNoOptional list of chunk ids (data-chunk-id values) of OUT-OF-FLOW part sections (page headers/footers, footnote/endnote bodies, comments) to delete explicitly, sent alongside document_html. Out-of-flow parts absent from document_html are always KEPT — an editor view not containing them is their normal state, never a deletion — so removing one requires naming its id here. Ids that are not stored out-of-flow parts are ignored (in-flow content keeps the default behavior). Omit when deleting nothing.
cross_session_memory_keyNoOptional per-request id of YOUR end-customer so the cross-session memory note is kept in a separate file per end-customer. Omit for one account-level note (the default / B2C).

Output Schema

NameRequiredDescriptionDefault
hintNoAdvisory guidance for API callers (additive; absent on most responses). Currently: prefer_chat_async_for_large_generations — this turn ran long enough that the same work submitted via POST /v1/chat/async would be safer (no gateway timeout risk) and reports progress.
usageNoOperation usage data. Present for authenticated users with usage tracking.
downloadNoPresent whenever export_format was set (not on a failed turn): download_url, curl_example, filename, format, expires_at, expires_in_seconds (or error, saying why no link could be made). While changes are held for review, it is the document as it was before this turn (before_this_turn is true): nothing from this turn is in it yet.
responseYesAI assistant's response text.
model_tierNoPresent only when part of this turn ran on a different model tier than requested: tier_requested, tier_used and reason. reason 'context_overflow' = the document is too large for the requested tier's context window, so that part of the turn ran on the tier named in tier_used instead (billing is per operation and unchanged).
session_idYesSession identifier for this conversation.
turn_indexNoThis turn's position in the session history. Pass it to revert_session_to_message to put the document back to just before this turn. Absent while the turn waits for review (find it later with get_session_history).
document_changesNoDocument modifications made by the AI. Present only when the document was changed.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed14 schema fields changed
    • removedInput schema / properties / authorization
      Removed value: -{
      -  "anyOf": [
      -    {
      -      "type": "string"
      -    },
      -    {
      -      "type": "null"
      -    }
      -  ],
      -  "title": "Authorization"
      -}
    • removedInput schema / properties / cursor_context
      Removed value: -{
      -  "anyOf": [
      -    {
      -      "additionalProperties": true,
      -      "type": "object"
      -    },
      -    {
      -      "type": "null"
      -    }
      -  ],
      -  "description": "Editor cursor context at message time, used to default the insert location for new images, diagrams, or sections when the user's prompt doesn't name a position. Shape: {chunk_id: str, pos_in_chunk?: int, text_before?: str, text_after?: str}. Omit when the user typed in chat without focusing the editor first.",
      -  "title": "Cursor Context"
      -}
    • addedInput schema / properties / export_format
      Added value: +{
      +  "anyOf": [
      +    {
      +      "enum": [
      +        "docx",
      +        "pdf",
      +        "html",
      +        "markdown",
      +        "txt"
      +      ],
      +      "type": "string"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "description": "Optional: the reply also carries `download` (a short-lived URL and curl_example) for the document in this format, so no request_download_url call is needed. While changes are held, it is the document before this turn.",
      +  "title": "Export Format"
      +}
    • removedInput schema / properties / html_document_id
      Removed value: -{
      -  "anyOf": [
      -    {
      -      "maxLength": 256,
      -      "type": "string"
      -    },
      -    {
      -      "type": "null"
      -    }
      -  ],
      -  "description": "Optional: the open document (id from /v1/sessions/{session_id}/documents) that `document_html` is the editor state of. The html is applied to that document only, and a turn that names no `document_id` works on that document by default (it is the one on screen); it does not pin the turn (use `document_id` for that). Set by the web app; omit to mean the focused document.",
      -  "title": "Html Document Id"
      -}
    • changedInput schema / properties / response_mode / anyOf
      Previous value: -[
      -  {
      -    "enum": [
      -      "full",
      -      "compact"
      -    ],
      -    "type": "string"
      -  },
      -  {
      -    "type": "null"
      -  }
      -]New value: +[
      +  {
      +    "enum": [
      +      "full",
      +      "compact",
      +      "summary"
      +    ],
      +    "type": "string"
      +  },
      +  {
      +    "type": "null"
      +  }
      +]
    • changedInput schema / properties / response_mode / description
      Previous value: -"Response shape control. 'full' (default) returns the complete updated document HTML — required by web app editors and recommended for small documents (<20 pages). 'compact' (recommended for AI agents editing large documents) suppresses the full HTML and returns only per-section diffs (chunk_diffs) for changed sections, saving thousands of tokens per turn. To read sections in compact mode, just send a natural-language request like 'show me the force majeure section' — the AI returns the content in the chat reply text."New value: +"Response shape control. 'full' (default) returns the complete updated document HTML — required by web app editors and recommended for small documents (<20 pages). 'compact' (recommended for AI agents editing large documents) suppresses the full HTML and returns only per-section diffs (chunk_diffs) for changed sections, saving thousands of tokens per turn. To read sections in compact mode, just send a natural-language request like 'show me the force majeure section' — the AI returns the content in the chat reply text. 'summary' (agent jobs): no HTML or diffs, only the reply, change counts, ids of held changes and turn_index; its size does not grow with the document."
    • removedInput schema / properties / touched_chunk_ids
      Removed value: -{
      -  "anyOf": [
      -    {
      -      "items": {
      -        "type": "string"
      -      },
      -      "maxItems": 50000,
      -      "type": "array"
      -    },
      -    {
      -      "type": "null"
      -    }
      -  ],
      -  "description": "Optional list of chunk ids (data-chunk-id values) the user actually edited since the last sync, sent alongside document_html. When present, a chunk NOT in this list whose text is unchanged keeps its stored formatting byte-for-byte even if the client serialized it differently (protects styling from editor round-trip loss). Chunks in the list — and any chunk whose text changed — always take the submitted content. Omit for the default behavior (any differing chunk is treated as an edit).",
      -  "title": "Touched Chunk Ids"
      -}
    • addedInput schema / properties / upload_filename
      Added value: +{
      +  "anyOf": [
      +    {
      +      "maxLength": 255,
      +      "type": "string"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "description": "The filename given to request_upload_url for upload_id.",
      +  "title": "Upload Filename"
      +}
    • addedInput schema / properties / upload_id
      Added value: +{
      +  "anyOf": [
      +    {
      +      "maxLength": 64,
      +      "type": "string"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "description": "Optional upload_id from request_upload_url (after the PUT): the file is loaded into this session (replacing its focused document) before the turn, so one call loads and edits it. Needs upload_filename.",
      +  "title": "Upload Id"
      +}
    • removedInput schema / properties / user_id
      Removed value: -{
      -  "anyOf": [
      -    {
      -      "maxLength": 256,
      -      "type": "string"
      -    },
      -    {
      -      "type": "null"
      -    }
      -  ],
      -  "description": "User identifier. Automatically set from authentication — typically omit this.",
      -  "title": "User Id"
      -}
    • removedInput schema / properties / window_id
      Removed value: -{
      -  "anyOf": [
      -    {
      -      "type": "string"
      -    },
      -    {
      -      "type": "null"
      -    }
      -  ],
      -  "description": "Optional identifier for the client window (set by the web app) so concurrent edits from two windows of the same chat are merged rather than overwritten. Agents/API may omit.",
      -  "title": "Window Id"
      -}
    • addedOutput schema / properties / download
      Added value: +{
      +  "anyOf": [
      +    {
      +      "additionalProperties": true,
      +      "type": "object"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "description": "Present whenever export_format was set (not on a failed turn): download_url, curl_example, filename, format, expires_at, expires_in_seconds (or error, saying why no link could be made). While changes are held for review, it is the document as it was before this turn (before_this_turn is true): nothing from this turn is in it yet.",
      +  "title": "Download"
      +}
    • addedOutput schema / properties / model_tier
      Added value: +{
      +  "anyOf": [
      +    {
      +      "additionalProperties": true,
      +      "type": "object"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "description": "Present only when part of this turn ran on a different model tier than requested: tier_requested, tier_used and reason. reason 'context_overflow' = the document is too large for the requested tier's context window, so that part of the turn ran on the tier named in tier_used instead (billing is per operation and unchanged).",
      +  "title": "Model Tier"
      +}
    • addedOutput schema / properties / turn_index
      Added value: +{
      +  "anyOf": [
      +    {
      +      "type": "integer"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "description": "This turn's position in the session history. Pass it to revert_session_to_message to put the document back to just before this turn. Absent while the turn waits for review (find it later with get_session_history).",
      +  "title": "Turn Index"
      +}
  2. Changed1 schema field changed
    • addedInput schema / properties / html_document_id
      Added value: +{
      +  "anyOf": [
      +    {
      +      "maxLength": 256,
      +      "type": "string"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "description": "Optional: the open document (id from /v1/sessions/{session_id}/documents) that `document_html` is the editor state of. The html is applied to that document only, and a turn that names no `document_id` works on that document by default (it is the one on screen); it does not pin the turn (use `document_id` for that). Set by the web app; omit to mean the focused document.",
      +  "title": "Html Document Id"
      +}
  3. First observed

TDQS

A4.8/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden and does so: it discloses billing semantics ('one billable operation per document-modifying turn', 'per 25 sections changed'), server-side document persistence across turns, the drift risk when content is described in `message` rather than passed verbatim, the 1-hour retention of a dropped turn's reply, and the no-retry rule on timeout. This is exactly the operational context an agent needs before mutating a session.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Front-loaded with purpose and operating rules, then layered concerns (persistence, verbatim load, returns/billing, async alternative, options, compact mode, timeout recovery) each in one sentence. It is long but proportionate to 17 parameters and stateful behavior; the only waste is the compact-mode retrieval tip, which repeats its schema field almost verbatim.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

An output schema exists so return values needn't be overspecified, yet the description still summarizes the response shape (reply text plus structural edits with chunk IDs) and how response_mode changes it. Combined with billing, persistence, failure recovery, and sibling routing, nothing an agent needs to invoke this correctly is missing.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so baseline is 3, but the description adds cross-parameter meaning the individual fields cannot convey: the interaction between document_html, upload_id, and message (load vs author vs drift), and the follow-up-turn rule for document_html. Some prose (model_tier/thinking_depth options, the compact-mode reading tip) restates schema text, which caps it below 5.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Opens with a specific verb+resource ('Synchronous AI chat') and enumerates the concrete document operations it performs (paragraph rewrite, table rows, restructuring, template generation, whole-document transform). It also names the sibling it is not ('For long-running edits or human-in-the-loop approval, use chat_async'), so an agent can route between the two without opening either schema.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicit when-to-use rules throughout: pass document_html only to load/replace, omit it on follow-ups because the server persists it; use document_html or upload_document_base64 for verbatim content instead of describing it in `message`; use chat_async for long-running/approval flows; use response_mode='compact' for large documents. It even specifies a recovery path for timeout/drop (get_session_jobs → get_job, and continue_chat if awaiting_kind is 'continue_prompt').

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.