README
🚀 亚马逊认知服务MCP服务器
本项目是一个实现Model Context Protocol(MCP)协议的服务器,它可连接到AWS Cognito进行身份验证和用户管理。该服务器提供了一系列实用工具,能高效处理包括注册、登录、密码管理等在内的用户认证流程。
🚀 快速开始
✅ 先决条件
- 拥有配置了Cognito用户池的AWS账户。
- 安装Node.js 18或更高版本。
📦 安装指南
# 克隆仓库
git clone https://github.com/yourusername/mcp-server-aws-cognito.git
# 安装依赖项
cd mcp-server-aws-cognito
npm install
# 构建服务器
npm run build
⚙️ AWS Cognito配置
- 登录AWS控制台,导航至Amazon Cognito。
- 创建新的用户池或使用现有的用户池。
- 记录下您的用户池ID和应用程序客户端ID。
- 将这些值设置为环境变量或在.env文件中(仅当您使用Claude代码时需要.env文件,而不是Claude桌面):
AWS_COGNITO_USER_POOL_ID=your-user-pool-id
AWS_COGNITO_USER_POOL_CLIENT_ID=your-app-client-id
✨ 主要特性
🛠️ 可用工具
| 属性 | 详情 |
|------|------|
| 工具名称 | 描述 |
| sign_up | 注册新用户 |
| sign_up_confirm_code_from_email | 使用确认代码验证账户 |
| sign_in | 身份验证用户 |
| sign_out | 退出当前用户 |
| getCurrentUser | 获取当前已登录的用户 |
| reset_password_send_code | 请求重置密码代码 |
| reset_password_veryify_code | 使用验证代码重置密码 |
| change_password | 更改当前用户的密码 |
| refresh_session | 刷新身份验证令牌 |
| update_user_attributes | 更新用户配置文件属性 |
| delete_user | 删除当前已登录的用户 |
| resend_confirmation_code | 重新发送账户验证代码 |
| verify_software_token | 验证TOTP进行双重身份验证 |
| 参数 | 详情 |
|------|------|
| sign_up | email: string, password: string |
| sign_up_confirm_code_from_email | username: string, confirmationCode: string |
| sign_in | username: string, password: string |
| sign_out | 无 |
| getCurrentUser | 无 |
| reset_password_send_code | username: string |
| reset_password_veryify_code | username: string, code: string, newPassword: string |
| change_password | oldPassword: string, newPassword: string |
| refresh_session | 无 |
| update_user_attributes | attributes: Array of {name: string, value: string} |
| delete_user | 无 |
| resend_confirmation_code | username: string |
| verify_software_token | username: string, totpCode: string |
Inspector将在您的浏览器中提供一个URL来访问调试工具。
💻 使用示例
🖥️ 使用Claude Desktop
在使用之前,请确保Node.js已安装在您的桌面上,以便npx正常工作。
- 转到:设置 > 开发者 > 编辑配置。
- 将以下内容添加到
claude_desktop_config.json:
{
"mcpServers": {
"aws-cognito-mcp-server": {
"command": "/path/to/mcp-server-aws-cognito/build/index.js",
"env": {
"AWS_COGNITO_USER_POOL_ID": "your-user-pool-id",
"AWS_COGNITO_USER_POOL_CLIENT_ID": "your-app-client-id"
}
}
}
}
📄 使用Claude Code
Claude Code是Claude的命令行界面。要使用此MCP服务器与Claude Code一起使用:
- 按照Claude Code文档中的说明安装Claude Code。
- 将MCP服务器添加到Claude Code:
claude mcp add "aws-cognito-mcp" npx tsx index.ts
- 验证是否已添加:
claude mcp list
- 使用您的MCP服务器运行Claude:
claude
🔧 技术细节
💻 开发
使用自动重建进行开发:
npm run watch
🐞 调试
由于MCP服务器通过stdio通信,调试可能具有挑战性。使用MCP Inspector获得更好的可见性:
npm run inspector
现在您可以使用AWS Cognito身份验证工具与Claude一起工作!
微信扫一扫