@casoon/opengrid-mcp
v0.25.0
Published
opengrid as an MCP App: the grid in a chat client, driven by keyboard and by the model through one view
Readme
@casoon/opengrid-mcp
opengrid's data grid as an MCP App: a chat client shows the grid in the conversation, and the reader's keyboard and the model work on one view. The model filters, sorts and groups by setting that view; the reader does the same with the grid; each sees what the other did.
The rows stay with the server. The model gets columns, counts and — when the reader hands them over — the selected rows, never a whole source.
Install
Claude Desktop runs the server locally; nothing is hosted. In Settings → Developer → Edit Config:
{
"mcpServers": {
"opengrid": {
"command": "npx",
"args": ["-y", "@casoon/opengrid-mcp", "--config", "/path/to/opengrid-mcp.json"]
}
}
}Restart the app, then ask for a source: "Open the orders as a grid." Claude asks once whether it may show the app.
Not yet tried in Claude Desktop or any other host: the tests run the view in a test host of their own. A report of how it behaves in yours is welcome as an issue.
| Client | | |---|---| | Claude Desktop | local, as above | | Claude Code | the tools work; a terminal shows no grid | | claude.ai, ChatGPT | need a server reachable over HTTP (a custom connector); this package speaks stdio |
Sources
The operator decides what exists, in opengrid-mcp.json. Paths are relative to
the file:
{
"sources": {
"orders": {
"csv": "data/orders.csv",
"schema": "data/orders.schema.json",
"title": "Orders",
"columns": ["id", "customer", "country", "amount", "ordered_on"],
"fields": ["id", "customer", "country", "amount", "qty", "ordered_on"]
}
}
}| Key | |
|---|---|
| csv, schema | the data and its schema, as opengrid's load_csv reads them |
| columns | the grid's columns, in order — its columns attribute |
| fields | the fields any query may name; absent, every field of the schema |
| title | the grid's label |
The model names a source. It never names a path, writes SQL or reaches a
network, and a query naming a field outside fields is refused.
A source on an opengrid-server
A source can also live on an opengrid-server,
reached by URL and token:
{
"sources": {
"orders": {
"server": { "url": "https://grid.example.com", "source": "orders", "tokenEnv": "ORDERS_TOKEN" },
"columns": ["id", "customer", "country", "amount"],
"title": "Orders"
}
}
}| Key | |
|---|---|
| server.url | the server; only the operator names it, never the model. https://…; http:// only for localhost, 127.0.0.1 and [::1], because the token travels with every request |
| server.source | the source's name there; absent, the name it has here |
| server.tokenEnv / server.token | the bearer token — preferably from an environment variable, so it is not in the file |
The server's rules hold as they are: its token, its allowed fields, its row
filter. There is no fields for such a source; the server narrows. The source
is described once when the MCP server starts. A server that refuses the token
stops the start with a sentence; one that cannot be reached does not — its
source answers unavailable and is described when it is next opened.
Tools
| Tool | Called by | |
|---|---|---|
| opengrid_open | model | Opens a source as a grid in the chat. Answers with the session, the columns and the count — no rows. |
| opengrid_set_view | model | Sets the whole view (opengrid's get_view JSON). A view naming an unknown column is refused as a whole. Answers with the new count. |
| opengrid_describe | model | What the reader sees: view, query, count, size of the selection. No rows. |
| opengrid_selection | model | The selected rows as { column: value }, 100 by default, 500 at most; more are cut and said. |
| opengrid_query | grid only | The grid's own queries — its window, its counts. |
| opengrid_sync | grid only | The reader's changes in, the model's view out. |
The model's view reaches a grid already shown through the server: it keeps each session's view, and the grid asks for it when it becomes visible or focused and every few seconds while it is. It is applied in one step and said once, with the result: "52 matches · Filtered by the assistant". The focus stays where it was.
A selection is the grid's query plus the positions the reader selected
under it. Analyse the selection hands it to the model, which reads the rows
with opengrid_selection.
How it runs in a client
MCP Apps hosts give a view a strict Content Security Policy: its own inline code, nothing from elsewhere — and no WebAssembly. opengrid's elements are WebAssembly, so this package carries them translated to JavaScript (wasm2js) and inlined into one HTML file. The engine runs in the server, in Node.
Limits
The grid only — no pivot, no tree. No editing: a surface through which a model could change data needs its own approval path.
The rows the grid asks for come in windows of at most 500 (limit is cut to
that): a host that shows the grid's app-only query tool to the model still does
not hand it a source in one piece. The server keeps at most 100 sessions; past
that, the least recently used goes, and a call naming it answers
unknown_session — open the grid again.
Licence
MIT OR Apache-2.0, like opengrid.
