# Tool.action
URL: https://lsd.tools/docs/api-tool-action
Updated: 2026-07-17

## Parameters

| name | type | default | description |
|---|---|---|---|
| `route` | `str` | — | the action route: `app/<verb>`, `entity/<type>/<verb>`, or another namespace |
| `label` | `str` | `None` | the menu / button label (defaults to a humanized last route segment) |
| `icon` | `str` | `None` | a symbolic icon name for the menu item or context action |

## Example

```python
@tool.action("app/refresh", label="Refresh", icon="view-refresh-symbolic")
def refresh(ctx, **values):
    ctx.rerun()
```

An entity context-menu action:

```python
@tool.action("entity/drillholes/export")
def export(ctx, path: str = "out.csv"):
    ctx.entity.step("desurvey").table().write_csv(path)
```

## Notes

The function is `(ctx: Context, **values)`. At mount, `app/<verb>` routes become Run-menu items and
`entity/<type>/<verb>` routes become entity context-menu actions; actions are also exposed as MCP
tools. Any route is reachable programmatically via [`dispatch`](/docs/api-tool-dispatch).

## See also

**API:** [dispatch](/docs/api-tool-dispatch) · [command](/docs/api-tool-command) · [Context](/docs/api-context)

**Guides:** [Commands & actions](/docs/tools-commands-actions)
