Skip to main content

Crate tableski

Crate tableski 

Source
Expand description

Stateless Streamable HTTP (JSON + SSE) MCP server over the tableski engine.

Everything about tables and tools lives in tableski_core and is re-exported here, so tableski::AppState and tableski_core::AppState are the same type. This crate adds the HTTP wiring (app_router) and the CLI (src/main.rs). No Mcp-Session-Id is issued or required — every POST is independent.

Modules§

excel
Excel ingestion: calamine → Arrow RecordBatch → registered DataFusion tables.
export
Result export: run a query and write the result set as CSV or XLSX — only into the operator-configured export directory (no caller-controlled paths outside it).
guard
Untrusted-SQL guard: decide on the parsed statement whether a client that we do not trust may run it. Read-only queries over registered tables pass; everything else is rejected before DataFusion sees it.
limits
Per-query limits: a memory pool cap on the session, a wall-clock timeout, and caps on the rows and bytes a result may carry back. Unlimited by default for embedders; the CLI applies QueryLimits::safe unless told otherwise.
quota
Quota primitives: what a tenant may use, and an in-memory meter that enforces it.
register
Unified file registration: one model for every supported format.
source
Where tables come from: the TableSource seam between a supplier of tables and the DataFusion SessionContext that serves them.

Structs§

AppState
DataFusion-backed MCP handler: registered tables plus the session context to query them.
Collected
What collect_limited brought back.
FileSource
Files on disk: the CLI’s --file (extension picks the reader, table = file stem), --csv with an explicit table name, and --xlsx (one table per sheet).
IngestOptions
Ingestion options for register_workbook.
QueryLimits
Bounds on what one query may consume and return. None means unlimited.
Quota
The allowance of one tenant. None = unlimited.
SheetInfo
One registered sheet: table name, source sheet name, and data dimensions.
TableEntry
One registered table and where it came from (CSV path or workbook sheet).
Usage
Point-in-time usage, for display and for the hosted server’s metering.
UsageMeter
Thread-safe in-memory counters for one tenant, checked against a Quota.

Enums§

HeaderMode
How the first row of each sheet is interpreted.
QuotaExceeded
Which allowance ran out. The Display text is what the client sees.
Rejection
Why a statement was refused in untrusted mode. The Display text is what the client sees.
SqlTrust
How much the server trusts the client sending SQL.

Constants§

ACCEPT_STREAMABLE
Accept value clients should send (re-exported from the shared transport). Accept value a client should send for Streamable HTTP (JSON or SSE responses).
PROTOCOL_VERSION
MCP protocol version reported on initialize.

Traits§

TableSource
A supplier of tables. Implementations register whatever they know about into the session and describe it; see the module docs for stateful sources.

Functions§

app_router
Build the stateless Streamable HTTP router over the registered tables.
call_tool
Run one tool by name with its JSON arguments and return the result text (unframed).
check_plan
Second decision, on the physical plan: refuse cartesian products. A cross join or a nested-loop join over registered tables is the one query shape a wall-clock limit cannot stop once it runs (DataFusion yields too rarely inside it), so it never starts.
check_untrusted
Parse sql and decide whether an untrusted client may run it against registered tables.
collect_limited
Execute df as a stream, stop at the row/byte caps, and give up at the timeout.
query_runtime
The process-wide tokio runtime queries execute on when a timeout is set: one thread per core, separate from whatever runtime serves clients, so a busy query cannot starve the server. Built on first use.
register_path
Register path by extension. Returns one TableEntry per registered table (workbooks may produce several — one per sheet).
register_sources
Build a registry: register sources in order into ctx and collect their entries.
register_workbook
Open path (xlsx / xls / ods), convert every non-empty sheet to an Arrow RecordBatch, and register each as a DataFusion table. Returns the registered sheets.
run_bounded
Run work under timeout on the query_runtime: the caller’s runtime (HTTP, timers) stays responsive however busy the work is, and on expiry the task is aborted (it stops at its next yield point). Without a timeout, work runs inline.
tools_list
The MCP tools/list result: the five tools with their JSON input schemas.