Skip to main content
Glama
Cyreslab-AI

Have I Been Pwned MCP Server

check_email

Verify if an email address has been exposed in data breaches using the Have I Been Pwned API. Includes options to check unverified breaches and truncate response data for streamlined results.

Instructions

Check if an email address has been found in data breaches

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
emailYesEmail address to check
include_unverifiedNoInclude unverified breaches in the results
truncate_responseNoTruncate the response to only include breach names

Implementation Reference

  • The primary handler function that executes the check_email tool logic, querying the HIBP API for breached accounts associated with the given email and formatting the response.
    private async handleCheckEmail(args: any) { if (!args.email || typeof args.email !== "string") { throw new McpError( ErrorCode.InvalidParams, "Email address is required" ); } const params: Record<string, any> = {}; if (args.include_unverified !== undefined) { params.includeUnverified = args.include_unverified; } if (args.truncate_response !== undefined) { params.truncateResponse = args.truncate_response; } const response = await this.axiosInstance.get(`/breachedaccount/${encodeURIComponent(args.email)}`, { params }); if (!response.data || response.data.length === 0) { return { content: [ { type: "text", text: "Good news! This email address has not been found in any known data breaches.", }, ], }; } // Format the breach data for better readability const breaches = response.data; const breachCount = breaches.length; let summary = `⚠️ This email address was found in ${breachCount} data breach${breachCount > 1 ? 'es' : ''}.\n\n`; if (args.truncate_response) { // If truncated, just list the breach names summary += "Breaches: " + breaches.map((breach: any) => breach.Name).join(", "); } else { // Otherwise, provide detailed information summary += "Breach details:\n\n"; breaches.forEach((breach: any, index: number) => { summary += `${index + 1}. ${breach.Name} (${breach.BreachDate})\n`; summary += ` Domain: ${breach.Domain}\n`; summary += ` Description: ${breach.Description}\n`; summary += ` Compromised data: ${breach.DataClasses.join(", ")}\n`; if (index < breaches.length - 1) { summary += "\n"; } }); summary += "\nRecommendations:\n"; summary += "- Change your password for these services immediately\n"; summary += "- If you used the same password elsewhere, change those too\n"; summary += "- Enable two-factor authentication where available\n"; summary += "- Consider using a password manager"; } return { content: [ { type: "text", text: summary, }, ], }; }
  • Input schema defining the parameters for the check_email tool, including email (required), include_unverified, and truncate_response options.
    inputSchema: { type: "object", properties: { email: { type: "string", description: "Email address to check", }, include_unverified: { type: "boolean", description: "Include unverified breaches in the results", default: true, }, truncate_response: { type: "boolean", description: "Truncate the response to only include breach names", default: false, }, }, required: ["email"], },
  • src/index.ts:80-103 (registration)
    Registration of the check_email tool in the list of available tools returned by ListToolsRequestSchema.
    { name: "check_email", description: "Check if an email address has been found in data breaches", inputSchema: { type: "object", properties: { email: { type: "string", description: "Email address to check", }, include_unverified: { type: "boolean", description: "Include unverified breaches in the results", default: true, }, truncate_response: { type: "boolean", description: "Truncate the response to only include breach names", default: false, }, }, required: ["email"], }, },
  • Dispatch in the CallToolRequestSchema handler that routes check_email calls to the handleCheckEmail function.
    case "check_email": return await this.handleCheckEmail(request.params.arguments);
  • Special error handling for 404 responses specific to check_email, treating it as a successful 'no breaches found' result.
    if (error.response?.status === 404 && request.params.name === "check_email") { return { content: [ { type: "text", text: "Good news! This email address has not been found in any known data breaches.", }, ], }; }

Other Tools

Related 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/Cyreslab-AI/hibp-mcp-server'

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