Skip to main content
Glama
Cyreslab-AI

Have I Been Pwned MCP Server

check_password

Verify if a password has been exposed in data breaches using k-anonymity via the Have I Been Pwned API. Ensure account security by identifying compromised passwords.

Instructions

Check if a password has been exposed in data breaches (using k-anonymity)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
passwordYesPassword to check

Implementation Reference

  • The handler function that implements the core logic of the 'check_password' tool. It uses SHA-1 hashing and k-anonymity to query the Pwned Passwords API without sending the full password.
    private async handleCheckPassword(args: any) {
      if (!args.password || typeof args.password !== "string") {
        throw new McpError(
          ErrorCode.InvalidParams,
          "Password is required"
        );
      }
    
      // Hash the password with SHA-1
      const sha1Hash = crypto.createHash("sha1").update(args.password).digest("hex").toUpperCase();
    
      // Get the first 5 characters (prefix) and the rest (suffix)
      const prefix = sha1Hash.substring(0, 5);
      const suffix = sha1Hash.substring(5);
    
      // Query the API with just the prefix (k-anonymity)
      const response = await axios.get(`https://api.pwnedpasswords.com/range/${prefix}`);
    
      // Parse the response to find if our suffix is in the list
      const hashes = response.data.split("\n");
      let found = false;
      let occurrences = 0;
    
      for (const hash of hashes) {
        const [hashSuffix, count] = hash.split(":");
    
        if (hashSuffix.trim() === suffix) {
          found = true;
          occurrences = parseInt(count.trim(), 10);
          break;
        }
      }
    
      if (found) {
        return {
          content: [
            {
              type: "text",
              text: `⚠️ This password has been exposed in data breaches ${occurrences.toLocaleString()} times!\n\nRecommendations:\n- Stop using this password immediately\n- Change it on any site where you use it\n- Use a unique, strong password for each account\n- Consider using a password manager`,
            },
          ],
        };
      } else {
        return {
          content: [
            {
              type: "text",
              text: "Good news! This password hasn't been found in any known data breaches. However, remember to use strong, unique passwords for each account and consider using a password manager.",
            },
          ],
        };
      }
    }
  • The input schema defining the parameters for the 'check_password' tool (requires a 'password' string).
    inputSchema: {
      type: "object",
      properties: {
        password: {
          type: "string",
          description: "Password to check",
        },
      },
      required: ["password"],
    },
  • src/index.ts:104-117 (registration)
    Registration of the 'check_password' tool in the ListTools handler, including name, description, and schema.
    {
      name: "check_password",
      description: "Check if a password has been exposed in data breaches (using k-anonymity)",
      inputSchema: {
        type: "object",
        properties: {
          password: {
            type: "string",
            description: "Password to check",
          },
        },
        required: ["password"],
      },
    },
  • src/index.ts:167-168 (registration)
    Dispatch/registration in the CallToolRequestSchema switch statement that routes calls to the handleCheckPassword method.
    case "check_password":
      return await this.handleCheckPassword(request.params.arguments);
Behavior2/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 the method ('k-anonymity') but does not explain what this entails operationally, such as whether the password is sent in plaintext or hashed, any rate limits, privacy implications, or what the output looks like. This leaves significant gaps for a security-related tool.

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, efficient sentence that is front-loaded with the core purpose. There is no wasted verbiage, and every word contributes to understanding the tool's function, 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.

Completeness2/5

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

Given the complexity of a security tool with no annotations and no output schema, the description is incomplete. It fails to address critical behavioral aspects like data handling, error conditions, or result interpretation, which are essential for safe and effective use in this context.

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 description coverage is 100%, with the parameter 'password' clearly documented in the schema. The description adds no additional meaning beyond what the schema provides, such as format requirements or examples. Since the schema does the heavy lifting, the baseline score of 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 clearly states the specific action ('Check if a password has been exposed') and the resource ('in data breaches'), with the technical method ('using k-anonymity') distinguishing it from potential siblings like 'check_email' or 'list_all_breaches'. It uses a precise verb and specifies the domain of operation.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives like 'check_email' or 'get_breach_details'. The description lacks context about prerequisites, such as whether the password needs to be hashed or if there are rate limits, and does not mention any exclusions or complementary tools.

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

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