Skip to main content
Glama

register_domain

Register a domain name using USDC payment via x402. Automatic async provisioning handles domain setup after registration.

Instructions

Register a new domain name. Requires USDC payment via x402. Handles async provisioning automatically.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
domainYesDomain to register (e.g., 'myproject.com')
yearsNoRegistration period in years (1-10, default: 1)

Implementation Reference

  • The registerDomain function is the handler for the register_domain tool. It validates the private key, ensures auth, POSTs to /domains/register, polls async jobs on 202, and formats the response.
    export async function registerDomain(
      client: BloomfilterClient,
      params: { domain: string; years?: number },
    ): Promise<McpToolResult> {
      const keyError = client.requiresPrivateKey();
      if (keyError) return keyError;
    
      try {
        await client.ensureAuth();
    
        const response = await client.http.post<RegistrationResponse>(
          "/domains/register",
          { domain: params.domain, years: params.years ?? 1 },
          { headers: client.getAuthHeaders() },
        );
    
        let result = response.data;
    
        // Async provisioning — poll until complete
        if (response.status === 202 && result.jobId) {
          console.error(`[bloomfilter-mcp] Registration queued (job ${result.jobId}), polling...`);
    
          const jobResult = await client.pollJobStatus(result.jobId);
          if (jobResult.result) {
            result = jobResult.result as RegistrationResponse;
          }
        }
    
        // Format the result
        const lines = [`Domain registered: ${result.domain}`, `Status: ${result.status}`];
    
        if (result.expiresAt) {
          lines.push(`Expires: ${result.expiresAt}`);
        }
        if (result.payment) {
          lines.push(`Cost: $${result.payment.amountUsd}`);
          if (result.payment.txHash) {
            lines.push(`Transaction: ${result.payment.txHash}`);
          }
          lines.push(`Network: ${result.payment.network}`);
        }
        if (result.dnsRecords && result.dnsRecords.length > 0) {
          lines.push("");
          lines.push("DNS Records:");
          for (const record of result.dnsRecords) {
            lines.push(`  ${record.type} ${record.host} \u2192 ${record.value}`);
          }
        }
        if (result.warnings && result.warnings.length > 0) {
          lines.push("");
          lines.push("Warnings:");
          for (const warning of result.warnings) {
            lines.push(`  \u26a0 ${warning}`);
          }
        }
    
        return { content: [{ type: "text", text: lines.join("\n") }] };
      } catch (error) {
        return formatToolError(error);
      }
    }
  • RegistrationResponse type — defines the shape of the API response for domain registration, including domain, status, expiresAt, payment details, DNS records, and warnings.
    export interface RegistrationResponse {
      domain: string;
      status: string;
      registeredAt?: string;
      expiresAt?: string;
      jobId?: string;
      payment?: {
        amountUsd: string;
        txHash?: string;
        network: string;
        settled: boolean;
      };
      dnsRecords?: Array<{ type: string; host: string; value: string }>;
      warnings?: string[];
    }
  • src/index.ts:117-132 (registration)
    The register_domain tool is registered with the MCP server on line 118-132, defining the tool name, description, Zod schema params (domain string, optional years int 1-10), and delegating to registerDomain().
    // 4. register_domain
    server.tool(
      "register_domain",
      "Register a new domain name. Requires USDC payment via x402. Handles async provisioning automatically.",
      {
        domain: z.string().describe("Domain to register (e.g., 'myproject.com')"),
        years: z
          .number()
          .int()
          .min(1)
          .max(10)
          .optional()
          .describe("Registration period in years (1-10, default: 1)"),
      },
      async (params) => registerDomain(client, params),
    );
  • pollJobStatus is a helper used by registerDomain for async provisioning — polls GET /domains/status/:jobId until completed or failed, with timeout.
      async function pollJobStatus(jobId: string): Promise<JobStatusResponse> {
        const startTime = Date.now();
    
        while (Date.now() - startTime < JOB_TIMEOUT_MS) {
          // Re-check auth on each poll — long polling loops can outlast token expiry
          await ensureAuth();
    
          const { data } = await httpClient.get<JobStatusResponse>(`/domains/status/${jobId}`, {
            headers: getAuthHeaders(),
          });
    
          if (data.status === "completed") {
            return data;
          }
    
          if (data.status === "failed") {
            throw new Error(data.error ?? `Job ${jobId} failed: domain provisioning was unsuccessful`);
          }
    
          // Wait before polling again
          await new Promise((resolve) => setTimeout(resolve, JOB_POLL_INTERVAL_MS));
        }
    
        throw new Error(
          `Job ${jobId} timed out after ${JOB_TIMEOUT_MS / 1000}s. ` +
            "The domain may still be provisioning — check status later with get_domain_info.",
        );
      }
    
      return {
        http: httpClient,
        ensureAuth,
        getAuthHeaders,
        requiresPrivateKey,
        pollJobStatus,
      };
    }
  • requiresPrivateKey is called at the top of registerDomain to check if a private key is configured; returns an error result if missing.
    function requiresPrivateKey(): McpToolResult | null {
      if (config.privateKey) return null;
      return {
        content: [
          {
            type: "text",
            text:
              "Error: BLOOMFILTER_PRIVATE_KEY is required for this operation. " +
              "Set it as an environment variable to enable domain registration, " +
              "renewal, DNS management, and account access.\n\n" +
              "Example: BLOOMFILTER_PRIVATE_KEY=0x... bloomfilter-mcp",
          },
        ],
        isError: true,
      };
    }
Behavior3/5

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

No annotations are provided, so the description carries the full burden. It discloses that USDC payment via x402 is required and that async provisioning is handled automatically. However, it lacks details on what the async process entails, potential errors, or whether the operation blocks or returns immediately.

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 extremely concise: two short sentences. The first sentence states the primary purpose, and the second adds critical behavioral context (payment and async handling). No wasted words.

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

Completeness2/5

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

For a payment-based mutation tool with no output schema, the description is incomplete. It does not specify the response format, success/failure indicators, polling instructions for async provisioning, or what happens if the domain is unavailable. This lack of detail could hinder correct 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?

Both parameters (domain and years) have descriptions in the input schema (100% coverage). The description does not add specific parameter-level meaning beyond what the schema already provides. 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 'Register a new domain name,' which is a specific verb and resource. It distinguishes itself from sibling tools like renew_domain and add_dns_record by focusing on new registration.

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 mentions payment method and async provisioning but provides no explicit guidance on when to use this tool versus alternatives like renew_domain or search_domains. Usage is implied by the name but not clearly delineated.

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/BloomFilter-Labs/mcp-server-bloomfilter'

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