add_user
Add new user records to the JSON database by providing required details like name, email, department, position, and join date. Supports optional fields for salary, skills, and contact information.
Instructions
Yeni kullanıcı ekler
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Kullanıcı adı | |
| Yes | E-posta adresi | ||
| department | Yes | Departman | |
| position | Yes | Pozisyon | |
| joinDate | Yes | İşe giriş tarihi (YYYY-MM-DD formatında) | |
| salary | No | Maaş (opsiyonel) | |
| birthDate | No | Doğum tarihi (YYYY-MM-DD formatında, opsiyonel) | |
| phone | No | Telefon numarası (opsiyonel) | |
| address | No | Adres (opsiyonel) | |
| skills | No | Yetenekler listesi (opsiyonel) |
Implementation Reference
- src/index.js:707-722 (handler)The core handler logic for the 'add_user' tool. It generates a new unique ID for the user using generateId, spreads the input arguments into the new user object, appends it to the database's users array, persists the database changes with writeDatabase, and returns a success response with the new user data.case 'add_user': { const newUser = { id: generateId(db.users), ...args }; db.users.push(newUser); await writeDatabase(db); return { content: [{ type: 'text', text: JSON.stringify({ success: true, user: newUser }) }] }; }
- src/index.js:258-273 (schema)The input schema definition for the 'add_user' tool, specifying properties, types, descriptions, and required fields for validation.inputSchema: { type: 'object', properties: { name: { type: 'string', description: 'Kullanıcı adı' }, email: { type: 'string', description: 'E-posta adresi' }, department: { type: 'string', description: 'Departman' }, position: { type: 'string', description: 'Pozisyon' }, joinDate: { type: 'string', description: 'İşe giriş tarihi (YYYY-MM-DD formatında)' }, salary: { type: 'number', description: 'Maaş (opsiyonel)' }, birthDate: { type: 'string', description: 'Doğum tarihi (YYYY-MM-DD formatında, opsiyonel)' }, phone: { type: 'string', description: 'Telefon numarası (opsiyonel)' }, address: { type: 'string', description: 'Adres (opsiyonel)' }, skills: { type: 'array', items: { type: 'string' }, description: 'Yetenekler listesi (opsiyonel)' } }, required: ['name', 'email', 'department', 'position', 'joinDate'] }
- src/index.js:255-274 (registration)The tool registration object in the ListTools response, including name, description, and inputSchema.{ name: 'add_user', description: 'Yeni kullanıcı ekler', inputSchema: { type: 'object', properties: { name: { type: 'string', description: 'Kullanıcı adı' }, email: { type: 'string', description: 'E-posta adresi' }, department: { type: 'string', description: 'Departman' }, position: { type: 'string', description: 'Pozisyon' }, joinDate: { type: 'string', description: 'İşe giriş tarihi (YYYY-MM-DD formatında)' }, salary: { type: 'number', description: 'Maaş (opsiyonel)' }, birthDate: { type: 'string', description: 'Doğum tarihi (YYYY-MM-DD formatında, opsiyonel)' }, phone: { type: 'string', description: 'Telefon numarası (opsiyonel)' }, address: { type: 'string', description: 'Adres (opsiyonel)' }, skills: { type: 'array', items: { type: 'string' }, description: 'Yetenekler listesi (opsiyonel)' } }, required: ['name', 'email', 'department', 'position', 'joinDate'] } },
- src/database.js:38-41 (helper)Utility function generateId used in the add_user handler to compute the next available user ID by finding the maximum existing ID and incrementing it.export function generateId(items) { if (!items || items.length === 0) return 1; return Math.max(...items.map(item => item.id)) + 1; }