---
title: Commands
description: "Play 0x10, server → client."
---

`play` · `0x10` · **clientbound** (server → client)

Sends the full command tree (a graph of `nodes` with `rootIndex` pointing to the root) so the client can parse and tab-complete commands locally. The server sends it after login and whenever the available commands change. The client uses it for syntax highlighting and suggestions in the chat box.

Sent by the server, read by the client. Listen for it with `client.on("Commands", (data) => …)` on the receiving side.

## Fields

| Field | Type | Notes |
|---|---|---|
| `nodes` | Array |  |
| `rootIndex` | VarInt |  |

## Send it

```ts
import { helpers } from "mc-protocol";
const { literal, argument, createCommandTree } = helpers;

await client.sendPacket("Commands", createCommandTree([
  literal("ping", { executable: true }),
  literal("tp", {
    children: [argument("target", "entity", { single: true, playersOnly: true, executable: true })],
  }),
  literal("say", {
    children: [argument("message", "string", { type: "greedy", executable: true, suggestions: "ask_server" })],
  }),
  literal("run", { redirect: "root" }),
]));
```

`createCommandTree` numbers the nodes, packs the flags and resolves parser IDs. See [Commands](/docs/commands) for parsers, properties and redirects.

Field aliases listed under Notes are accepted as alternative keys when writing.

Source: [`src/Core/Versions/776/Packets/play/clientbound/Commands.ts`](https://github.com/GDLev/mc-protocol/blob/master/src/Core/Versions/776/Packets/play/clientbound/Commands.ts)
