Skip to main content
Glama

create_todo

Create and manage user-specific tasks by specifying a title and user ID, enabling structured task tracking and organization.

Instructions

创建待办事项

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
titleYes待办事项标题
userIdYes用户ID

Implementation Reference

  • The handler function for the create_todo tool. It destructures title and userId from args, checks if the user exists in testData.users, creates a new todo with incremental ID, appends to testData.todos and logs the action, then returns a success message with the new todo JSON.
    }, async (args) => { const { title, userId } = args; // 检查用户是否存在 const user = testData.users.find(u => u.id === userId); if (!user) { return { content: [{ type: "text", text: `❌ 错误: 用户ID ${userId} 不存在` }] }; } const newTodo = { id: Math.max(...testData.todos.map(t => t.id)) + 1, title, completed: false, userId }; testData.todos.push(newTodo); testData.logs.push(`创建待办事项: "${title}" (用户: ${user.name})`); return { content: [{ type: "text", text: `✅ 成功创建待办事项: ${JSON.stringify(newTodo, null, 2)}` }] }; });
  • Zod input schema defining title as string and userId as number with descriptions.
    title: z.string().describe("待办事项标题"), userId: z.number().describe("用户ID")
  • src/index.ts:145-145 (registration)
    The server.tool registration call for create_todo, specifying name, description, schema, and handler.
    server.tool("create_todo", "创建待办事项", {

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/small-tou/mcp-test'

If you have feedback or need assistance with the MCP directory API, please join our Discord server