# Chat

## Get Chat Messages

`TOOL discourse_get_chat_messages`

Get messages from a chat channel. Returns JSON object with channel_id, messages array (id, username, created_at, message, edited, thread_id, in_reply_to_id), and meta.

Authentication: no security requirement declared for this operation.

Parameters:

- `channel_id` (argument, integer, required) - The chat channel ID
  Type: integer
  
  The chat channel ID
  
  exclusiveMinimum: 0

- `page_size` (argument, integer, optional) - Number of messages to return (default: 50, max: 50)
  Type: integer
  
  Number of messages to return (default: 50, max: 50)
  
  minimum: 1
  
  maximum: 50

- `target_message_id` (argument, integer, optional) - Message ID to query around or paginate from
  Type: integer
  
  Message ID to query around or paginate from
  
  exclusiveMinimum: 0

- `direction` (argument, string, optional) - Pagination direction: 'past' for older messages, 'future' for newer
  Type: string
  
  Pagination direction: 'past' for older messages, 'future' for newer
  
  enum: ["past","future"]

- `target_date` (argument, string, optional) - ISO 8601 date string to query messages around
  Type: string
  
  ISO 8601 date string to query messages around

Declared MCP annotations:

```json
{
  "readOnlyHint": true,
  "destructiveHint": false,
  "idempotentHint": true,
  "openWorldHint": true
}
```

## Examples

### JSON-RPC

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "discourse_get_chat_messages",
    "arguments": {
        "channel_id": 0,
        "page_size": 1,
        "target_message_id": 0,
        "direction": "past",
        "target_date": "string"
      }
  }
}
```

### TypeScript

```typescript
const result = await client.callTool({
  "name": "discourse_get_chat_messages",
  "arguments": {
    "channel_id": 0,
    "page_size": 1,
    "target_message_id": 0,
    "direction": "past",
    "target_date": "string"
  }
});
```

### Python

```python
result = await session.call_tool("discourse_get_chat_messages", arguments={
  "channel_id": 0,
  "page_size": 1,
  "target_message_id": 0,
  "direction": "past",
  "target_date": "string"
})
```
