Skip to main content
Glama
turlockmike

MCP Rand

by turlockmike

generate_password

Create a strong, random password with customizable length using the MCP Rand server. This tool ensures a mix of character types for enhanced security while operating locally on your machine.

Instructions

Generate a strong password with a mix of character types. WARNING: While this password is generated locally on your machine, it is recommended to use a dedicated password manager for generating and storing passwords securely.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
lengthNoPassword length (minimum 8, default 16)

Implementation Reference

  • The handler function for the 'generate_password' tool. It extracts the optional length parameter, calls generateStrongPassword, and returns the generated password as tool result content.
    export const generatePasswordHandler = async (
      request: CallToolRequest
    ): Promise<CallToolResult> => {
      const args = request.params.arguments as { length?: number };
      const length = args.length ?? DEFAULT_LENGTH;
      
      const password = generateStrongPassword(length);
      
      return {
        content: [
          {
            type: 'text',
            text: password
          }
        ]
      };
    };
  • The tool specification (schema) defining the name, description, and input schema for the 'generate_password' tool.
    export const toolSpec = {
      name: 'generate_password',
      description: 'Generate a strong password with a mix of character types. WARNING: While this password is generated locally on your machine, it is recommended to use a dedicated password manager for generating and storing passwords securely.',
      inputSchema: {
        type: 'object' as const,
        properties: {
          length: {
            type: 'number',
            description: `Password length (minimum ${MIN_LENGTH}, default ${DEFAULT_LENGTH})`,
          }
        }
      }
    };
  • src/index.ts:23-23 (registration)
    Registers the 'generate_password' tool handler in the MCP server registry under the 'tools/call' method.
    registry.register('tools/call', 'generate_password', generatePasswordHandler as Handler);
  • Core helper function that implements the password generation logic, ensuring diversity and minimum length.
    function generateStrongPassword(length: number): string {
      if (length < MIN_LENGTH) {
        throw new McpError(
          ErrorCode.InvalidParams,
          `Password length must be at least ${MIN_LENGTH} characters`
        );
      }
    
      // Ensure at least one character from each set
      let password = '';
      password += charsets.uppercase[Math.floor(Math.random() * charsets.uppercase.length)];
      password += charsets.lowercase[Math.floor(Math.random() * charsets.lowercase.length)];
      password += charsets.numbers[Math.floor(Math.random() * charsets.numbers.length)];
      password += charsets.special[Math.floor(Math.random() * charsets.special.length)];
    
      // Fill the rest with random characters from all sets
      const allChars = Object.values(charsets).join('');
      while (password.length < length) {
        password += allChars[Math.floor(Math.random() * allChars.length)];
      }
    
      // Shuffle to avoid predictable pattern of character types
      return shuffleString(password);
    }
  • Helper function to shuffle the characters in the generated password for randomness.
    function shuffleString(str: string): string {
      const array = str.split('');
      for (let i = array.length - 1; i > 0; i--) {
        const j = Math.floor(Math.random() * (i + 1));
        [array[i], array[j]] = [array[j], array[i]];
      }
      return array.join('');
    }
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. It discloses that the password is 'generated locally on your machine,' which adds useful context about the tool's behavior and security implications. However, it doesn't cover other behavioral aspects like performance, error handling, or the specific character types used in the mix.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized with two sentences. The first sentence states the purpose clearly, and the second provides a security warning. While the warning is useful, it could be more front-loaded with tool-specific details, but overall it's efficient with minimal waste.

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 the tool's low complexity (one parameter, no output schema, no annotations), the description is somewhat complete but has gaps. It covers the basic purpose and a security note, but lacks details on output format (e.g., what the generated password looks like) and doesn't fully address behavioral context beyond the local generation aspect.

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 input schema has 100% description coverage, with the 'length' parameter documented as 'Password length (minimum 8, default 16).' The description adds no additional parameter information beyond what's in the schema, so it meets the baseline of 3 for high schema coverage without compensating value.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Generate a strong password with a mix of character types.' It specifies the verb ('generate') and resource ('password'), though it doesn't explicitly differentiate from sibling tools like 'generate_string' or 'generate_random_number' beyond the password-specific context.

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?

The description provides no guidance on when to use this tool versus alternatives. It includes a security warning about using a password manager, but this doesn't help the agent choose between this tool and siblings like 'generate_string' or 'generate_random_number' for password generation scenarios.

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/turlockmike/mcp-rand'

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