Skip to main content
Glama
gitCarrot

AWS Cognito MCP Server

by gitCarrot

sign_in

Authenticate users with username and password credentials to access AWS Cognito protected applications and services.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
passwordYes
usernameYes

Implementation Reference

  • The handler function for the 'sign_in' tool. It authenticates the user using AWS Cognito by creating AuthenticationDetails and a CognitoUser instance, then calls authenticateUser. On success, it returns login success message with access, ID, and refresh tokens. On failure, it rejects with error message and code.
    async ({ username, password }) => { const authenticationDetails = new AuthenticationDetails({ Username: username, Password: password, }); const cognitoUser = new CognitoUser({ Username: username, Pool: userPool, }); return new Promise((resolve, reject) => { cognitoUser.authenticateUser(authenticationDetails, { onSuccess: (result) => { resolve({ content: [ { type: "text" as const, text: "Login successful", }, { type: "text" as const, text: `Access Token: ${result.getAccessToken().getJwtToken()}`, }, { type: "text" as const, text: `ID Token: ${result.getIdToken().getJwtToken()}`, }, { type: "text" as const, text: `Refresh Token: ${result.getRefreshToken().getToken()}`, } ] }); }, onFailure: (err) => { reject({ content: [ { type: "text" as const, text: `Login failed: ${err.message}`, }, { type: "text" as const, text: `Error code: ${(err as any).code || 'Unknown'}`, } ] }); }, }); }); }
  • Input schema for the 'sign_in' tool defined using Zod, requiring 'username' and 'password' as strings.
    { username: z.string(), password: z.string(), },
  • index.ts:221-278 (registration)
    Registration of the 'sign_in' tool using server.tool(), specifying the name, input schema, and handler function.
    server.tool( "sign_in", { username: z.string(), password: z.string(), }, async ({ username, password }) => { const authenticationDetails = new AuthenticationDetails({ Username: username, Password: password, }); const cognitoUser = new CognitoUser({ Username: username, Pool: userPool, }); return new Promise((resolve, reject) => { cognitoUser.authenticateUser(authenticationDetails, { onSuccess: (result) => { resolve({ content: [ { type: "text" as const, text: "Login successful", }, { type: "text" as const, text: `Access Token: ${result.getAccessToken().getJwtToken()}`, }, { type: "text" as const, text: `ID Token: ${result.getIdToken().getJwtToken()}`, }, { type: "text" as const, text: `Refresh Token: ${result.getRefreshToken().getToken()}`, } ] }); }, onFailure: (err) => { reject({ content: [ { type: "text" as const, text: `Login 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