Skip to main content
Glama
rosschurchill

Technitium MCP Secure

dns_block_domain

Block a domain on your DNS server to deny all queries to it. Specify the domain name to add it to the blocklist.

Instructions

Block a domain name. Queries to this domain will be denied by the DNS server.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
domainYesDomain name to block (e.g. ads.example.com)

Implementation Reference

  • Handler function for dns_block_domain. Takes a 'domain' argument, validates it using validateDomain(), calls the Technitium API endpoint '/api/blocked/add' via client.callOrThrow(), and returns a JSON response with success status and the blocked domain.
    handler: async (args) => {
      const domain = validateDomain(args.domain as string);
      const data = await client.callOrThrow("/api/blocked/add", {
        domain,
      });
      return JSON.stringify(
        { success: true, blocked: domain, ...data },
        null,
        2
      );
    },
  • Input schema for dns_block_domain. Defines a required 'domain' string parameter and provides a description. The tool is marked as not readonly (mutates state).
    inputSchema: {
      type: "object",
      properties: {
        domain: {
          type: "string",
          description: "Domain name to block (e.g. ads.example.com)",
        },
      },
      required: ["domain"],
    },
  • The getAllTools function aggregates all tool entries, including blockingTools(client) which contains dns_block_domain. This is called from the main server setup in src/index.ts.
    export function getAllTools(client: TechnitiumClient): ToolEntry[] {
      return [
        ...dashboardTools(client),
        ...dnsClientTools(client),
        ...zoneTools(client),
        ...recordTools(client),
        ...blockingTools(client),
        ...cacheTools(client),
        ...settingsTools(client),
        ...logTools(client),
        ...appTools(client),
        ...dnssecTools(client),
      ];
    }
  • src/index.ts:18-148 (registration)
    Main server entry point that loads tools via getAllTools(), filters by readonly mode, and registers them with the MCP server via CallToolRequestSchema handler which dispatches to the tool's handler.
    async function main(): Promise<void> {
      const config = loadConfig();
      const client = new TechnitiumClient(config);
      const allTools = getAllTools(client);
    
      // Filter out write tools in readonly mode
      const tools = config.readonly
        ? allTools.filter((t) => t.readonly)
        : allTools;
    
      if (config.readonly) {
        audit.logSecurity(
          "readonly_mode",
          `Exposing ${tools.length} of ${allTools.length} tools (write tools hidden)`
        );
      }
    
      const toolMap = new Map(tools.map((t) => [t.definition.name, t]));
      const rateLimiter = new RateLimiter();
    
      const server = new Server(
        { name: "technitium-mcp", version: VERSION },
        { capabilities: { tools: {} } }
      );
    
      server.setRequestHandler(ListToolsRequestSchema, async () => ({
        tools: tools.map((t) => t.definition),
      }));
    
      server.setRequestHandler(CallToolRequestSchema, async (request) => {
        const { name, arguments: args } = request.params;
        const tool = toolMap.get(name);
    
        if (!tool) {
          return {
            content: [
              { type: "text" as const, text: JSON.stringify({ error: `Unknown tool: ${name}` }) },
            ],
            isError: true,
          };
        }
    
        // Rate limit check
        const rateCheck = rateLimiter.check(name);
        if (!rateCheck.allowed) {
          audit.logSecurity("rate_limited", `Tool ${name} rate limited`);
          return {
            content: [
              {
                type: "text" as const,
                text: JSON.stringify({
                  error: "Rate limited",
                  retryAfterMs: rateCheck.retryAfterMs,
                }),
              },
            ],
            isError: true,
          };
        }
    
        const startTime = Date.now();
    
        try {
          const rawResult = await tool.handler((args || {}) as Record<string, unknown>);
    
          // Sanitize the response
          let sanitized: string;
          try {
            const parsed = JSON.parse(rawResult);
            sanitized = JSON.stringify(sanitizeResponse(parsed), null, 2);
          } catch {
            sanitized = rawResult;
          }
    
          audit.logToolCall(
            name,
            (args || {}) as Record<string, unknown>,
            "success",
            Date.now() - startTime
          );
    
          return {
            content: [{ type: "text" as const, text: sanitized }],
          };
        } catch (error) {
          const rawMessage = error instanceof Error ? error.message : String(error);
          const message = sanitizeError(rawMessage);
    
          audit.logToolCall(
            name,
            (args || {}) as Record<string, unknown>,
            "error",
            Date.now() - startTime,
            message
          );
    
          return {
            content: [
              {
                type: "text" as const,
                text: JSON.stringify({ error: message }),
              },
            ],
            isError: true,
          };
        }
      });
    
      let shuttingDown = false;
      const shutdown = async (signal: string) => {
        if (shuttingDown) return;
        shuttingDown = true;
        audit.logShutdown(signal);
        client.clearToken();
        await server.close();
        process.exit(0);
      };
    
      process.on("SIGINT", () => shutdown("SIGINT"));
      process.on("SIGTERM", () => shutdown("SIGTERM"));
    
      const transport = new StdioServerTransport();
      audit.logStartup(VERSION, maskUrl(config.url));
      await server.connect(transport);
    }
    
    main().catch((error) => {
      const message = error instanceof Error ? error.message : String(error);
      audit.logSecurity("fatal_error", sanitizeError(message));
      process.exit(1);
    });
  • The validateDomain function used by the handler to sanitize and validate the domain name argument (trims, lowercases, checks length and regex pattern).
    export function validateDomain(domain: string): string {
      if (!domain || typeof domain !== "string") {
        throw new Error("Domain name is required");
      }
      const trimmed = domain.trim().toLowerCase();
      if (trimmed.length > 253) {
        throw new Error("Domain name exceeds maximum length of 253 characters");
      }
      if (!DOMAIN_RE.test(trimmed)) {
        throw new Error("Invalid domain name format");
      }
      return trimmed;
    }
  • Rate limiting configuration for dns_block_domain. It is grouped with other 'mutate' operations limited to 10 requests per 60-second window.
    for (const tool of [
      "dns_create_zone", "dns_add_record", "dns_update_record",
      "dns_block_domain", "dns_allow_domain",
      "dns_remove_allowed", "dns_remove_blocked", "dns_delete_cached",
      "dns_enable_zone", "dns_disable_zone", "dns_set_zone_options",
      "dns_set_settings", "dns_install_app",
    ]) {
      this.toolLimits.set(tool, mutateLimits);
    }

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.1.0

TDQS

A3.8/5.0
Behavior3/5

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

With no annotations, the description must disclose behavior. It states the effect (queries denied) but does not mention reversibility, permissions, idempotency, or side effects. It provides basic transparency but leaves gaps.

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?

Two sentences, no filler, front-loaded with the action. Every word earns its place.

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 simple one-parameter tool with no output schema, the description covers the main action and effect. It lacks detail on return values or edge cases, but given the low complexity, it's largely sufficient.

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 schema already provides a full description for the only parameter ('Domain name to block'), so the description adds little beyond that. 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 uses a specific verb 'Block' and resource 'domain name', and clarifies the consequence ('Queries to this domain will be denied'), which clearly distinguishes it from sibling tools like dns_allow_domain or dns_remove_blocked.

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 when to use the tool (to block a domain) but does not explicitly mention alternatives or exclusions. It lacks guidance on when not to use it or how it differs from related tools like dns_allow_domain.

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