// src/tools.ts
export interface Tool {
name: string;
description: string;
parameters: Record<string, { type: string; description: string }>;
}
export const tools: Tool[] = [
{
name: 'users:list',
description: 'Get a list of users',
parameters: {
limit: { type: 'number', description: 'Maximum users to return' },
},
},
{
name: 'users:get',
description: 'Get a specific user by ID',
parameters: {
id: { type: 'string', description: 'User ID' },
},
},
{
name: 'email:send',
description: 'Send an email to a user',
parameters: {
to: { type: 'string', description: 'Recipient email' },
subject: { type: 'string', description: 'Email subject' },
body: { type: 'string', description: 'Email body' },
},
},
];
// Tool implementations (mock for this example)
export async function executeTool(name: string, args: Record<string, unknown>) {
switch (name) {
case 'users:list':
return [
{ id: '1', name: 'Alice', email: 'alice@example.com' },
{ id: '2', name: 'Bob', email: 'bob@example.com' },
].slice(0, (args.limit as number) || 10);
case 'users:get':
return { id: args.id, name: 'Alice', email: 'alice@example.com' };
case 'email:send':
console.log(`[Mock] Sending email to ${args.to}`);
return { sent: true, messageId: 'msg-123' };
default:
throw new Error(`Unknown tool: ${name}`);
}
}