Skip to main content
Glama

batch_create_qurls

Create multiple qURLs in a single request. Returns per-item results with error details for any failures, enabling handling of partial failures without manual parsing.

Instructions

Create multiple qURLs in a single request. Returns per-item results including any errors for partial failures. The response sets isError=true when one or more items fail so agents can branch on partial failure without parsing the JSON.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
itemsYesArray of qURL creation requests (1-100 items)

Implementation Reference

  • The main handler function for batch_create_qurls. Calls client.batchCreate(input), validates response shape with defense-in-depth checks, and returns per-item results with isError flag set when failed > 0.
    export function batchCreateTool(client: IQURLClient) {
      return {
        name: "batch_create_qurls",
        description:
          "Create multiple qURLs in a single request. " +
          "Returns per-item results including any errors for partial failures. " +
          "The response sets isError=true when one or more items fail so agents can branch on partial failure without parsing the JSON.",
        inputSchema: batchCreateSchema,
        handler: async (input: z.infer<typeof batchCreateSchema>) => {
          const result = await client.batchCreate(input);
          // Defense-in-depth: batchCreate passes through HTTP 400, which is
          // contracted to carry a BatchCreateResponse body with per-item errors.
          // If the API ever returns 400 with a different shape (e.g., a
          // top-level malformed-request error), the downstream `failed > 0`
          // access would be meaningless — surface the raw response as an error
          // so agents get a real signal instead of silent mis-interpretation.
          const data = result.data as Partial<typeof result.data> | undefined;
          if (
            !data ||
            typeof data.failed !== "number" ||
            typeof data.succeeded !== "number" ||
            !Array.isArray(data.results)
          ) {
            return {
              content: [
                {
                  type: "text" as const,
                  text: `Unexpected batchCreate response shape: ${JSON.stringify(result).slice(0, 500)}`,
                },
              ],
              isError: true,
            };
          }
          const payload = {
            ...data,
            request_id: result.meta?.request_id,
          };
          return {
            content: [
              {
                type: "text" as const,
                text: JSON.stringify(payload),
              },
            ],
            isError: data.failed > 0,
          };
        },
      };
    }
  • Input schema: an array of 1-100 create-qurl schemas, reused from create-qurl.ts.
    export const batchCreateSchema = z.object({
      items: z
        .array(createQurlSchema)
        .min(1)
        .max(100)
        .describe("Array of qURL creation requests (1-100 items)"),
    });
  • src/server.ts:39-54 (registration)
    Registration: batchCreateTool is included in the toolFactories array and registered via server.tool() at runtime.
    const toolFactories = [
      createQurlTool,
      resolveQurlTool,
      listQurlsTool,
      getQurlTool,
      deleteQurlTool,
      extendQurlTool,
      updateQurlTool,
      mintLinkTool,
      batchCreateTool,
    ] satisfies ToolFactory[];
    
    for (const factory of toolFactories) {
      const tool = factory(client);
      server.tool(tool.name, tool.description, tool.inputSchema.shape, tool.handler);
    }
  • Reused schema for each item in the batch. Defines the per-qURL creation fields (target_url, label, expires_in, etc.) imported into batch-create.ts.
    export const createQurlSchema = z.object({
      target_url: z.string().url().describe("The URL to protect with qURL"),
      label: z
        .string()
        .max(500)
        .optional()
        .describe("Human-readable label identifying who this qURL is for (max 500 chars)"),
      expires_in: z
        .string()
        .min(1)
        .optional()
        .describe('Duration string (e.g., "1h", "24h", "7d")'),
      one_time_use: z.boolean().optional().describe("Whether the link can only be used once"),
      max_sessions: z
        .number()
        .int()
        .min(0)
        .max(1000)
        .optional()
        .describe("Maximum concurrent sessions (0 = unlimited, max 1000)"),
      session_duration: z
        .string()
        .min(1)
        .optional()
        .describe('How long access lasts after clicking (e.g., "1h")'),
      custom_domain: z.string().optional().describe("Custom domain to assign to the auto-created resource"),
      access_policy: accessPolicySchema.optional().describe("Access control policy for the qURL"),
    });
Behavior4/5

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

With no annotations, the description carries full burden. It discloses critical behavioral traits: returns per-item results, includes errors for partial failures, and sets isError=true for easy branching on partial failure. This adds value beyond the schema.

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 three sentences long, front-loaded with the primary purpose, and every sentence provides value. No unnecessary words or redundancy.

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

Completeness4/5

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

For a batch creation tool with complex nested schema and no output schema, the description adequately explains the response behavior (per-item results and isError flag). It could mention the response structure more fully, but the given info is sufficient for an agent to understand error handling.

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?

The input schema has 100% description coverage for all parameters, so the description does not need to add parameter details. The description does not elaborate on parameters beyond what schema provides, which is acceptable for baseline score.

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 creates multiple qURLs in a single request, distinguishing it from the sibling create_qurl which handles single creations. The verb 'Create' and resource 'multiple qURLs' are specific and unambiguous.

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

Usage Guidelines3/5

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

The description implies batch usage but does not explicitly state when to use this over the single creation tool or other siblings. It mentions partial failure handling, which is a key differentiator, but lacks direct guidance on alternatives or exclusion cases.

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/layervai/qurl-mcp'

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