Skip to main content
Glama
gitCarrot

AWS Cognito MCP Server

by gitCarrot

reset_password_send_code

Initiate password reset by sending a verification code to the user's registered contact method, enabling secure account recovery.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
usernameYes

Implementation Reference

  • The main handler function for the 'reset_password_send_code' tool. It creates a CognitoUser instance for the given username and calls forgotPassword to send a password reset code. On success, it returns details about the delivery; on failure, it rejects with error information.
    async ({ username }) => { const cognitoUser = new CognitoUser({ Username: username, Pool: userPool, }); return new Promise((resolve, reject) => { cognitoUser.forgotPassword({ onSuccess: (data) => { console.log('Password reset request successful:', data); resolve({ content: [ { type: "text" as const, text: "Code sent successfully", }, { type: "text" as const, text: `Delivery method: ${data.CodeDeliveryDetails?.DeliveryMedium || 'Unknown'}`, }, { type: "text" as const, text: `Destination: ${data.CodeDeliveryDetails?.Destination || 'Unknown'}`, }, { type: "text" as const, text: `Attribute name: ${data.CodeDeliveryDetails?.AttributeName || 'Unknown'}`, } ] }); }, onFailure: (err) => { console.error('Password reset request failed:', err.message); reject({ content: [ { type: "text" as const, text: `Password reset request failed: ${err.message}`, }, { type: "text" as const, text: `Error code: ${(err as any).code || 'Unknown'}`, } ] }); }, }); }); }
  • Zod schema defining the input parameters for the tool: a required 'username' string.
    { username: z.string(), },
  • index.ts:280-334 (registration)
    The server.tool call that registers the 'reset_password_send_code' tool, including its name, input schema, and inline handler function.
    server.tool( "reset_password_send_code", { username: z.string(), }, async ({ username }) => { const cognitoUser = new CognitoUser({ Username: username, Pool: userPool, }); return new Promise((resolve, reject) => { cognitoUser.forgotPassword({ onSuccess: (data) => { console.log('Password reset request successful:', data); resolve({ content: [ { type: "text" as const, text: "Code sent successfully", }, { type: "text" as const, text: `Delivery method: ${data.CodeDeliveryDetails?.DeliveryMedium || 'Unknown'}`, }, { type: "text" as const, text: `Destination: ${data.CodeDeliveryDetails?.Destination || 'Unknown'}`, }, { type: "text" as const, text: `Attribute name: ${data.CodeDeliveryDetails?.AttributeName || 'Unknown'}`, } ] }); }, onFailure: (err) => { console.error('Password reset request failed:', err.message); reject({ content: [ { type: "text" as const, text: `Password reset request failed: ${err.message}`, }, { type: "text" as const, text: `Error code: ${(err as any).code || 'Unknown'}`, } ] }); }, }); }); } )

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/gitCarrot/mcp-server-aws-cognito'

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