@chaprola/mcp-server 1.3.1 → 1.4.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
@@ -12,6 +12,8 @@ Gives AI agents 40 tools for structured data storage, querying, web search, URL
12
12
  claude mcp add chaprola-mcp -e CHAPROLA_USERNAME=yourusername -e CHAPROLA_API_KEY=chp_yourkey -- npx @chaprola/mcp-server
13
13
  ```
14
14
 
15
+ > **Note:** After installing, restart Claude Code to load the MCP server. The server description and tools will then be available to Claude.
16
+
15
17
  ### Claude Desktop
16
18
 
17
19
  Add to `claude_desktop_config.json`:
package/dist/index.js CHANGED
@@ -84,7 +84,40 @@ async function withBaaCheck(fn) {
84
84
  // --- Server setup ---
85
85
  const server = new McpServer({
86
86
  name: "chaprola",
87
- version: "1.0.0",
87
+ version: "1.4.0",
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
+
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.
91
+
92
+ **Think of it like this:** Files are tables. Fields are columns. Records are rows. Programs (.PR) are stored procedures. /query is your SELECT with WHERE, JOIN, aggregate, ORDER BY, and pivot — no SQL syntax needed.
93
+
94
+ **Core workflow:** Import JSON → Query or process → Export results (JSON or FHIR)
95
+
96
+ **What you can do:**
97
+ - **Import data:** chaprola_import (JSON or FHIR bundles), chaprola_import_download (CSV/Excel/Parquet from URL)
98
+ - **Query data:** chaprola_query (filter, aggregate, join, pivot — like SELECT without SQL)
99
+ - **Record CRUD:** chaprola_insert_record, chaprola_update_record, chaprola_delete_record
100
+ - **Batch operations:** chaprola_run_each — run a compiled program against every record in a file (like a stored procedure that executes per-row). Use this for scoring, bulk updates, conditional logic across records.
101
+ - **Compile programs:** chaprola_compile (source code → bytecode). Programs are stored procedures — compile once, run on demand.
102
+ - **Run programs:** chaprola_run (single execution), chaprola_run_each (per-record batch), chaprola_report (published reports)
103
+ - **Email:** chaprola_email_send, chaprola_email_inbox, chaprola_email_read
104
+ - **Web:** chaprola_search (Brave API), chaprola_fetch (URL → markdown)
105
+ - **Schema:** chaprola_format (inspect fields), chaprola_alter (add/widen/rename/drop fields)
106
+ - **Export:** chaprola_export (JSON or FHIR — full round-trip: FHIR in, process, FHIR out)
107
+ - **Schedule:** chaprola_schedule (cron jobs for any endpoint)
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).
110
+
111
+ **Common misconceptions:**
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 batch updates" → Wrong. chaprola_run_each runs a compiled program against every record. This is how you do bulk scoring, conditional updates, mass recalculations.
114
+ - "Concurrent writes will conflict" → Wrong. The merge-file model is concurrency-safe with dirty-bit checking. Multiple writers are handled transparently.
115
+ - "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
+ - "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.
117
+
118
+ **For specialized processing** (NLP, ML inference, image recognition): use external services and import results into Chaprola. Chaprola is the data and compute layer, not the everything layer.
119
+
120
+ **Start here:** Import data with chaprola_import, then query with chaprola_query. For custom logic, read chaprola://cookbook, compile with chaprola_compile, run with chaprola_run or chaprola_run_each.`,
88
121
  });
89
122
  // --- MCP Resources (language reference for agents) ---
90
123
  import { readFileSync } from "fs";
@@ -357,6 +390,26 @@ server.tool("chaprola_run_status", "Check status of an async job. Returns full o
357
390
  const res = await authedFetch("/run/status", { userid: username, project, job_id });
358
391
  return textResult(res);
359
392
  }));
393
+ server.tool("chaprola_run_each", "Run a compiled .PR program against every record in a data file. Like CHAPRPG from the original SCIOS. Use this for scoring, bulk updates, conditional logic across records.", {
394
+ project: z.string().describe("Project name"),
395
+ file: z.string().describe("Data file to iterate (.DA)"),
396
+ program: z.string().describe("Compiled program name (.PR) in the same project"),
397
+ where: z.array(z.object({
398
+ field: z.string().describe("Field name to filter on"),
399
+ op: z.string().describe("Operator: eq, ne, gt, ge, lt, le, between, contains, starts_with"),
400
+ value: z.union([z.string(), z.number(), z.array(z.number())]).describe("Value to compare against"),
401
+ })).optional().describe("Optional filter — only run against matching records"),
402
+ where_logic: z.enum(["and", "or"]).optional().describe("How to combine multiple where conditions (default: and)"),
403
+ }, async ({ project, file, program, where, where_logic }) => withBaaCheck(async () => {
404
+ const { username } = getCredentials();
405
+ const body = { userid: username, project, file, program };
406
+ if (where)
407
+ body.where = where;
408
+ if (where_logic)
409
+ body.where_logic = where_logic;
410
+ const res = await authedFetch("/run-each", body);
411
+ return textResult(res);
412
+ }));
360
413
  // --- Publish ---
361
414
  server.tool("chaprola_publish", "Publish a compiled program for public access via /report", {
362
415
  project: z.string().describe("Project name"),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chaprola/mcp-server",
3
- "version": "1.3.1",
3
+ "version": "1.4.0",
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",
@@ -31,7 +31,7 @@
31
31
  "license": "MIT",
32
32
  "repository": {
33
33
  "type": "git",
34
- "url": "https://github.com/cletcher/chaprola"
34
+ "url": "https://github.com/cletcher/chaprola-mcp"
35
35
  },
36
36
  "homepage": "https://chaprola.org",
37
37
  "mcpName": "io.github.cletcher/chaprola",
@@ -318,31 +318,79 @@ Higher weight = more important. HULDRA minimizes `Q = sum(weight × (value - goa
318
318
  - **`SSR` (objective value)** — Sum of squared residuals. Divide by record count for mean squared error. Take the square root for RMSE in the same units as your data.
319
319
  - **`dq_dx` on elements** — Gradient. Values near zero mean the parameter is well-optimized. Large values may indicate the bounds are too tight.
320
320
 
321
- ### Nonlinear Models
321
+ ### Model Catalog — Which Formula to Try
322
+
323
+ HULDRA fits any model expressible with Chaprola's math: `+`, `-`, `*`, `/`, `EXP`, `LOG`, `SQRT`, `ABS`, `POW`, and `IF` branching. Use this catalog to pick the right model for your data shape.
324
+
325
+ | Model | Formula | When to use | Chaprola math |
326
+ |-------|---------|-------------|---------------|
327
+ | **Linear** | `y = R1*x + R2` | Proportional relationships, constant rate | `*`, `+` |
328
+ | **Multi-linear** | `y = R1*x1 + R2*x2 + R3` | Multiple independent factors | `*`, `+` |
329
+ | **Quadratic** | `y = R1*x^2 + R2*x + R3` | Accelerating/decelerating curves, area scaling | `*`, `+`, `POW` |
330
+ | **Exponential growth** | `y = R1 * EXP(R2*x)` | Compound growth, population, interest | `EXP`, `*` |
331
+ | **Exponential decay** | `y = R1 * EXP(-R2*x) + R3` | Drug clearance, radioactive decay, cooling | `EXP`, `*`, `-` |
332
+ | **Power law** | `y = R1 * POW(x, R2)` | Scaling laws (Zipf, Kleiber), fractal relationships | `POW`, `*` |
333
+ | **Logarithmic** | `y = R1 * LOG(x) + R2` | Diminishing returns, perception (Weber-Fechner) | `LOG`, `*`, `+` |
334
+ | **Gaussian** | `y = R1 * EXP(-(x-R2)^2/(2*R3^2))` | Bell curves, distributions, demand peaks | `EXP`, `*`, `/` |
335
+ | **Logistic (S-curve)** | `y = R1 / (1 + EXP(-R2*(x-R3)))` | Adoption curves, saturation, carrying capacity | `EXP`, `/`, `+` |
336
+ | **Inverse** | `y = R1/x + R2` | Boyle's law, unit cost vs volume | `/`, `+` |
337
+ | **Square root** | `y = R1 * SQRT(x) + R2` | Flow rates (Bernoulli), risk vs portfolio size | `SQRT`, `*`, `+` |
338
+
339
+ **How to choose:** Look at your data's shape.
340
+ - Straight line → linear or multi-linear
341
+ - Curves upward faster and faster → exponential growth or quadratic
342
+ - Curves upward then flattens → logarithmic, square root, or logistic
343
+ - Drops fast then levels off → exponential decay or inverse
344
+ - Has a peak/hump → Gaussian
345
+ - Straight on log-log axes → power law
346
+
347
+ ### Nonlinear VALUE Program Patterns
348
+
349
+ **Exponential decay:** `y = R1 * exp(-R2 * x) + R3`
350
+ ```chaprola
351
+ LET ARG = R2 * X
352
+ LET ARG = ARG * -1
353
+ LET PRED = EXP ARG
354
+ LET PRED = PRED * R1
355
+ LET PRED = PRED + R3
356
+ ```
322
357
 
323
- HULDRA handles any model you can express in Chaprola, not just linear. Use EXP, LOG, SQRT, POW for curves:
358
+ **Power law:** `y = R1 * x^R2`
359
+ ```chaprola
360
+ LET PRED = POW X R2
361
+ LET PRED = PRED * R1
362
+ ```
324
363
 
364
+ **Gaussian:** `y = R1 * exp(-(x - R2)^2 / (2 * R3^2))`
325
365
  ```chaprola
326
- // Exponential decay: value = R1 * exp(-R2 * time) + R3
327
- DEFINE VARIABLE T R41
328
- DEFINE VARIABLE OBS R42
329
- DEFINE VARIABLE PRED R43
330
- DEFINE VARIABLE ARG R44
331
- DEFINE VARIABLE SSR R45
332
-
333
- GET T FROM P.time
334
- GET OBS FROM P.observed
335
- LET ARG = R2 * T
366
+ LET DIFF = X - R2
367
+ LET DIFF = DIFF * DIFF
368
+ LET DENOM = R3 * R3
369
+ LET DENOM = DENOM * 2
370
+ LET ARG = DIFF / DENOM
336
371
  LET ARG = ARG * -1
337
372
  LET PRED = EXP ARG
338
373
  LET PRED = PRED * R1
339
- LET PRED = PRED + R3
340
- LET R46 = PRED - OBS // residual
341
- LET R46 = R46 * R46
342
- LET SSR = SSR + R46
343
374
  ```
344
375
 
345
- This fits exponential decay, growth curves, dose-response functions, depreciation models any formula where you need to find the best-fitting coefficients.
376
+ **Logistic S-curve:** `y = R1 / (1 + exp(-R2 * (x - R3)))`
377
+ ```chaprola
378
+ LET ARG = X - R3
379
+ LET ARG = ARG * R2
380
+ LET ARG = ARG * -1
381
+ LET DENOM = EXP ARG
382
+ LET DENOM = DENOM + 1
383
+ LET PRED = R1 / DENOM
384
+ ```
385
+
386
+ **Logarithmic:** `y = R1 * ln(x) + R2`
387
+ ```chaprola
388
+ LET PRED = LOG X
389
+ LET PRED = PRED * R1
390
+ LET PRED = PRED + R2
391
+ ```
392
+
393
+ All patterns follow the same loop structure: SEEK records, GET fields, compute PRED, accumulate `(PRED - OBS)^2` in SSR, store SSR in R21 at the end.
346
394
 
347
395
  ### Agent Workflow Summary
348
396