attach_flow_model
Attach an existing flow model to a parent container at a specific position. Integrate blocks into flowPage layouts.
Instructions
Attach an existing flowPage block/model to a parent. Use this to add an existing block into a flowPage container at a specific position.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| uid | Yes | Flow model UID to attach | |
| parentId | Yes | Parent flow model UID to attach to | |
| subKey | Yes | Sub-key within the parent (e.g. 'items') | |
| subType | No | Sub-type (e.g. 'array') | |
| position | No | Sort position index |
Implementation Reference
- src/index.ts:245-263 (registration)Registration of the attach_flow_model tool via server.registerTool() with the name 'attach_flow_model'.
server.registerTool( "attach_flow_model", { description: "Attach an existing flowPage block/model to a parent. Use this to add an existing block into a flowPage container at a specific position.", inputSchema: { uid: z.string().describe("Flow model UID to attach"), parentId: z.string().describe("Parent flow model UID to attach to"), subKey: z.string().describe("Sub-key within the parent (e.g. 'items')"), subType: z.string().optional().describe("Sub-type (e.g. 'array')"), position: z.number().optional().describe("Sort position index"), }, }, async ({ uid, parentId, subKey, subType, position }) => { const qs = new URLSearchParams({ uid, parentId, subKey }); if (subType) qs.set("subType", subType); if (position !== undefined) qs.set("position", String(position)); return ok(await nocoFetch(`/api/flowModels:attach?${qs}`, { method: "POST" })); } ); - src/index.ts:257-262 (handler)Handler function that builds query params from inputs and calls the nocoFetch helper to POST to /api/flowModels:attach.
async ({ uid, parentId, subKey, subType, position }) => { const qs = new URLSearchParams({ uid, parentId, subKey }); if (subType) qs.set("subType", subType); if (position !== undefined) qs.set("position", String(position)); return ok(await nocoFetch(`/api/flowModels:attach?${qs}`, { method: "POST" })); } - src/index.ts:249-255 (schema)Input schema definition with Zod: uid, parentId, subKey (required), subType and position (optional).
inputSchema: { uid: z.string().describe("Flow model UID to attach"), parentId: z.string().describe("Parent flow model UID to attach to"), subKey: z.string().describe("Sub-key within the parent (e.g. 'items')"), subType: z.string().optional().describe("Sub-type (e.g. 'array')"), position: z.number().optional().describe("Sort position index"), }, - src/index.ts:18-27 (helper)The nocoFetch helper function used by the handler to make the actual HTTP POST request to the NocoBase API.
async function nocoFetch(path: string, options: RequestInit = {}): Promise<unknown> { const url = `${NOCOBASE_URL}${path}`; const res = await fetch(url, { ...options, headers: { ...reqHeaders, ...(options.headers as Record<string, string> | undefined) }, }); const text = await res.text(); if (!res.ok) throw new Error(`HTTP ${res.status} ${res.statusText}: ${text}`); try { return JSON.parse(text); } catch { return text; } } - src/index.ts:29-31 (helper)The ok helper that wraps the response into MCP content format, used by the handler to return results.
const ok = (data: unknown) => ({ content: [{ type: "text" as const, text: JSON.stringify(data, null, 2) }], });