grist-mcp
# grist-mcp
MCP server for [Grist](https://www.getgrist.com/) — enables LLMs to create and manage Grist applications through natural language.
19 tools covering document creation, schema management, data operations, and full UI control (pages, widgets, layouts, linking).
## Quick Start
```bash
npm install
npm run build
```
### Claude Code / Claude Desktop
Add to your MCP settings (`~/.claude/settings.json` for Claude Code, or Claude Desktop config):
```json
{
"mcpServers": {
"grist": {
"command": "node",
"args": ["/path/to/grist-mcp/dist/index.js"],
"env": {
"GRIST_API_URL": "http://localhost:8484",
"GRIST_API_KEY": "your-api-key"
}
}
}
}
```
### Streamable HTTP
```bash
GRIST_API_URL=http://localhost:8484 GRIST_API_KEY=your-key node dist/index.js --http 3000
```
Server listens at `http://localhost:3000/mcp` with a health check at `/health`.
## Configuration
| Variable | Required | Description |
|----------|----------|-------------|
| `GRIST_API_URL` | Yes | Base URL of the Grist instance (e.g. `http://localhost:8484`) |
| `GRIST_API_KEY` | Yes | API key for authentication |
| `GRIST_DOC_ID` | No | Default document ID — avoids passing `doc_id` to every tool call |
## Tools
### Document Tools
| Tool | Description |
|------|-------------|
| `list_documents` | List workspaces and documents |
| `create_document` | Create a new empty document |
| `describe_document` | Full schema as Python class definitions |
### Schema Tools
| Tool | Description |
|------|-------------|
| `create_tables` | Create tables with typed columns |
| `add_columns` | Add columns to an existing table |
| `modify_columns` | Change column types, add formulas, rename |
| `delete_columns` | Remove a column |
### Data Tools
| Tool | Description |
|------|-------------|
| `get_records` | Read records with filter, sort, limit |
| `add_records` | Insert records |
| `update_records` | Update records by ID |
| `delete_records` | Delete records by ID |
### UI Tools
| Tool | Description |
|------|-------------|
| `create_page` | Create a page with multiple widgets, layout, and linking |
| `add_widget_to_page` | Add a widget to an existing page |
| `link_widgets` | Master-detail linking between widgets |
| `configure_page_layout` | Rearrange widgets (stacked, side_by_side, left_panel, grid_2x2) |
| `rename_page` | Rename a page |
| `create_summary_table` | Grouped/pivot view of a table |
### Power Tools
| Tool | Description |
|------|-------------|
| `run_sql` | Read-only SQL queries against the document |
| `apply_user_actions` | Raw UserAction escape hatch |
## Resources
| URI | Description |
|-----|-------------|
| `grist://docs/{docId}/schema` | Document schema as Python classes |
| `grist://column-types` | Column type reference documentation |
## Prompts
| Prompt | Description |
|--------|-------------|
| `create_application` | Guided workflow for building a Grist app from a use-case description |
| `write_formula` | Guided workflow for writing a Grist Python formula |
## Column Types
`Text`, `Numeric`, `Int`, `Bool`, `Date`, `DateTime`, `Choice`, `ChoiceList`, `Ref:<Table>`, `RefList:<Table>`, `Attachments`, `Any`
## Testing
### Integration tests (requires a running Grist instance)
```bash
# Start Grist in Docker
docker run -d --name grist-test -p 8484:8484 \
-e GRIST_DEFAULT_EMAIL=test@example.com \
-e GRIST_FORWARD_AUTH_HEADER=X-Forwarded-User \
-e GRIST_FORWARD_AUTH_LOGOUT_PATH=_unused \
gristlabs/grist
# Create an API key via the Grist UI, then:
npm run build
GRIST_API_URL=http://localhost:8484 GRIST_API_KEY=your-key node dist/test-integration.js
```
The integration test creates a document, exercises all 19 tools and both resources, and verifies results (50 assertions).
## License
Apache-2.0
Authored by Evan Wies <evan@neomantra.net>TDQS
Scored across 19 tools
Tools are organized by distinct resources (documents, tables, columns, records, pages/widgets), and descriptions make the boundaries clear. Minor overlap exists between apply_user_actions and the higher-level tools (it is explicitly the escape hatch), and create_summary_table borrows the 'table' name for what is really a grouped view.
Every tool follows a consistent snake_case verb_noun pattern (create_document, add_columns, get_records, delete_records, rename_page, etc.). No mixed cases or inconsistent verb conventions across the set.
19 tools is slightly above the ideal band but justified: it spans five resource types (documents, tables, columns, records, pages) each requiring separate operations. No tool looks redundant or filler.
Records and columns have full CRUD, and pages/widgets have create, link, layout, and rename operations. Gaps remain for deletes on documents, tables, and pages/widgets, but apply_user_actions provides a documented workaround for these.