Skip to main content
Glama

create_todo

Create new todo items with titles and optional descriptions to organize tasks and track progress through a complete todo management system.

Instructions

Create a new todo item

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
authTokenYesAuthentication token from Kinde
descriptionNoOptional description of the todo item
titleYesTitle of the todo item

Implementation Reference

  • Main execution logic for create_todo tool: authenticates user via token, checks creation quota using canCreateTodo helper, creates todo in DB if permitted, increments usage count, or prompts for details if no title provided.
    case 'create_todo': { // Try to get token from args or stored token let token = args?.authToken as string; if (!token) { token = getStoredToken() || ''; } if (!token) { return { content: [ { type: 'text', text: `❌ No authentication token found. Please:\n1. Type "login" to get the authentication URL\n2. Complete login at http://localhost:3000\n3. Copy your token and use "save_token" to store it\n4. Then try "create todo" again`, }, ], }; } const user = await verifyToken(token); if (!user) { return { content: [{ type: 'text', text: 'Error: Invalid authentication token' }], }; } // If title is provided, create the todo if (args?.title) { // Check if user can create more todos const { canCreate, reason } = await canCreateTodo(user.userId); if (!canCreate) { return { content: [{ type: 'text', text: `🚫 You have used up all your free todos.\n\n💳 Upgrade your plan to create more todos:\n🔗 https://learnflowai.kinde.com/portal` }], }; } const todoId = await sql` INSERT INTO todos (user_id, title, description, completed) VALUES (${user.userId}, ${args.title as string}, ${args.description as string || null}, ${args.completed as boolean || false}) RETURNING id `; // Update user's todo count await sql` INSERT INTO users (user_id, free_todos_used) VALUES (${user.userId}, 1) ON CONFLICT (user_id) DO UPDATE SET free_todos_used = users.free_todos_used + 1 `; return { content: [{ type: 'text', text: JSON.stringify({ success: true, todoId: todoId[0].id, message: 'Todo created successfully', title: args.title, description: args.description, completed: args.completed || false }, null, 2) }], }; } // If no title provided, ask for details return { content: [ { type: 'text', text: `📝 **Create New Todo**\n\nPlease provide the following details:\n\n1. **Title**: What is the title of your todo?\n2. **Description**: (Optional) What is the description?\n3. **Completed**: (Optional) Is it completed? (true/false)\n\nPlease respond with your answers in this format:\n\`\`\`\ntitle: Your todo title\ndescription: Your description (optional)\ncompleted: false (optional)\n\`\`\``, }, ], }; }
  • Input schema defining parameters for create_todo: authToken (opt), title (req), description (opt), completed (opt).
    inputSchema: { type: 'object', properties: { authToken: { type: 'string', description: 'Authentication token from Kinde (optional if saved)', }, title: { type: 'string', description: 'Title of the todo item', }, description: { type: 'string', description: 'Optional description of the todo item', }, completed: { type: 'boolean', description: 'Completion status of the todo', }, }, },
  • src/server.ts:284-308 (registration)
    Registration of the create_todo tool in the tools list returned by ListToolsRequestHandler.
    { name: 'create_todo', description: 'Create a new todo item with interactive prompts', inputSchema: { type: 'object', properties: { authToken: { type: 'string', description: 'Authentication token from Kinde (optional if saved)', }, title: { type: 'string', description: 'Title of the todo item', }, description: { type: 'string', description: 'Optional description of the todo item', }, completed: { type: 'boolean', description: 'Completion status of the todo', }, }, }, },
  • Helper function to check if the user can create more todos based on subscription status and free tier usage limits. Called from the handler.
    async function canCreateTodo(userId: string, accessToken?: string): Promise<{ canCreate: boolean; reason?: string }> { try { if (accessToken) { const billingStatus = await getKindeBillingStatus(userId, accessToken); return { canCreate: billingStatus.canCreate, reason: billingStatus.reason }; } // Fallback to local database check const subscription = await sql` SELECT * FROM users WHERE user_id = ${userId} `; if (subscription.length === 0) { return { canCreate: true }; } const userSub = subscription[0]; if (userSub.subscription_status === 'active') { return { canCreate: true }; } if (userSub.free_todos_used < 5) { return { canCreate: true }; } return { canCreate: false, reason: 'You have used all 5 free todos. Please upgrade to create more todos.' }; } catch (error) { console.error('Error checking subscription:', error); return { canCreate: false, reason: 'Error checking subscription status' }; } }

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/sholajegede/todo_mcp_server'

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