@mapled/mcp 0.21.1 → 0.21.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.
- package/README.md +1 -0
- package/dist/tools.js +42 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -67,6 +67,7 @@ A rename or a conversion Mapled wouldn't take is refused at once with the reason
|
|
|
67
67
|
| `create_collection` | Add a collection or single |
|
|
68
68
|
| `add_field` | Add a field (short_text, long_text, rich_text, slug, image, number, boolean, date, datetime, relation, enum, url, email, group, file, color, json — an object or list up to 32 KB, location — { lat, lng }, computed, components). Optional `validation` ({min, max, pattern}) and `defaultValue`; `relation` ({target, cardinality: one \| many, onDelete: restrict \| nullify}) is required for relation fields — values are record ids of the target collection, kept in the order given; `onDelete` says what a delete of a linked record does (restrict: it can't be deleted while linked, nullify: the links are cleared — the default is restrict for required fields and nullify otherwise); `options` (1–50 labels) is required for enum fields; `sensitive: true` keeps a field out of lists, history and delivery (a group's sub-fields take it too); `group` ({fields, repeatable, maxItems}) shapes a group field — its values are objects (or arrays of them) keyed by the sub-field keys; `components` ({allowed, min, max}) makes a components field — an ordered list of blocks of the component types named in `allowed` (their keys, from `add_component_type`); values are lists of `{ _type, _key, …sub-fields }`, `_key` given by Mapled and kept when sent back; `computed` ({expression}) makes a computed field — a formula Mapled evaluates whenever a record is read or published, over the record's fields and up to two links through relations (`author.company.name`, `sum(items.product.price)`) or back along one and one link on (`count(@posts.author)`, `sum(@order-items.order.product.price)`), at most one list per path, never a sensitive field or relation; `today()` and `now()` are the moment the value was computed — baked at publish and recomputed once a day for the current release; the site reads the value like any field of its result type. |
|
|
69
69
|
| `add_component_type` | Add a component type — a reusable block (hero, text, gallery…) for `components` fields: a name and the sub-fields an item holds (the types a group's sub-fields take, none sensitive, no relation or components inside); its key is what an item names in `_type`; `types generate` writes one TypeScript type per component and a components field as a union of them |
|
|
70
|
+
| `list_templates` / `create_project_from_template` | Project templates — Mapled's curated starting points (landing, blog, docs). The list gives each one's slug, name, description, starter-site repository and what it creates; creating makes a **new** project for the person who connected the client (theirs to own, on one of their plan's slots) with the template's collections, component types and sample records. `region` (`us` by default, or `eu` on a paid plan) says where the project's data is kept; it is chosen at creation and doesn't change. A template never applies to an existing project, and the connection keeps working only in the project it was made for — the answer says how to connect a client to the new one. |
|
|
70
71
|
| `add_records` | Insert draft records — a translated field (`localized: true` in `get_schema`) by language, `{ "en": "About us", "ru": "О нас" }`, or as one plain value, the default language's |
|
|
71
72
|
| `list_records` | Read a collection's draft records, newest edit first — `query` searches their content as full text (every word, the last one from its start; best match first), `limit` (1–200) and `cursor` (the previous answer's `nextCursor`) page through them; `total` counts every match; `locale` reads the translated fields in one language (`ru`) or in every one at once (`*`, as `{ "en": …, "ru": … }`) |
|
|
72
73
|
| `create_form` / `list_forms` | Set up public forms with spam protection |
|
package/dist/tools.js
CHANGED
|
@@ -29,6 +29,10 @@ export function createApiClient(baseUrl, token) {
|
|
|
29
29
|
},
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
|
+
/** What a project's site is built with, as New project takes it. */
|
|
33
|
+
const PROJECT_STACKS = ["nextjs", "react-spa", "plain-html", "other"];
|
|
34
|
+
/** Where a project's data can be kept (architecture §45.4): chosen when it is created. */
|
|
35
|
+
const PROJECT_REGIONS = ["us", "eu"];
|
|
32
36
|
export const FIELD_TYPES = [
|
|
33
37
|
"short_text",
|
|
34
38
|
"long_text",
|
|
@@ -666,6 +670,44 @@ export function createTools(api) {
|
|
|
666
670
|
},
|
|
667
671
|
handler: async (args) => api.request("POST", "/v1/agent/component-types", { displayName: args.displayName, fields: args.fields ?? [] }),
|
|
668
672
|
},
|
|
673
|
+
{
|
|
674
|
+
name: "list_templates",
|
|
675
|
+
description: "List Mapled's project templates — curated starting points for a new project (a landing page, a blog, documentation): for each its slug, name, description, " +
|
|
676
|
+
"the repository of its starter site (`repoUrl`, or null), the collections it creates, and how many component types and sample records come with it. " +
|
|
677
|
+
"A template only ever starts a new project — create_project_from_template; nothing applies one to the project this connection works in.",
|
|
678
|
+
schema: {},
|
|
679
|
+
handler: async () => api.request("GET", "/v1/agent/templates"),
|
|
680
|
+
},
|
|
681
|
+
{
|
|
682
|
+
name: "create_project_from_template",
|
|
683
|
+
description: "Create a new Mapled project from a template (list_templates gives the slugs) for the person who connected this client: they own it, and it takes one of their plan's project slots — " +
|
|
684
|
+
"so call it only when the person asked for a new project. It comes with the template's collections, component types and sample records, all at once or not at all. " +
|
|
685
|
+
"This connection still works only in the project it was made for: the answer's `next` says how the person connects a client to the new one, and `template.repoUrl` is its starter site. " +
|
|
686
|
+
"`region` is where the project's data is kept — `us` (when left out) or `eu`; it is chosen here and can't be changed later, and `eu` is for paid plans: pass it only when the person asked for it. " +
|
|
687
|
+
"Refused when the slug is taken, the person has no slot left, or the region isn't open to their plan — tell the person; don't try again under another name or region.",
|
|
688
|
+
schema: {
|
|
689
|
+
template: z.string().min(1).max(60).describe("A template's slug, as list_templates gives it."),
|
|
690
|
+
name: z.string().min(1).max(120).describe("The project's name, as the person will see it."),
|
|
691
|
+
slug: z
|
|
692
|
+
.string()
|
|
693
|
+
.min(3)
|
|
694
|
+
.max(60)
|
|
695
|
+
.optional()
|
|
696
|
+
.describe("The project's slug: lowercase letters, digits and hyphens. Left out, it is made from the name."),
|
|
697
|
+
frontendStack: z.enum(PROJECT_STACKS).optional().describe("What the site is built with; nextjs when left out."),
|
|
698
|
+
region: z
|
|
699
|
+
.enum(PROJECT_REGIONS)
|
|
700
|
+
.optional()
|
|
701
|
+
.describe("Where the project's data is kept: us (when left out) or eu. Chosen once — it can't be changed later. eu needs a paid plan."),
|
|
702
|
+
},
|
|
703
|
+
handler: async (args) => api.request("POST", "/v1/agent/projects", {
|
|
704
|
+
template: args.template,
|
|
705
|
+
name: args.name,
|
|
706
|
+
...(args.slug ? { slug: args.slug } : {}),
|
|
707
|
+
...(args.frontendStack ? { frontendStack: args.frontendStack } : {}),
|
|
708
|
+
...(args.region ? { region: args.region } : {}),
|
|
709
|
+
}),
|
|
710
|
+
},
|
|
669
711
|
{
|
|
670
712
|
name: "add_records",
|
|
671
713
|
description: "Insert up to 100 records into a collection. Each record maps field keys to values (rich_text takes Markdown; image takes an asset id; relation takes record ids; group takes objects; components takes a list of items, each { _type: \"<component key>\", …its sub-fields } — Mapled gives every item a _key, kept when sent back). " +
|