inistate-mcp 1.2.0 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -80,7 +80,7 @@ Then point your MCP client at `node /absolute/path/to/inistate-mcp/build/index.j
80
80
 
81
81
  ## Tools
82
82
 
83
- Tools marked **(configure)** are only exposed in configure mode — see [Modes](#modes). Tools the active backend cannot serve (e.g. `scaffold_module` on the hosted Platform) stay registered but return a structured capability message instead of failing silently.
83
+ Tools marked **(configure)** are only exposed in configure mode — see [Modes](#modes). Tools that depend on a local-runtime capability, such as `scaffold_module`, are not exposed by the hosted Platform.
84
84
 
85
85
  | Tool | Description |
86
86
  |------|-------------|
@@ -90,6 +90,7 @@ Tools marked **(configure)** are only exposed in configure mode — see [Modes](
90
90
  | `get_module_schema` | Get the canvas schema (basic or extended tier) — available in every mode |
91
91
  | `get_module_canvas` | Get full module definition with stable IDs (round-trippable) **(configure)** |
92
92
  | `list_entries` | Query entries with filters, sorting, and pagination |
93
+ | `aggregate_entries` | Count, sum, average, min or max over matching entries, optionally grouped — the platform does the arithmetic |
93
94
  | `get_entry` | Read a single entry by ID |
94
95
  | `get_form` | Get form fields and defaults for an activity |
95
96
  | `submit_activity` | Create, edit, delete, or run custom activities |
@@ -103,7 +104,7 @@ Tools marked **(configure)** are only exposed in configure mode — see [Modes](
103
104
  | `validate_design` | Validate a module schema before creating or updating **(configure)** |
104
105
  | `create_module` | Create a new module with schema **(configure)** |
105
106
  | `update_module` | Update an existing module's schema **(configure)** |
106
- | `scaffold_module` | Draft a module schema from existing data (SQLite, Notion, or Airtable table) **(configure)** — served by the local runtime (inistate-core); on the hosted Platform backend it returns a capability message pointing to `design_workflow` |
107
+ | `scaffold_module` | Draft a module schema from existing SQLite, Notion, or Airtable data **(configure)** — local runtime (inistate-core) only; it never creates a module |
107
108
  | `switch_mode` | Switch the active mode (runtime / configure / frontend) |
108
109
 
109
110
  ## Resources
@@ -60,6 +60,20 @@ export interface ListEntriesParams {
60
60
  pageSize?: number;
61
61
  fields?: string[];
62
62
  }
63
+ /** aggregate_entries: one metric over the entries a listing and filters match, optionally grouped. */
64
+ export interface AggregateEntriesParams {
65
+ module: string;
66
+ listing?: string;
67
+ state?: string;
68
+ search?: string;
69
+ filters?: Record<string, unknown>;
70
+ op: "count" | "sum" | "ave" | "min" | "max";
71
+ field?: string;
72
+ groupBy?: string;
73
+ interval?: "day" | "week" | "month";
74
+ breakdown?: string;
75
+ top?: number;
76
+ }
63
77
  export interface GetEntryParams {
64
78
  module: string;
65
79
  entryId: string | number;
@@ -132,6 +146,7 @@ export interface Backend {
132
146
  createModule(payload: Record<string, unknown>): Promise<unknown>;
133
147
  updateModule(payload: Record<string, unknown>): Promise<unknown>;
134
148
  listEntries(params: ListEntriesParams): Promise<unknown>;
149
+ aggregateEntries(params: AggregateEntriesParams): Promise<unknown>;
135
150
  getEntry(params: GetEntryParams): Promise<unknown>;
136
151
  getForm(params: GetFormParams): Promise<unknown>;
137
152
  submitActivity(payload: Record<string, unknown>): Promise<unknown>;
@@ -164,6 +179,7 @@ export declare class CloudBackend implements Backend {
164
179
  createModule(payload: Record<string, unknown>): Promise<unknown>;
165
180
  updateModule(payload: Record<string, unknown>): Promise<unknown>;
166
181
  listEntries(p: ListEntriesParams): Promise<unknown>;
182
+ aggregateEntries(p: AggregateEntriesParams): Promise<unknown>;
167
183
  getEntry(p: GetEntryParams): Promise<unknown>;
168
184
  getForm(p: GetFormParams): Promise<unknown>;
169
185
  submitActivity(payload: Record<string, unknown>): Promise<unknown>;
package/build/backend.js CHANGED
@@ -85,6 +85,28 @@ export class CloudBackend {
85
85
  body.fields = p.fields;
86
86
  return api.post("/api/mcp/list", body);
87
87
  }
88
+ aggregateEntries(p) {
89
+ const body = { module: p.module, op: p.op };
90
+ if (p.listing)
91
+ body.listing = p.listing;
92
+ if (p.state)
93
+ body.state = p.state;
94
+ if (p.search)
95
+ body.search = p.search;
96
+ if (p.filters)
97
+ body.filters = p.filters;
98
+ if (p.field)
99
+ body.field = p.field;
100
+ if (p.groupBy)
101
+ body.groupBy = p.groupBy;
102
+ if (p.interval)
103
+ body.interval = p.interval;
104
+ if (p.breakdown)
105
+ body.breakdown = p.breakdown;
106
+ if (p.top !== undefined)
107
+ body.top = p.top;
108
+ return api.post("/api/mcp/aggregate", body);
109
+ }
88
110
  getEntry(p) {
89
111
  return api.post("/api/mcp/entry", { module: p.module, entryId: p.entryId });
90
112
  }
package/build/server.js CHANGED
@@ -17,7 +17,7 @@ export function createServer(options = {}) {
17
17
  // agents don't spend turns rediscovering them.
18
18
  const instructions = `Inistate MCP — canonical flows (minimize tool calls):
19
19
  - Orient: list_workspaces (auto-selects if exactly one match) -> set_workspace. Both return the workspace's module list; list_modules is only for refreshing it.
20
- - Read: list_entries with the fields parameter (keeps payloads small) and filters; get_entry for one record.
20
+ - Read: list_entries with the fields parameter (keeps payloads small) and filters; get_entry for one record; aggregate_entries for counts and totals (never add up list_entries pages).
21
21
  - Write: get_form once per (module, activity), then submit_activity; reuse the form schema for more entries of the same kind. Use submit_activities for bulk writes (max 100 per call).
22
22
  - Design: design_workflow -> create_module (validates internally; validate_design is an optional dry-run). Modify: get_module_canvas -> edit -> update_module (full-canvas payloads validate internally).
23
23
  - Files: request_upload_url -> PUT bytes -> confirm_upload (default); upload_file only if that flow fails.
package/build/tools.js CHANGED
@@ -316,6 +316,19 @@ function normalizeModuleSections(body) {
316
316
  resolveDesignRefs(body);
317
317
  }
318
318
  // ---------- Tool registration ----------
319
+ // The query half of list_entries — which entries it reads — shared verbatim by aggregate_entries, so the
320
+ // two tools take one set of query parameters and the platform runs one query for both (FETIAS
321
+ // McpReadQuery). list_entries adds its page (sort, paging, fields); aggregate_entries its metric.
322
+ const listQueryParams = {
323
+ module: z.string().describe("Module name from list_modules"),
324
+ listing: z
325
+ .string()
326
+ .optional()
327
+ .describe("Listing (saved view) name to query, case-insensitive; 'archive' targets archived entries. Defaults to the unfiltered 'Everything' view, which is admin-only on modules with listings — non-admins must name an accessible listing (an access-denied response lists them)."),
328
+ state: z.string().optional(),
329
+ search: z.string().optional().describe("Free-text search across document ID, state, and text-like fields; supports * and ? wildcards"),
330
+ filters: z.record(z.unknown()).optional(),
331
+ };
319
332
  export function registerTools(server, backend) {
320
333
  const configureTools = [];
321
334
  // Capability gating (MCP spec §1.6). Read once. Platform-only tools below
@@ -647,7 +660,7 @@ Workflow sequences after workspace is set:
647
660
  - Design: design_workflow → create_module (validates internally)
648
661
  - Execute: list_entries → get_form → submit_activity
649
662
  - Modify: get_module_canvas → validate_design → update_module
650
- - Query: list_entries → get_entry / get_entry_history`),
663
+ - Query: list_entries → get_entry / get_entry_history; aggregate_entries for totals`),
651
664
  inputSchema: {
652
665
  workspaceId: z
653
666
  .union([z.string(), z.number()])
@@ -778,14 +791,7 @@ Load resource inistate://schema before modifying to know valid field types, colo
778
791
  title: "List Entries",
779
792
  description: "Query entries with filters, sorting, pagination. Filter keys are field display names; values are equality (simple) or operator objects (contains/startsWith/endsWith/min/max/above/below/between/after/before/empty/exists/yes/no/is/not/excludes). Use {or:[…]} for OR; multiple keys are AND-ed. Use 'me' for User-field self-match. See FilterOperators in inistate://schema/runtime for the full set.\n\nAccess: non-admin users cannot query the unfiltered default 'Everything' view on modules that have listings — pass `listing` with one of their accessible listings (an access-denied response names them).\n\nToken control: use `fields` to restrict the returned `data` to just the columns you need. For modules with many fields this can shrink the response by an order of magnitude. Every item carries entryId, documentId and state whatever `fields` holds; the other system fields (date, createdBy, createdDate, updatedBy, updatedDate, assignees, due) come with the full row, but when `fields` is given only if it names them.\n\nCheck each item's `state` before totalling, counting or ranking entries: a Cancelled or Draft entry usually must not count. get_module_schema's stateDetails says what each state means.",
780
793
  inputSchema: {
781
- module: z.string().describe("Module name from list_modules"),
782
- listing: z
783
- .string()
784
- .optional()
785
- .describe("Listing (saved view) name to query, case-insensitive; 'archive' targets archived entries. Defaults to the unfiltered 'Everything' view, which is admin-only on modules with listings — non-admins must name an accessible listing (an access-denied response lists them)."),
786
- state: z.string().optional(),
787
- search: z.string().optional().describe("Free-text search across document ID, state, and text-like fields; supports * and ? wildcards"),
788
- filters: z.record(z.unknown()).optional(),
794
+ ...listQueryParams,
789
795
  sortBy: z.string().optional(),
790
796
  sortDirection: z.enum(["asc", "desc"]).default("asc").optional(),
791
797
  currentPage: z.number().int().default(0).optional(),
@@ -867,6 +873,60 @@ Load resource inistate://schema before modifying to know valid field types, colo
867
873
  }
868
874
  });
869
875
  // ═══════════════════════════════════════════
876
+ // 6b. aggregate_entries
877
+ // ═══════════════════════════════════════════
878
+ server.registerTool("aggregate_entries", {
879
+ title: "Aggregate Entries",
880
+ description: "Totals without paging rows: count, sum, average (ave), min or max of a field over the entries list_entries would list, optionally grouped by a field (a date by day, week or month) and broken down by a second field. Use it for 'how many / how much / total / average / top N / per month' questions instead of adding up list_entries pages.\n\nThe query parameters (module, listing, state, search, filters) ARE list_entries' — same names, same meaning, same access — so pass exactly what you would pass list_entries to read those entries.\n\nThe answer: `groups` [{key, count, value}] (with a breakdown, `values` [{key, value}] per group), `total` {count, value} over EVERY matching entry, `complete` (false: the module's engine read only its first 501 entries, so the figures are partial — narrow the filters, or say they are partial) and `groupsTruncated` (only the largest `top` groups, or the latest periods, are listed; `total` is still whole).\n\nFilter or group by state when Cancelled or Draft entries must not count. What a figure means — signs, which entries belong in it — comes from the module's description and get_module_schema.",
881
+ inputSchema: {
882
+ ...listQueryParams,
883
+ op: z.enum(["count", "sum", "ave", "min", "max"]).describe("The metric"),
884
+ field: z.string().optional().describe("Field the metric reads (a number for sum/ave; a number or date for min/max). Not needed for count."),
885
+ groupBy: z.string().optional().describe("Field to group by: a display name, or state, date, createdBy, assignees …"),
886
+ interval: z.enum(["day", "week", "month"]).optional().describe("Only when groupBy is a date field. Default day."),
887
+ breakdown: z.string().optional().describe("Second field, splitting each group"),
888
+ top: z.number().int().min(1).max(500).optional().describe("Most groups returned, 1–500. Default 100."),
889
+ workspaceId: wsParam,
890
+ },
891
+ annotations: { readOnlyHint: true, destructiveHint: false, openWorldHint: false, idempotentHint: true },
892
+ }, async ({ module: moduleName, listing, state, search, filters, op, field, groupBy, interval, breakdown, top, workspaceId }) => {
893
+ try {
894
+ applyWorkspace(workspaceId);
895
+ const data = await backend.aggregateEntries({
896
+ module: moduleName,
897
+ listing,
898
+ state,
899
+ search,
900
+ filters,
901
+ op,
902
+ field,
903
+ groupBy,
904
+ interval,
905
+ breakdown,
906
+ top,
907
+ });
908
+ return ok(data);
909
+ }
910
+ catch (e) {
911
+ // A platform build without the route answers with no `error` of its own: 405 where the
912
+ // GET-only api/mcp/{moduleName} route catches the path (what 132 and production answered
913
+ // before FETIAS r33760), or a bare 404. A missing module says "Not found" and stays as is.
914
+ const structured = e && typeof e === "object" && "structured" in e
915
+ ? e.structured
916
+ : null;
917
+ if (structured && (structured.error === "HTTP 405" || structured.error === "HTTP 404")) {
918
+ return err({
919
+ structured: {
920
+ error: "not_supported",
921
+ message: "This Inistate server does not offer aggregate_entries yet.",
922
+ agent_action: "Use list_entries instead, and tell the user any total you give was added up from the rows you read.",
923
+ },
924
+ });
925
+ }
926
+ return err(e);
927
+ }
928
+ });
929
+ // ═══════════════════════════════════════════
870
930
  // 7. get_entry
871
931
  // ═══════════════════════════════════════════
872
932
  server.registerTool("get_entry", {
@@ -1853,12 +1913,12 @@ Load resources inistate://schema and inistate://design-guide before designing fo
1853
1913
  // ═══════════════════════════════════════════
1854
1914
  // The inverse on-ramp: the user already has data in a Notion database, an
1855
1915
  // Airtable table, or a local SQLite table. Capability-gated — only a backend
1856
- // that declares `scaffold` (the local runtime) serves it; the hosted Platform
1857
- // returns a capability message. The introspection itself lives behind the
1858
- // Backend so the closed-source engine owns it.
1859
- // Param descriptions follow the same gating as the tool description: a
1860
- // backend that cannot serve the tool registers the same shape (so the
1861
- // structural contract is stable) without the operating manual attached.
1916
+ // that declares `scaffold` (the local runtime) serves it. It is not
1917
+ // advertised by the hosted Platform: an unavailable tool is not a useful
1918
+ // model-callable operation. The introspection itself lives behind the Backend
1919
+ // so the closed-source engine owns it.
1920
+ // Only a capable local runtime registers the tool, so its detailed input
1921
+ // descriptions are never exposed as an unusable hosted operation.
1862
1922
  const scaffoldInput = caps.scaffold
1863
1923
  ? {
1864
1924
  source: z
@@ -1880,21 +1940,22 @@ Load resources inistate://schema and inistate://design-guide before designing fo
1880
1940
  name: z.string().optional(),
1881
1941
  state: z.string().optional(),
1882
1942
  };
1883
- configureTools.push(server.registerTool("scaffold_module", {
1884
- title: "Scaffold Module from Existing Data",
1885
- description: gatedDesc(caps.scaffold, "Design a module schema together with the user from data they ALREADY have — a Notion database, an Airtable table, or a local SQLite table. This is the inverse on-ramp: instead of designing from scratch, read the existing shape and refine it with the user. One container (a SQLite database, an Airtable base, a Notion workspace) can yield several modules — discover the tables, then model the chosen ones.\n\nFlow (use it conversationally):\n1. DISCOVER — call with just `source` pointed at the container: a SQLite database path, an `airtable://<baseId>` (no table), or a bare `notion://`. Returns { discovery: true, tables: [{ name, id?, columns, rows?, hasState, scaffold_source }] }. Show these to the user and ask which one(s) to model; each becomes its own module.\n2. DRAFT — call again with a chosen table's `scaffold_source` as `source` (or a SQLite `table`). Returns { schema, validation, suggestions } — columns become typed fields, a detected status/state/stage/phase column becomes states.\n3. REFINE together — confirm the inferred field types with the user, then define activities + flows (the governed transitions; design_workflow can scaffold a pattern).\n4. CREATE — validate_design → create_module, then point the runtime at the same data.\n\nTargets: notion://<databaseId> or bare notion:// (needs INISTATE_NOTION_TOKEN), airtable://<baseId>/<tableIdOrName> or airtable://<baseId> (needs INISTATE_AIRTABLE_TOKEN; listing a base's tables needs schema.bases:read), or a local SQLite path. Credentials are read from the environment — never pass tokens as arguments.", "Local-runtime only; use design_workflow to draft a module here."),
1886
- inputSchema: scaffoldInput,
1887
- annotations: { readOnlyHint: true, destructiveHint: false, openWorldHint: false, idempotentHint: true },
1888
- }, async ({ source, table, name, state }) => {
1889
- if (!caps.scaffold)
1890
- return ok(capabilityMessage("scaffold", backend.kind));
1891
- try {
1892
- const data = await backend.scaffoldModule({ source, table, name, state });
1893
- return ok(data);
1894
- }
1895
- catch (e) {
1896
- return err(e);
1897
- }
1898
- }));
1943
+ if (caps.scaffold)
1944
+ configureTools.push(server.registerTool("scaffold_module", {
1945
+ title: "Scaffold Module from Existing Data",
1946
+ description: gatedDesc(caps.scaffold, "Design a module schema together with the user from data they ALREADY have — a Notion database, an Airtable table, or a local SQLite table. This is the inverse on-ramp: instead of designing from scratch, read the existing shape and refine it with the user. One container (a SQLite database, an Airtable base, a Notion workspace) can yield several modules — discover the tables, then model the chosen ones.\n\nFlow (use it conversationally):\n1. DISCOVER — call with just `source` pointed at the container: a SQLite database path, an `airtable://<baseId>` (no table), or a bare `notion://`. Returns { discovery: true, tables: [{ name, id?, columns, rows?, hasState, scaffold_source }] }. Show these to the user and ask which one(s) to model; each becomes its own module.\n2. DRAFT — call again with a chosen table's `scaffold_source` as `source` (or a SQLite `table`). Returns { schema, validation, suggestions } — columns become typed fields, a detected status/state/stage/phase column becomes states.\n3. REFINE together — confirm the inferred field types with the user, then define activities + flows (the governed transitions; design_workflow can scaffold a pattern).\n4. CREATE — validate_design → create_module, then point the runtime at the same data.\n\nTargets: notion://<databaseId> or bare notion:// (needs INISTATE_NOTION_TOKEN), airtable://<baseId>/<tableIdOrName> or airtable://<baseId> (needs INISTATE_AIRTABLE_TOKEN; listing a base's tables needs schema.bases:read), or a local SQLite path. Credentials are read from the environment — never pass tokens as arguments.", "Local-runtime only. This inspects an existing data source and returns a module-schema draft; it never creates a module. Use design_workflow to draft a module here."),
1947
+ inputSchema: scaffoldInput,
1948
+ annotations: { readOnlyHint: true, destructiveHint: false, openWorldHint: false, idempotentHint: true },
1949
+ }, async ({ source, table, name, state }) => {
1950
+ if (!caps.scaffold)
1951
+ return ok(capabilityMessage("scaffold", backend.kind));
1952
+ try {
1953
+ const data = await backend.scaffoldModule({ source, table, name, state });
1954
+ return ok(data);
1955
+ }
1956
+ catch (e) {
1957
+ return err(e);
1958
+ }
1959
+ }));
1899
1960
  return { configureTools };
1900
1961
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "inistate-mcp",
3
3
  "mcpName": "io.github.Inistate/inistate-mcp",
4
- "version": "1.2.0",
4
+ "version": "1.3.0",
5
5
  "description": "MCP server for the Inistate platform — no-code apps creation powered by AI",
6
6
  "type": "module",
7
7
  "author": "Inistate",
package/server.json CHANGED
@@ -8,13 +8,13 @@
8
8
  "url": "https://github.com/inistate/inistate-mcp",
9
9
  "source": "github"
10
10
  },
11
- "version": "1.2.0",
11
+ "version": "1.3.0",
12
12
  "packages": [
13
13
  {
14
14
  "registryType": "npm",
15
15
  "registryBaseUrl": "https://registry.npmjs.org",
16
16
  "identifier": "inistate-mcp",
17
- "version": "1.2.0",
17
+ "version": "1.3.0",
18
18
  "transport": {
19
19
  "type": "stdio"
20
20
  },