Skip to main content
Glama
gitCarrot

AWS Cognito MCP Server

by gitCarrot

change_password

Change your AWS Cognito user password by providing your current password and setting a new one for enhanced account security.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
newPasswordYes
oldPasswordYes

Implementation Reference

  • The handler function executes the password change logic using Amazon Cognito's changePassword method on the current user after checking the session.
    async ({ oldPassword, newPassword }) => { return new Promise((resolve, reject) => { const cognitoUser = userPool.getCurrentUser(); if (!cognitoUser) { resolve({ content: [ { type: "text" as const, text: "No user currently signed in", } ] }); return; } cognitoUser.getSession((err: Error | null, _session: CognitoUserSession) => { if (err) { reject({ content: [ { type: "text" as const, text: `Error getting session: ${err.message}`, } ] }); return; } cognitoUser.changePassword(oldPassword, newPassword, (err, result) => { if (err) { reject({ content: [ { type: "text" as const, text: `Failed to change password: ${err.message}`, }, { type: "text" as const, text: `Error code: ${(err as any).code || 'Unknown'}`, }, { type: "text" as const, text: `Time: ${new Date().toISOString()}`, } ] }); return; } resolve({ content: [ { type: "text" as const, text: "Password changed successfully", }, { type: "text" as const, text: `Username: ${cognitoUser.getUsername()}`, }, { type: "text" as const, text: `Result: ${result}`, }, { type: "text" as const, text: `Time: ${new Date().toISOString()}`, } ] }); }); }); }); } )
  • Zod schema defining input parameters: oldPassword and newPassword as strings.
    { oldPassword: z.string(), newPassword: z.string(), },
  • index.ts:463-543 (registration)
    The server.tool call that registers the change_password tool with its schema and handler.
    server.tool( "change_password", { oldPassword: z.string(), newPassword: z.string(), }, async ({ oldPassword, newPassword }) => { return new Promise((resolve, reject) => { const cognitoUser = userPool.getCurrentUser(); if (!cognitoUser) { resolve({ content: [ { type: "text" as const, text: "No user currently signed in", } ] }); return; } cognitoUser.getSession((err: Error | null, _session: CognitoUserSession) => { if (err) { reject({ content: [ { type: "text" as const, text: `Error getting session: ${err.message}`, } ] }); return; } cognitoUser.changePassword(oldPassword, newPassword, (err, result) => { if (err) { reject({ content: [ { type: "text" as const, text: `Failed to change password: ${err.message}`, }, { type: "text" as const, text: `Error code: ${(err as any).code || 'Unknown'}`, }, { type: "text" as const, text: `Time: ${new Date().toISOString()}`, } ] }); return; } resolve({ content: [ { type: "text" as const, text: "Password changed successfully", }, { type: "text" as const, text: `Username: ${cognitoUser.getUsername()}`, }, { type: "text" as const, text: `Result: ${result}`, }, { type: "text" as const, text: `Time: ${new Date().toISOString()}`, } ] }); }); }); }); } )

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