Skip to main content
Glama

create_dns_record

Add DNS records like A, CNAME, MX, or TXT to domains managed through domain-suite-mcp, enabling AI agents to configure domain routing and services.

Instructions

Create a new DNS record

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
domainYes
providerNo
typeYes
nameYesSubdomain or '@' for root
contentYesIP address, hostname, or TXT value
ttlNoTTL in seconds; use 1 for Cloudflare Auto
priorityNoRequired for MX and SRV records

Implementation Reference

  • Main handler function that executes the create_dns_record tool logic. It resolves the provider, validates DNS write capability, constructs the DNSRecord object, and calls the provider's createDNSRecord method.
    export async function handleCreateDnsRecord(
      input: { domain: string; provider?: string } & DNSRecord,
      registry: ProviderRegistry,
    ) {
      const provider = input.provider ? registry.get(input.provider) : await registry.resolveProviderForDomain(input.domain);
      assertDnsWrite(provider.name(), (f) => provider.supports(f));
      const record: DNSRecord = { type: input.type, name: input.name, content: input.content, ttl: input.ttl, priority: input.priority };
      const created = await provider.createDNSRecord(input.domain, record);
      return stripRecord(created);
    }
  • src/server.ts:134-150 (registration)
    Registration of the 'create_dns_record' tool with the MCP server. Defines the input schema using Zod (domain, provider, type, name, content, ttl, priority) and imports/calls the handler function.
    server.tool('create_dns_record', 'Create a new DNS record', {
      domain: domainSchema,
      provider: z.string().optional(),
      type: z.enum(['A', 'AAAA', 'CNAME', 'MX', 'TXT', 'NS', 'SRV', 'CAA']),
      name: z.string().describe("Subdomain or '@' for root"),
      content: z.string().describe('IP address, hostname, or TXT value'),
      ttl: z.number().int().min(1).default(300).describe('TTL in seconds; use 1 for Cloudflare Auto'),
      priority: z.number().int().optional().describe('Required for MX and SRV records'),
    }, async (input) => {
      try {
        const { handleCreateDnsRecord } = await import('./tools/dns.js');
        const result = await handleCreateDnsRecord(input as Parameters<typeof handleCreateDnsRecord>[0], registry);
        return { content: [{ type: 'text', text: JSON.stringify(result) }] };
      } catch (err) {
        return { content: [{ type: 'text', text: formatErrorForAgent(err) }], isError: true };
      }
    });
  • The DNSRecord interface that defines the type structure for DNS records (id, type, name, content, ttl, priority). This is the schema used for input validation and type safety.
    export interface DNSRecord {
      id?: string;
      type: 'A' | 'AAAA' | 'CNAME' | 'MX' | 'TXT' | 'NS' | 'SRV' | 'CAA';
      name: string;
      content: string;
      ttl: number;
      priority?: number;
    }
  • Helper function assertDnsWrite that validates the provider supports DNS write capability before attempting to create the record. Throws AgentError if feature is not supported.
    export function assertDnsWrite(providerName: string, supports: (f: Feature) => boolean): void {
      if (!supports(Feature.DnsWrite)) {
        throw new AgentError(
          'FEATURE_NOT_SUPPORTED',
          `Provider '${providerName}' does not support DNS record management.`,
          'Use a provider that supports DNS writes (e.g., cloudflare, godaddy, namecheap, porkbun).',
          providerName,
        );
      }
    }

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/oso95/domain-suite-mcp'

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