change_password
Update user password securely in the MCP JSON Database Server by providing current and new credentials with JWT authentication.
Instructions
Kullanıcı şifresini değiştirir
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"token": "<token>",
"oldPassword": "<oldPassword>",
"newPassword": "<newPassword>"
},
"name": "change_password"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| token | Yes | JWT token | |
| oldPassword | Yes | Mevcut şifre | |
| newPassword | Yes | Yeni şifre |
Implementation Reference
- src/index.js:501-546 (handler)The handler function for the 'change_password' tool. Verifies the user's token, checks the old password, hashes the new password using hashPassword, updates the user record in the database, and returns a JSON response indicating success or failure.
case 'change_password': { const { token, oldPassword, newPassword } = args; try { const decoded = verifyToken(token); const user = db.users.find(u => u.id === decoded.userId); if (!user) { return { content: [{ type: 'text', text: JSON.stringify({ success: false, message: 'Kullanıcı bulunamadı' }) }] }; } // Eski şifreyi kontrol et const isOldPasswordValid = await comparePassword(oldPassword, user.password); if (!isOldPasswordValid) { return { content: [{ type: 'text', text: JSON.stringify({ success: false, message: 'Mevcut şifre yanlış' }) }] }; } // Yeni şifreyi hash'le ve güncelle user.password = await hashPassword(newPassword); await writeDatabase(db); return { content: [{ type: 'text', text: JSON.stringify({ success: true, message: 'Şifre başarıyla değiştirildi' }) }] }; } catch (error) { return { content: [{ type: 'text', text: JSON.stringify({ success: false, message: error.message }) }] }; } } - src/index.js:108-119 (registration)Registration of the 'change_password' tool in the MCP tools array, including name, description, and input schema definition.
name: 'change_password', description: 'Kullanıcı şifresini değiştirir', inputSchema: { type: 'object', properties: { token: { type: 'string', description: 'JWT token' }, oldPassword: { type: 'string', description: 'Mevcut şifre' }, newPassword: { type: 'string', description: 'Yeni şifre' } }, required: ['token', 'oldPassword', 'newPassword'] } }, - src/index.js:110-118 (schema)Input schema definition for the change_password tool, specifying required fields: token, oldPassword, newPassword.
inputSchema: { type: 'object', properties: { token: { type: 'string', description: 'JWT token' }, oldPassword: { type: 'string', description: 'Mevcut şifre' }, newPassword: { type: 'string', description: 'Yeni şifre' } }, required: ['token', 'oldPassword', 'newPassword'] }