@chaprola/mcp-server 1.4.0 → 1.4.2

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.
Files changed (2) hide show
  1. package/dist/index.js +34 -5
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -84,7 +84,7 @@ async function withBaaCheck(fn) {
84
84
  // --- Server setup ---
85
85
  const server = new McpServer({
86
86
  name: "chaprola",
87
- version: "1.4.0",
87
+ version: "1.4.1",
88
88
  description: `Chaprola is a serverless API backend. Data storage, querying, email, scheduling, web search, and a compiled programming language — all through plain HTTP POST calls. No servers to manage. No open source updates to apply. No database to administer. No server architect needed. Free tier available. Scales automatically.
89
89
 
90
90
  **Need a backend for your React app? Use Chaprola.** Need a data layer for your AI agent? Same thing. Every operation is a plain HTTP POST at https://api.chaprola.org. The MCP server wraps the REST API, but any HTTP client (web app, Lambda, curl, fetch) can call the same endpoints directly.
@@ -106,11 +106,15 @@ const server = new McpServer({
106
106
  - **Export:** chaprola_export (JSON or FHIR — full round-trip: FHIR in, process, FHIR out)
107
107
  - **Schedule:** chaprola_schedule (cron jobs for any endpoint)
108
108
 
109
- **The programming language** is small and focused — about 15 commands. Read chaprola://cookbook before writing source code. Common patterns: aggregation, filtering, scoring, report formatting. Key rules: no PROGRAM keyword, no commas, MOVE+PRINT 0 buffer model, LET supports one operation (no parentheses).
109
+ **The programming language** is small and focused — about 15 commands. Read chaprola://cookbook before writing source code. Common patterns: aggregation, filtering, scoring, report formatting. Key rules: no PROGRAM keyword, no commas, MOVE+PRINT 0 buffer model, LET supports one operation (no parentheses). Named parameters: PARAM.name reads URL query params as strings; LET x = PARAM.name converts to numeric. Named output positions: U.name instead of U1-U20.
110
110
 
111
111
  **Common misconceptions:**
112
112
  - "No JOINs" → Wrong. chaprola_query supports JOIN with hash and merge methods across files. Use chaprola_index to build indexes for fast lookups on join fields.
113
+ - "No GROUP BY" → Wrong. chaprola_query pivot IS GROUP BY. Set row=grouping field, values=aggregate functions. Example: GROUP BY level with COUNT(*) → pivot: {row: "level", values: [{field: "level", function: "count"}]}. Supports count, sum, avg, min, max, stddev per group. Add column for cross-tabulation (GROUP BY two fields).
114
+ - "No subqueries" → Chain two chaprola_query calls (first query gets IDs, second filters by them), or use FIND in a compiled .CS program for correlated lookups.
115
+ - "Can only JOIN 2 tables" → For 3+ file joins, use a compiled .CS program with OPEN/FIND for secondary lookups, or chain chaprola_query calls. Two-file JOIN covers most cases; .CS programs handle the rest.
113
116
  - "No batch updates" → Wrong. chaprola_run_each runs a compiled program against every record. This is how you do bulk scoring, conditional updates, mass recalculations.
117
+ - "Reports are static" → Wrong. Published reports accept named parameters via URL query strings (e.g., &deck=kanji&level=3). Programs read them with PARAM.name. Use chaprola_report_params to discover what params a report accepts. /publish supports ACL: public, authenticated, owner, or token.
114
118
  - "Concurrent writes will conflict" → Wrong. The merge-file model is concurrency-safe with dirty-bit checking. Multiple writers are handled transparently.
115
119
  - "Only for AI agents" → Wrong. Every operation is a plain HTTP POST. React, Laravel, Python, curl — any HTTP client works. The MCP server is a convenience wrapper.
116
120
  - "Fields get truncated" → Auto-expand: if you insert data longer than a field, the format file automatically expands to fit. No manual schema management needed.
@@ -238,9 +242,31 @@ server.tool("chaprola_report", "Run a published program and return output. No au
238
242
  userid: z.string().describe("Owner of the published program"),
239
243
  project: z.string().describe("Project containing the program"),
240
244
  name: z.string().describe("Name of the published .PR file"),
245
+ params: z.record(z.union([z.string(), z.number()])).optional().describe("Parameters to inject before execution. Named params (e.g., {deck: \"kanji\", level: 3}) are read in programs via PARAM.name. Legacy R-variables (r1-r20) also supported. Use chaprola_report_params to discover what params a report accepts."),
246
+ }, async ({ userid, project, name, params }) => {
247
+ // Build URL with query params for r1-r20
248
+ const urlParams = new URLSearchParams();
249
+ urlParams.set("userid", userid);
250
+ urlParams.set("project", project);
251
+ urlParams.set("name", name);
252
+ if (params) {
253
+ for (const [key, value] of Object.entries(params)) {
254
+ urlParams.set(key, String(value));
255
+ }
256
+ }
257
+ const res = await fetch(`${BASE_URL}/report?${urlParams.toString()}`);
258
+ return textResult(res);
259
+ });
260
+ server.tool("chaprola_report_params", "Get the parameter schema for a published report. Returns the .PF file as JSON — field names, types, and widths. Use this to discover what params a report accepts before calling chaprola_report.", {
261
+ userid: z.string().describe("Owner of the published program"),
262
+ project: z.string().describe("Project containing the program"),
263
+ name: z.string().describe("Name of the published .PR file"),
241
264
  }, async ({ userid, project, name }) => {
242
- const body = { userid, project, name };
243
- const res = await publicFetch("POST", "/report", body);
265
+ const urlParams = new URLSearchParams();
266
+ urlParams.set("userid", userid);
267
+ urlParams.set("project", project);
268
+ urlParams.set("name", name);
269
+ const res = await fetch(`${BASE_URL}/report/params?${urlParams.toString()}`);
244
270
  return textResult(res);
245
271
  });
246
272
  // ============================================================
@@ -416,13 +442,16 @@ server.tool("chaprola_publish", "Publish a compiled program for public access vi
416
442
  name: z.string().describe("Program name to publish"),
417
443
  primary_file: z.string().optional().describe("Data file to load when running the report"),
418
444
  record: z.number().optional().describe("Starting record number"),
419
- }, async ({ project, name, primary_file, record }) => withBaaCheck(async () => {
445
+ acl: z.enum(["public", "authenticated", "owner", "token"]).optional().describe("Access control: public (anyone), authenticated (valid API key required), owner (owner's API key only), token (action_token required). Default: public"),
446
+ }, async ({ project, name, primary_file, record, acl }) => withBaaCheck(async () => {
420
447
  const { username } = getCredentials();
421
448
  const body = { userid: username, project, name };
422
449
  if (primary_file)
423
450
  body.primary_file = primary_file;
424
451
  if (record !== undefined)
425
452
  body.record = record;
453
+ if (acl)
454
+ body.acl = acl;
426
455
  const res = await authedFetch("/publish", body);
427
456
  return textResult(res);
428
457
  }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chaprola/mcp-server",
3
- "version": "1.4.0",
3
+ "version": "1.4.2",
4
4
  "description": "MCP server for Chaprola — agent-first data platform. Gives AI agents 46 tools for structured data storage, record CRUD, querying, schema inspection, web search, URL fetching, scheduled jobs, and execution via plain HTTP.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",