registrobr-domain-check
Verify the status and availability of .br domain names in Brazil. Use this tool to check if a specific domain is registered or free for registration, ensuring accurate domain management.
Instructions
Check the status and availability of a .br domain name
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| domain | Yes | Domain name to check (with or without .br extension) |
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"domain": {
"description": "Domain name to check (with or without .br extension)",
"type": "string"
}
},
"required": [
"domain"
],
"type": "object"
}
Implementation Reference
- src/tools/registrobr/index.ts:18-75 (handler)Executes the tool logic: cleans domain input, fetches status from Brasil API via getBrasilApiData, formats availability response with details like nameservers, expiration, and suggestions.async ({ domain }) => { console.error(`Checking domain status: ${domain}`); // Make sure we're using the domain name only without http or https let cleanDomain = domain.toLowerCase(); cleanDomain = cleanDomain.replace(/^https?:\/\//i, ""); cleanDomain = cleanDomain.replace(/^www\./i, ""); // If domain doesn't end with .br, we don't add it automatically // as the API accepts any domain name to evaluate const result = await getBrasilApiData(`/registrobr/v1/${cleanDomain}`); if (!result.success) { return formatErrorResponse(`Error checking domain: ${result.message}`); } // Format the response data const domainInfo = result.data; // Create a formatted response based on the domain status let statusText; if (domainInfo.status === "AVAILABLE") { statusText = `${cleanDomain} is AVAILABLE for registration`; } else if (domainInfo.status === "REGISTERED") { statusText = `${cleanDomain} is REGISTERED`; // Add more details if available if (domainInfo.hosts && domainInfo.hosts.length > 0) { statusText += `\nNameservers: ${domainInfo.hosts.join(", ")}`; } if (domainInfo.expiresAt) { statusText += `\nExpires at: ${domainInfo.expiresAt}`; } if (domainInfo.suggestions && domainInfo.suggestions.length > 0) { statusText += `\n\nSimilar available domains:\n${domainInfo.suggestions.join("\n")}`; } } else { statusText = `Status for ${cleanDomain}: ${domainInfo.status}`; if (domainInfo.suggestions && domainInfo.suggestions.length > 0) { statusText += `\n\nSuggested available domains:\n${domainInfo.suggestions.join("\n")}`; } } return { content: [{ type: "text" as const, text: ` Domain Check Result: ${statusText} ` }] }; } );
- src/tools/registrobr/index.ts:14-17 (schema)Zod input schema defining the 'domain' parameter as a string.{ domain: z.string() .describe("Domain name to check (with or without .br extension)") },
- src/tools/registrobr/index.ts:12-75 (registration)Registers the 'registrobr-domain-check' tool with the MCP server, including name, description, input schema, and handler."registrobr-domain-check", "Check the status and availability of a .br domain name", { domain: z.string() .describe("Domain name to check (with or without .br extension)") }, async ({ domain }) => { console.error(`Checking domain status: ${domain}`); // Make sure we're using the domain name only without http or https let cleanDomain = domain.toLowerCase(); cleanDomain = cleanDomain.replace(/^https?:\/\//i, ""); cleanDomain = cleanDomain.replace(/^www\./i, ""); // If domain doesn't end with .br, we don't add it automatically // as the API accepts any domain name to evaluate const result = await getBrasilApiData(`/registrobr/v1/${cleanDomain}`); if (!result.success) { return formatErrorResponse(`Error checking domain: ${result.message}`); } // Format the response data const domainInfo = result.data; // Create a formatted response based on the domain status let statusText; if (domainInfo.status === "AVAILABLE") { statusText = `${cleanDomain} is AVAILABLE for registration`; } else if (domainInfo.status === "REGISTERED") { statusText = `${cleanDomain} is REGISTERED`; // Add more details if available if (domainInfo.hosts && domainInfo.hosts.length > 0) { statusText += `\nNameservers: ${domainInfo.hosts.join(", ")}`; } if (domainInfo.expiresAt) { statusText += `\nExpires at: ${domainInfo.expiresAt}`; } if (domainInfo.suggestions && domainInfo.suggestions.length > 0) { statusText += `\n\nSimilar available domains:\n${domainInfo.suggestions.join("\n")}`; } } else { statusText = `Status for ${cleanDomain}: ${domainInfo.status}`; if (domainInfo.suggestions && domainInfo.suggestions.length > 0) { statusText += `\n\nSuggested available domains:\n${domainInfo.suggestions.join("\n")}`; } } return { content: [{ type: "text" as const, text: ` Domain Check Result: ${statusText} ` }] }; } );
- src/utils/api.ts:11-40 (helper)Helper function to fetch data from Brasil API, used to query /registrobr/v1/{domain} endpoint in the handler.export async function getBrasilApiData(endpoint: string, params: Record<string, any> = {}) { try { const url = `${BASE_URL}${endpoint}`; console.error(`Making request to: ${url}`); const response = await axios.get(url, { params }); return { data: response.data, success: true }; } catch (error: any) { console.error(`Error in API request: ${error.message}`); // Handle API errors in a structured format if (error.response) { return { success: false, statusCode: error.response.status, message: error.response.data?.message || error.message, error: error.response.data }; } return { success: false, message: error.message, error }; } }
- src/utils/api.ts:47-55 (helper)Helper function to format error responses consistently, used when API call fails.export function formatErrorResponse(message: string) { return { content: [{ type: "text" as const, text: message }], isError: true }; }