@mapled/mcp 0.11.0 → 0.12.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/dist/tools.d.ts CHANGED
@@ -5,7 +5,7 @@ export type ApiClient = {
5
5
  request: (method: "GET" | "POST" | "PATCH", path: string, body?: unknown) => Promise<unknown>;
6
6
  };
7
7
  export declare function createApiClient(baseUrl: string, token: string): ApiClient;
8
- export declare const FIELD_TYPES: readonly ["short_text", "long_text", "rich_text", "slug", "image", "number", "boolean", "date", "relation", "enum", "url", "email", "group", "datetime", "file", "color", "json", "location"];
8
+ export declare const FIELD_TYPES: readonly ["short_text", "long_text", "rich_text", "slug", "image", "number", "boolean", "date", "relation", "enum", "url", "email", "group", "datetime", "file", "color", "json", "location", "computed"];
9
9
  export type ToolDef = {
10
10
  name: string;
11
11
  description: string;
package/dist/tools.js CHANGED
@@ -37,12 +37,19 @@ export const FIELD_TYPES = [
37
37
  "color",
38
38
  "json",
39
39
  "location",
40
+ "computed",
40
41
  ];
42
+ /** What add_field and propose_setup_plan say about formulas (§14.9). */
43
+ const COMPUTED_HELP = "For type computed only: { expression } — a formula over the record's other fields that Mapled evaluates when a record is read or published (read-only for editors and agents; the site reads the value like any field of the result type, filters and sorts included; writes ignore it). " +
44
+ "Field keys as written (price, unit-cost — put spaces around a minus to subtract: price - cost); one link deep through relations: author.name, and lists over many-relations for aggregates: sum(items.price), count(tags), join(tags.name, \", \"). " +
45
+ "Numbers: + - * / %, round(x, digits), floor, ceil, abs, min, max, sum, avg, count, fixed(x, digits) → text. Text: & joins (empty counts as \"\"), concat, upper, lower, trim, length, left(s, n), right(s, n), replace(s, from, to), contains(s, part), slug(s), text(x), number(s). " +
46
+ "Logic: = != < <= > >=, and, or, not, if(cond, a, b), coalesce(a, b), empty(x). Dates: year, month, day, date(datetime), daysBetween(a, b), addDays(d, n). Literals: 12, 2.5, \"text\", true, false, null. " +
47
+ "Sensitive fields, groups, JSON and location can't be read; there is no now(). The result type (number, text, boolean, date, datetime) follows from the formula.";
41
48
  export function createTools(api) {
42
49
  return [
43
50
  {
44
51
  name: "get_schema",
45
- description: "Read the project's full content schema: collections with their fields.",
52
+ description: "Read the project's full content schema: collections with their fields (a computed field carries its formula and result type under `computed`).",
46
53
  schema: {},
47
54
  handler: async () => api.request("GET", "/v1/agent/schema"),
48
55
  },
@@ -82,6 +89,10 @@ export function createTools(api) {
82
89
  .max(50)
83
90
  .optional()
84
91
  .describe("For type enum only: the values a record may hold, in display order."),
92
+ computed: z
93
+ .object({ expression: z.string().min(1).max(500) })
94
+ .optional()
95
+ .describe(`${COMPUTED_HELP} In a plan the formula may read fields of this plan (this collection, or another one through a relation); one that doesn't check is skipped with a warning when the plan is applied.`),
85
96
  relation: z
86
97
  .object({
87
98
  target: z
@@ -206,7 +217,7 @@ export function createTools(api) {
206
217
  },
207
218
  {
208
219
  name: "clear_records",
209
- description: "Destructive: move every record of a collection to Trash (kept 7 days), e.g. before re-importing content. " +
220
+ description: "Destructive: move every record of a collection to Trash (kept 7 to 90 days by the project's plan), e.g. before re-importing content. " +
210
221
  "Needs a person's confirmation on a trusted Mapled screen (returns a reviewUrl to send to the user); poll " +
211
222
  "get_confirmation.",
212
223
  schema: { collectionKey: z.string().min(1).max(120) },
@@ -296,7 +307,7 @@ export function createTools(api) {
296
307
  },
297
308
  {
298
309
  name: "add_field",
299
- description: "Add a field to a collection. Types: short_text, long_text, rich_text (Markdown: headings, lists, links, bold/italic, images as ![alt](file URL)), slug, image, number, boolean, date, relation (a link to records of another collection: pass `relation`; values are record ids), enum (a choice: pass `options`), url, email, group (an object shaped by its own `group.fields`, or a list of them when repeatable — feature cards, FAQ items; values are objects / arrays of objects keyed by the sub-field keys), datetime (ISO 8601, stored in UTC), file (an asset id of any uploaded file), color (#rrggbb), json (any object or list up to 32 KB — settings, specs, structured data the site reads as is), location ({ lat, lng } in degrees).",
310
+ description: "Add a field to a collection. Types: short_text, long_text, rich_text (Markdown: headings, lists, links, bold/italic, images as ![alt](file URL)), slug, image, number, boolean, date, relation (a link to records of another collection: pass `relation`; values are record ids), enum (a choice: pass `options`), url, email, group (an object shaped by its own `group.fields`, or a list of them when repeatable — feature cards, FAQ items; values are objects / arrays of objects keyed by the sub-field keys), datetime (ISO 8601, stored in UTC), file (an asset id of any uploaded file), color (#rrggbb), json (any object or list up to 32 KB — settings, specs, structured data the site reads as is), location ({ lat, lng } in degrees), computed (a value derived from the record's other fields: pass `computed.expression`; never required or sensitive).",
300
311
  schema: {
301
312
  collectionKey: z.string().min(1).max(120),
302
313
  displayName: z.string().min(1).max(120),
@@ -360,6 +371,7 @@ export function createTools(api) {
360
371
  })
361
372
  .optional()
362
373
  .describe("For type group only. Sub-field keys are the lowercase, hyphenated names."),
374
+ computed: z.object({ expression: z.string().min(1).max(500) }).optional().describe(COMPUTED_HELP),
363
375
  },
364
376
  handler: async (args) => api.request("POST", `/v1/agent/collections/${encodeURIComponent(args.collectionKey)}/fields`, {
365
377
  displayName: args.displayName,
@@ -372,6 +384,7 @@ export function createTools(api) {
372
384
  ...(args.options ? { options: args.options } : {}),
373
385
  ...(args.sensitive !== undefined ? { sensitive: args.sensitive } : {}),
374
386
  ...(args.group ? { group: args.group } : {}),
387
+ ...(args.computed ? { computed: args.computed } : {}),
375
388
  }),
376
389
  },
377
390
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mapled/mcp",
3
- "version": "0.11.0",
3
+ "version": "0.12.0",
4
4
  "description": "Mapled MCP server: lets AI agents build schema and content for one Mapled project.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://mapled.io",