register
Create a new user account in the MCP JSON Database Server by submitting name, email, password, department, position, and role details. Supports user management with secure JWT authentication.
Instructions
Yeni kullanıcı kaydı oluşturur
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| department | Yes | Departman | |
| Yes | E-posta adresi | ||
| name | Yes | Kullanıcı adı | |
| password | Yes | Şifre | |
| position | Yes | Pozisyon | |
| role | No | Kullanıcı rolü |
Implementation Reference
- src/index.js:371-413 (handler)Main handler for 'register' tool: checks for existing email, hashes password using auth.js function, generates ID using database.js, creates and saves new user to database, returns JSON success response with user info.case 'register': { const { name: userName, email, password, department, position, role = 'employee' } = args; // E-posta kontrolü const existingUser = db.users.find(u => u.email === email); if (existingUser) { return { content: [{ type: 'text', text: JSON.stringify({ success: false, message: 'Bu e-posta adresi zaten kayıtlı' }) }] }; } // Şifreyi hash'le const hashedPassword = await hashPassword(password); // Yeni kullanıcı oluştur const newUser = { id: generateId(db.users), name: userName, email, password: hashedPassword, department, position, role, joinDate: new Date().toISOString().split('T')[0] }; db.users.push(newUser); await writeDatabase(db); return { content: [{ type: 'text', text: JSON.stringify({ success: true, message: 'Kullanıcı başarıyla kaydedildi', user: { id: newUser.id, name: userName, email, role } }) }] }; }
- src/index.js:67-82 (schema)Input schema definition for 'register' tool specifying required fields and types for new user registration.inputSchema: { type: 'object', properties: { name: { type: 'string', description: 'Kullanıcı adı' }, email: { type: 'string', description: 'E-posta adresi' }, password: { type: 'string', description: 'Şifre' }, department: { type: 'string', description: 'Departman' }, position: { type: 'string', description: 'Pozisyon' }, role: { type: 'string', enum: ['admin', 'manager', 'employee'], description: 'Kullanıcı rolü' } }, required: ['name', 'email', 'password', 'department', 'position'] }
- src/index.js:64-83 (registration)Tool registration in ListToolsRequestSchema handler: defines name, description, and input schema for the 'register' tool.{ name: 'register', description: 'Yeni kullanıcı kaydı oluşturur', inputSchema: { type: 'object', properties: { name: { type: 'string', description: 'Kullanıcı adı' }, email: { type: 'string', description: 'E-posta adresi' }, password: { type: 'string', description: 'Şifre' }, department: { type: 'string', description: 'Departman' }, position: { type: 'string', description: 'Pozisyon' }, role: { type: 'string', enum: ['admin', 'manager', 'employee'], description: 'Kullanıcı rolü' } }, required: ['name', 'email', 'password', 'department', 'position'] } },