Skip to main content
Glama
benswel

QR for Agent

set_custom_domain

Configure a custom domain for QR code short URLs (Pro required). All new QR codes will use your branded domain after setting DNS CNAME. Pass null to remove.

Instructions

Set a custom domain for your QR code short URLs (Pro plan required). When set, all new QR codes will use https://your-domain.com/r/... instead of the default URL. You must configure DNS (CNAME) to point to the QR Agent server. Pass domain=null to remove the custom domain.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
domainYesYour custom domain without protocol (e.g. 'qr.mybrand.com'). Pass null to remove.

Implementation Reference

  • MCP tool handler for 'set_custom_domain'. Defines description, inputSchema (zod validation for nullable domain string), and handler that calls the HTTP API: PUT /api/domain (with body {domain}) to set, or DELETE /api/domain to remove.
    set_custom_domain: {
      description:
        "Set a custom domain for your QR code short URLs (Pro plan required). When set, all new QR codes will use https://your-domain.com/r/... instead of the default URL. You must configure DNS (CNAME) to point to the QR Agent server. Pass domain=null to remove the custom domain.",
      inputSchema: z.object({
        domain: z
          .string()
          .nullable()
          .describe(
            "Your custom domain without protocol (e.g. 'qr.mybrand.com'). Pass null to remove."
          ),
      }),
      handler: async (input: { domain: string | null }) => {
        if (input.domain === null) {
          return apiRequest("/api/domain", { method: "DELETE" });
        }
        return apiRequest("/api/domain", {
          method: "PUT",
          body: { domain: input.domain },
        });
      },
    },
  • Input schema for set_custom_domain tool. Uses zod to define a nullable string 'domain' (e.g. 'qr.mybrand.com') which can also be null to remove the custom domain.
    inputSchema: z.object({
      domain: z
        .string()
        .nullable()
        .describe(
          "Your custom domain without protocol (e.g. 'qr.mybrand.com'). Pass null to remove."
        ),
    }),
  • Core database function setCustomDomain that updates the customDomain field on an apiKeys row by keyId using SQLite/Drizzle ORM.
    export function setCustomDomain(keyId: number, domain: string | null): void {
      db.update(apiKeys)
        .set({ customDomain: domain })
        .where(eq(apiKeys.id, keyId))
        .run();
    }
  • The tools object where set_custom_domain (and all other MCP tools) is registered/exported. Each tool has description, inputSchema, and handler.
    import { z } from "zod";
    import { apiRequest } from "./api-client.js";
    
    /**
     * MCP tool definitions for QR Agent Core.
     * Each tool calls the production HTTP API.
     */
    export const tools = {
  • HTTP API route handler for PUT /api/domain (called by the MCP tool). Validates input, enforces Pro plan gate, checks domain format/uniqueness, calls setCustomDomain(), and checks DNS status.
    // PUT /api/domain — set custom domain (Pro only)
    app.put(
      "/",
      {
        schema: {
          tags: ["Custom Domain"],
          summary: "Set your custom domain",
          description:
            "Configure a custom domain for your QR code short URLs. Pro plan required. The domain must be unique across all users.",
          body: {
            type: "object",
            required: ["domain"],
            properties: {
              domain: {
                type: "string",
                description:
                  "Your custom domain without protocol (e.g. 'qr.mybrand.com').",
              },
            },
          },
          response: {
            200: {
              type: "object",
              properties: {
                custom_domain: { type: "string" },
                dns_status: { type: "string" },
                hint: { type: "string" },
              },
            },
          },
        },
      },
      async (request, reply) => {
        // Pro-only gate
        if (request.plan !== "pro") {
          return sendError(reply, 403, {
            error: "Custom domains require a Pro plan.",
            code: "PRO_REQUIRED",
            hint: "Upgrade to Pro ($19/month) to use custom domains. Use the upgrade_to_pro tool or POST /api/stripe/checkout.",
          });
        }
    
        const { domain } = request.body as { domain: string };
    
        // Basic validation: no protocol, no path, no whitespace
        const cleaned = domain.trim().toLowerCase();
        if (
          !cleaned ||
          cleaned.includes("://") ||
          cleaned.includes("/") ||
          cleaned.includes(" ")
        ) {
          return sendError(reply, 400, {
            error: "Invalid domain format.",
            code: "INVALID_DOMAIN",
            hint: "Provide a bare domain without protocol or path (e.g. 'qr.mybrand.com', not 'https://qr.mybrand.com/').",
          });
        }
    
        // Must contain at least one dot
        if (!cleaned.includes(".")) {
          return sendError(reply, 400, {
            error: "Invalid domain format.",
            code: "INVALID_DOMAIN",
            hint: "Provide a fully qualified domain name with at least one dot (e.g. 'qr.mybrand.com').",
          });
        }
    
        // Uniqueness check
        if (isCustomDomainTaken(cleaned, request.apiKeyId)) {
          return sendError(reply, 409, {
            error: `Domain "${cleaned}" is already claimed by another user.`,
            code: "DOMAIN_ALREADY_TAKEN",
            hint: "Choose a different subdomain or contact support if you believe this is an error.",
          });
        }
    
        setCustomDomain(request.apiKeyId, cleaned);
        const dnsStatus = await checkDnsStatus(cleaned);
    
        return {
          custom_domain: cleaned,
          dns_status: dnsStatus,
          hint:
            dnsStatus === "active"
              ? `Domain ${cleaned} is active. New QR codes will use https://${cleaned}/r/...`
              : `Domain ${cleaned} saved. DNS is pending — add a CNAME record pointing to your server. Use GET /api/domain to re-check status.`,
        };
      }
    );
Behavior4/5

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

With no annotations, the description fully discloses the behavioral effect (all new QR codes use the custom domain) and the DNS requirement. It does not mention rate limits or authentication, but it adequately describes the mutation and removal behavior.

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 concise with three sentences. The first sentence states the purpose and prerequisite, the second explains the effect, and the third covers configuration and removal. No extraneous information, front-loaded with key details.

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

Completeness5/5

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

Given the low complexity (one parameter, no output schema), the description is fully complete. It covers purpose, prerequisites, usage, effect, and removal. No additional information is needed for correct tool invocation.

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

Parameters4/5

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

The input schema has 100% descriptive coverage for the single parameter. The description adds value by explaining the expected format (no protocol), providing an example, and clarifying that null removes the domain. This goes beyond the schema.

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's purpose: setting a custom domain for QR code short URLs. It specifies the effect (new QR codes use custom domain) and provides example URL format, distinguishing it from sibling tools like get_custom_domain.

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 mentions the Pro plan requirement and DNS configuration prerequisite. It also explains how to remove the domain. However, it does not explicitly contrast with alternatives or state when not to use, but the context is clear enough.

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/benswel/qr-agent-core'

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