Skip to main content
Glama

update_js_block

Update the code content of a JavaScript block on a classic page by specifying its UI schema UID and providing new JavaScript code.

Instructions

Update the code content of a JS block UI schema by UID (for classic 'page' type pages, not flowPage)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
uidYesUI schema UID of the JS block
codeYesNew JavaScript code content

Implementation Reference

  • src/index.ts:348-364 (registration)
    Registration of the 'update_js_block' tool with inputSchema (uid, code) and handler calling PATCH /api/uiSchemas/${uid} to update the JS block code content.
    server.registerTool(
      "update_js_block",
      {
        description: "Update the code content of a JS block UI schema by UID (for classic 'page' type pages, not flowPage)",
        inputSchema: {
          uid: z.string().describe("UI schema UID of the JS block"),
          code: z.string().describe("New JavaScript code content"),
        },
      },
      async ({ uid, code }) =>
        ok(
          await nocoFetch(`/api/uiSchemas/${uid}`, {
            method: "PATCH",
            body: JSON.stringify({ "x-component-props": { code } }),
          })
        )
    );
  • Handler function for update_js_block: receives uid and code, then calls nocoFetch to PATCH the UI schema with new code in 'x-component-props'.
    async ({ uid, code }) =>
      ok(
        await nocoFetch(`/api/uiSchemas/${uid}`, {
          method: "PATCH",
          body: JSON.stringify({ "x-component-props": { code } }),
        })
      )
  • Input schema for update_js_block: requires uid (string) and code (string) parameters.
      description: "Update the code content of a JS block UI schema by UID (for classic 'page' type pages, not flowPage)",
      inputSchema: {
        uid: z.string().describe("UI schema UID of the JS block"),
        code: z.string().describe("New JavaScript code content"),
      },
    },
  • The nocoFetch helper function used by the handler to make authenticated HTTP requests 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; }
    }
  • The ok helper function that wraps the response data into the MCP content format.
    const ok = (data: unknown) => ({
      content: [{ type: "text" as const, text: JSON.stringify(data, null, 2) }],
    });
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, and the description only says 'update', which is a mutation. It does not disclose any behavioral traits such as destructive potential, permissions needed, or idempotency, leaving the agent with minimal information beyond the fact that code content will be modified.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single sentence that efficiently conveys the core purpose and scope, with no redundant or extraneous information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool with 2 required parameters and no output schema, the description covers the essential scope (classic pages vs flow pages). However, it lacks details about return values, side effects, or confirmation of success, which could help an agent understand the full behavior after invocation.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100% with descriptions for both uid and code. The description adds no extra meaning beyond the schema, and there are no constraints or formatting hints for the code parameter, so baseline 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool updates code content of a JS block UI schema by UID, specifying 'for classic page type pages, not flowPage', which effectively distinguishes it from siblings like update_flow_js_block.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description explicitly limits usage to classic pages, implying when not to use it (flow pages). While it does not name alternatives, the sibling list includes update_flow_js_block for flow pages, providing indirect guidance.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/puguhsudarma/nocobase-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server