// src/tools/todos.ts
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { z } from "zod";
import { bcRequest } from "../lib/basecamp.js";
export function registerTodoTools(server: McpServer) {
server.registerTool(
"create_todo",
{
title: "Create a to-do",
description: "Create a new to-do in the given list.",
inputSchema: {
project_id: z.number().int(),
todolist_id: z.number().int(),
content: z.string(),
description: z.string().optional(),
due_on: z
.string()
.regex(/^\d{4}-\d{2}-\d{2}$/)
.optional(), // YYYY-MM-DD
},
},
async ({ project_id, todolist_id, content, description, due_on }) => {
const payload: any = { content };
if (description) payload.description = description;
if (due_on) payload.due_on = due_on;
const todo = await bcRequest<any>(
"POST",
`/buckets/${project_id}/todolists/${todolist_id}/todos.json`,
payload
);
return {
content: [
{
type: "text",
text: `Created to-do ${todo.id} in list ${todolist_id}.`,
},
],
};
}
);
}