Skip to main content
Glama

Get Message Context

wa_get_message_context
Read-only

Read the messages around one message in its conversation — the message itself plus the few just before and after it, oldest first — in a single call. Name the message by WhatsApp's message_id (as a webhook delivery or wa_list_messages gave it) or by its cursor, and optionally how many to return on each side (before/after, 1-50, default 5). Use it to see what a message a webhook announced is replying to, or to read the exchange around a message before you act on it, without paging.

Tool call template

This tool declares no required parameters. Add optional parameters from the input schema as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {},
    "name": "wa_get_message_context"
  }
}

Input Schema

NameRequiredDescriptionDefault
afterNohow many messages just after it to return, 1-50; defaults to 5
beforeNohow many messages just before it to return, 1-50; defaults to 5
cursorNothe message's cursor, as wa_list_messages returned it (a webhook delivery carries it as message_seq). Pass this or message_id
account_idNothe account the message belongs to, from wa_list_accounts; omit it when the workspace has only one account
message_idNoWhatsApp's id for the message to read around — the message_id a webhook delivery, wa_list_messages or wa_send_message gave you. Pass this or cursor
include_historyNoalso include imported history (pairing sync, wa_load_history) as neighbours; on automatically when the message itself is history. Off by default, so a live message's neighbours are the live conversation
include_media_urlsNoalso return attachment.media_url on each available attachment — a time-limited (1h) signed URL to GET the bytes with plain HTTP instead of a wa_get_media call; off by default

Output Schema

NameRequiredDescriptionDefault
afterYesthe messages just after it in the same conversation, oldest first; fewer than asked when the message is near the end of the chat
beforeYesthe messages just before it in the same conversation, oldest first; fewer than asked when the message is near the start of the chat
messageNothe message at the centre of the window; absent when the request was declined
refusalNopresent only when the request was declined — including when no such message is stored
account_noticesNopresent when a number this read covers is not working: new messages are not arriving on it; says why and what to do

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed3 schema fields changed
    • changedOutput schema / properties / after / items / properties / attachment / properties / available / description
      Previous value: -"true when the file should be fetchable with wa_get_media(account_id, message_id) — a live received attachment; false for history and for files you sent, which are not kept"New value: +"true when the file should be fetchable with wa_get_media(account_id, message_id) — a live received or sent attachment; false for imported history, which is not kept"
    • changedOutput schema / properties / before / items / properties / attachment / properties / available / description
      Previous value: -"true when the file should be fetchable with wa_get_media(account_id, message_id) — a live received attachment; false for history and for files you sent, which are not kept"New value: +"true when the file should be fetchable with wa_get_media(account_id, message_id) — a live received or sent attachment; false for imported history, which is not kept"
    • changedOutput schema / properties / message / properties / attachment / properties / available / description
      Previous value: -"true when the file should be fetchable with wa_get_media(account_id, message_id) — a live received attachment; false for history and for files you sent, which are not kept"New value: +"true when the file should be fetchable with wa_get_media(account_id, message_id) — a live received or sent attachment; false for imported history, which is not kept"
  2. Changed3 schema fields changed
    • addedOutput schema / properties / after / items / properties / undecryptable
      Added value: +{
      +  "description": "true for an inbound message this account could not decrypt: its text is unavailable. The sender's app may resend it, after which a later read returns the decrypted message",
      +  "type": "boolean"
      +}
    • addedOutput schema / properties / before / items / properties / undecryptable
      Added value: +{
      +  "description": "true for an inbound message this account could not decrypt: its text is unavailable. The sender's app may resend it, after which a later read returns the decrypted message",
      +  "type": "boolean"
      +}
    • addedOutput schema / properties / message / properties / undecryptable
      Added value: +{
      +  "description": "true for an inbound message this account could not decrypt: its text is unavailable. The sender's app may resend it, after which a later read returns the decrypted message",
      +  "type": "boolean"
      +}
  3. Added

TDQS

A4.3/5.0
Behavior4/5

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

Annotations already declare readOnlyHint=true and idempotentHint=false, so the safety profile is covered; the description adds the return ordering (oldest first), the single-call/no-paging behavior, and the fact that media URLs are time-limited 1h signed URLs obtainable without wa_get_media. It does not discuss any account-scoping or permission requirements, but the key read semantics are disclosed.

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

Conciseness5/5

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

Two sentences, front-loaded with the core action and its scope, then the identification and windowing options. Parentheticals carry genuine detail (ordering, ranges, defaults) rather than filler; nothing is wasted.

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?

For a read-only tool with a full output schema and 100% parameter coverage, the description supplies everything needed to invoke it correctly: how to identify the anchor message, how to size the window, and why one would choose it over paging. Return values are rightly left to the output schema.

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

Parameters3/5

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

Schema description coverage is 100%, so each of the seven parameters is already documented, and the description largely restates the schema's before/after ranges, defaults, and the message_id-or-cursor choice. It adds only marginal framing, such as the message_id provenance from a webhook delivery or wa_list_messages, so the baseline 3 applies.

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?

States a specific verb and resource — read the messages around one message in its conversation, including the message itself plus neighbours, oldest first, in a single call. The scope is precise enough to separate it from wa_get_message (single message) and wa_list_messages (paged scan) 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 Guidelines4/5

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

Gives two concrete use cases: seeing what a webhook-announced message is replying to, and reading the surrounding exchange before acting on it — explicitly contrasted with paging. It never says when not to use it (e.g. reading a whole conversation or a single message), so the routing guidance is clear but not exhaustive.

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.

Resources