Skip to main content
Glama
badchars

osint-mcp-server

by badchars

dns_spf_chain

Trace SPF DNS records to map email authentication chains, identify included domains, IP ranges, and verify RFC 7208 compliance for domain security analysis.

Instructions

Recursively resolve SPF include chain. Shows all included domains, IP ranges, detected services (Google Workspace, Microsoft 365, SendGrid, etc.), and RFC 7208 lookup limit compliance.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
domainYesDomain to trace SPF chain for
max_depthNoMaximum recursion depth (default: 10)

Implementation Reference

  • The `dnsSpfChain` function resolves the SPF record chain for a given domain, tracking depth, includes, and IP ranges to identify services and detect SPF lookups exceeding the RFC limit.
    export async function dnsSpfChain(domain: string, maxDepth = 10): Promise<SpfChainResult> {
      const visited = new Set<string>();
      const chain: SpfChainNode[] = [];
      const allIpRanges: string[] = [];
      const services = new Set<string>();
      let totalLookups = 0;
    
      async function resolveSpf(d: string, depth: number): Promise<void> {
        if (depth > maxDepth || visited.has(d)) return;
        visited.add(d);
        totalLookups++;
    
        try {
          const txts = await dns.resolveTxt(d);
          const spfRecord = txts.map((t) => t.join("")).find((t) => t.startsWith("v=spf1"));
          if (!spfRecord) return;
    
          const mechanisms = spfRecord.split(/\s+/).filter((m) => m !== "v=spf1");
          const includes: string[] = [];
          const ipRanges: string[] = [];
    
          for (const mech of mechanisms) {
            if (mech.startsWith("include:")) {
              const target = mech.slice(8);
              includes.push(target);
              // Identify known services
              for (const [pattern, service] of Object.entries(SPF_SERVICE_PATTERNS)) {
                if (target.includes(pattern)) services.add(service);
              }
            } else if (mech.startsWith("ip4:") || mech.startsWith("ip6:")) {
              const range = mech.slice(4);
              ipRanges.push(range);
              allIpRanges.push(range);
            } else if (mech.startsWith("a:") || mech.startsWith("mx:")) {
              // Count as DNS lookup
              totalLookups++;
            }
          }
    
          chain.push({ domain: d, depth, mechanisms, includes, ipRanges });
    
          // Recurse into includes
          for (const inc of includes) {
            await resolveSpf(inc, depth + 1);
          }
        } catch {
          // Domain might not have TXT records
        }
      }
    
      await resolveSpf(domain, 0);
    
      const maxChainDepth = chain.reduce((max, n) => Math.max(max, n.depth), 0);
    
      return {
        domain,
        chainDepth: maxChainDepth,
        totalLookups,
        lookupLimit: 10, // RFC 7208
        chain,
        allIpRanges,
        services: [...services],
        exceedsLimit: totalLookups > 10,
      };
    }
  • The `dnsSpfChainTool` definition registers the `dns_spf_chain` tool and connects it to the `dnsSpfChain` handler function.
    const dnsSpfChainTool: ToolDef = {
      name: "dns_spf_chain",
      description: "Recursively resolve SPF include chain. Shows all included domains, IP ranges, detected services (Google Workspace, Microsoft 365, SendGrid, etc.), and RFC 7208 lookup limit compliance.",
      schema: {
        domain: z.string().describe("Domain to trace SPF chain for"),
        max_depth: z.number().optional().describe("Maximum recursion depth (default: 10)"),
      },
      execute: async (args) =>
        json(await dnsSpfChain(args.domain as string, args.max_depth as number | undefined)),
    };
Behavior3/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions 'recursively resolve' (implying iterative lookups) and 'lookup limit compliance', which adds useful context about DNS query behavior and constraints. However, it lacks details on error handling, rate limits, or authentication needs, leaving gaps for a tool with potential network impacts.

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 a single, dense sentence that efficiently communicates the tool's purpose, process, and outputs without wasted words. It is front-loaded with the core action and avoids redundancy, making it highly concise and well-structured.

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

Completeness3/5

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

Given no annotations and no output schema, the description provides a clear purpose and some behavioral context (recursion, compliance checks). However, it lacks details on return format, error cases, or performance implications, which are important for a tool performing recursive DNS lookups. This makes it minimally adequate but incomplete for full contextual understanding.

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?

Schema description coverage is 100%, so the schema already documents both parameters (domain and max_depth). The description adds no additional parameter semantics beyond what the schema provides, such as format examples or domain validation rules. The baseline score of 3 reflects adequate but no extra value from the description.

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 specific action ('recursively resolve SPF include chain') and resource ('domain'), distinguishing it from sibling tools like dns_lookup or dns_email_security by focusing on SPF chain analysis. It explicitly lists outputs (included domains, IP ranges, services, compliance) that define its unique scope.

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 usage for SPF chain analysis but does not explicitly state when to use this tool versus alternatives (e.g., dns_email_security for broader email security checks). It provides some context by mentioning outputs like 'detected services' and 'RFC 7208 compliance', which hint at use cases, but lacks direct guidance on tool selection.

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/badchars/osint-mcp-server'

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