Skip to content

armgit / kaneo

Public Imported from GitHub
0

⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.

feat(mcp): expose members, search, columns, time and activity tools

Andrej37b2fc3138c3
diff --git a/apps/api/src/mcp/tools.ts b/apps/api/src/mcp/tools.ts
index 0cc733ed5..1a0489023 100644
--- a/apps/api/src/mcp/tools.ts
+++ b/apps/api/src/mcp/tools.ts
@@ -738,4 +738,220 @@ export function registerMcpTools(
});
}),
);
+
+ registerTool(
+ "list_workspace_members",
+ {
+ description:
+ "List the members of a workspace. Use this to resolve the user ID an assignee tool expects.",
+ inputSchema: z.object({ workspaceId: nonEmptyString }),
+ },
+ async (args) =>
+ run(() =>
+ client.json(
+ `/api/workspace/${encodeURIComponent(args.workspaceId)}/members`,
+ ),
+ ),
+ );
+
+ registerTool(
+ "search",
+ {
+ description:
+ "Search across tasks, projects, workspaces, comments, and activities.",
+ inputSchema: z.object({
+ q: nonEmptyString.describe("Search query"),
+ type: z
+ .enum([
+ "all",
+ "tasks",
+ "projects",
+ "workspaces",
+ "comments",
+ "activities",
+ ])
+ .optional()
+ .describe("Restrict results to one kind. Defaults to all."),
+ workspaceId: optionalNonEmptyString.describe("Limit to one workspace"),
+ projectId: optionalNonEmptyString.describe("Limit to one project"),
+ limit: z
+ .number()
+ .int()
+ .min(1)
+ .max(50)
+ .optional()
+ .describe("Maximum results, 1 to 50. Defaults to 20."),
+ }),
+ },
+ async (args) => {
+ const qs = new URLSearchParams({ q: args.q });
+ if (args.type) qs.set("type", args.type);
+ if (args.workspaceId) qs.set("workspaceId", args.workspaceId);
+ if (args.projectId) qs.set("projectId", args.projectId);
+ if (args.limit !== undefined) qs.set("limit", String(args.limit));
+ return run(() => client.json(`/api/search?${qs.toString()}`));
+ },
+ );
+
+ registerTool(
+ "list_project_columns",
+ {
+ description:
+ "List a project's columns. Their slugs are the values update_task_status and create_task accept as a status.",
+ inputSchema: z.object({ projectId: nonEmptyString }),
+ },
+ async (args) =>
+ run(() =>
+ client.json(`/api/column/${encodeURIComponent(args.projectId)}`),
+ ),
+ );
+
+ registerTool(
+ "delete_task",
+ {
+ description: "Delete a task by ID.",
+ inputSchema: z.object({ taskId: nonEmptyString }),
+ },
+ async (args) =>
+ run(() =>
+ client.json(`/api/task/${encodeURIComponent(args.taskId)}`, {
+ method: "DELETE",
+ }),
+ ),
+ );
+
+ registerTool(
+ "update_task_assignee",
+ {
+ description:
+ "Assign a task to a workspace member, or pass a null userId to unassign it.",
+ inputSchema: z.object({
+ taskId: nonEmptyString,
+ userId: nonEmptyString
+ .nullable()
+ .describe("Member user ID, or null to unassign"),
+ }),
+ },
+ async (args) =>
+ run(() =>
+ client.json(`/api/task/assignee/${encodeURIComponent(args.taskId)}`, {
+ method: "PUT",
+ body: JSON.stringify({ userId: args.userId }),
+ }),
+ ),
+ );
+
+ registerTool(
+ "update_task_due_date",
+ {
+ description: "Set a task's due date. Omit dueDate to clear it.",
+ inputSchema: z.object({
+ taskId: nonEmptyString,
+ dueDate: optionalIsoDateTimeSchema,
+ }),
+ },
+ async (args) =>
+ run(() =>
+ client.json(`/api/task/due-date/${encodeURIComponent(args.taskId)}`, {
+ method: "PUT",
+ body: JSON.stringify(
+ args.dueDate === undefined ? {} : { dueDate: args.dueDate },
+ ),
+ }),
+ ),
+ );
+
+ registerTool(
+ "list_task_time_entries",
+ {
+ description: "List the time entries logged against a task.",
+ inputSchema: z.object({ taskId: nonEmptyString }),
+ },
+ async (args) =>
+ run(() =>
+ client.json(`/api/time-entry/task/${encodeURIComponent(args.taskId)}`),
+ ),
+ );
+
+ registerTool(
+ "get_time_entry",
+ {
+ description: "Get a single time entry by ID.",
+ inputSchema: z.object({ id: nonEmptyString }),
+ },
+ async (args) =>
+ run(() => client.json(`/api/time-entry/${encodeURIComponent(args.id)}`)),
+ );
+
+ registerTool(
+ "create_time_entry",
+ {
+ description:
+ "Log time against a task. Omit endTime to leave the entry running.",
+ inputSchema: z.object({
+ taskId: nonEmptyString,
+ startTime: isoDateTimeSchema,
+ endTime: optionalIsoDateTimeSchema,
+ description: optionalNonEmptyString,
+ }),
+ },
+ async (args) =>
+ run(() =>
+ client.json("/api/time-entry", {
+ method: "POST",
+ body: JSON.stringify({
+ taskId: args.taskId,
+ startTime: args.startTime,
+ ...(args.endTime ? { endTime: args.endTime } : {}),
+ ...(args.description ? { description: args.description } : {}),
+ }),
+ }),
+ ),
+ );
+
+ registerTool(
+ "update_time_entry",
+ {
+ description:
+ "Update a time entry. startTime is required; omit endTime to reopen the entry.",
+ inputSchema: z.object({
+ id: nonEmptyString,
+ startTime: isoDateTimeSchema,
+ endTime: optionalIsoDateTimeSchema,
+ description: optionalNonEmptyString,
+ }),
+ },
+ async (args) =>
+ run(() =>
+ client.json(`/api/time-entry/${encodeURIComponent(args.id)}`, {
+ method: "PUT",
+ body: JSON.stringify({
+ startTime: args.startTime,
+ ...(args.endTime ? { endTime: args.endTime } : {}),
+ ...(args.description ? { description: args.description } : {}),
+ }),
+ }),
+ ),
+ );
+
+ registerTool(
+ "list_task_activity",
+ {
+ description: "List a task's activity history.",
+ inputSchema: z.object({ taskId: nonEmptyString }),
+ },
+ async (args) =>
+ run(() =>
+ client.json(`/api/activity/${encodeURIComponent(args.taskId)}`),
+ ),
+ );
+
+ registerTool(
+ "list_notifications",
+ {
+ description: "List the signed-in user's notifications.",
+ inputSchema: z.object({}),
+ },
+ async () => run(() => client.json("/api/notification")),
+ );
}
diff --git a/apps/docs/core/integrations/mcp.mdx b/apps/docs/core/integrations/mcp.mdx
index 6310364be..055c90ba4 100644
--- a/apps/docs/core/integrations/mcp.mdx
+++ b/apps/docs/core/integrations/mcp.mdx
@@ -102,13 +102,21 @@ On the first tool call that needs Kaneo access, the MCP server:
Both the HTTP endpoint and stdio package expose the same tools:
-- Session: `whoami`, `list_workspaces`
-- Projects: `list_projects`, `get_project`, `create_project`, `update_project`
-- Tasks: `list_tasks`, `get_task`, `create_task`, `update_task`, `move_task`, `update_task_status`
+- Session: `whoami`, `list_workspaces`, `list_workspace_members`, `list_notifications`
+- Search: `search`
+- Projects: `list_projects`, `get_project`, `create_project`, `update_project`, `list_project_columns`
+- Tasks: `list_tasks`, `get_task`, `create_task`, `update_task`, `delete_task`, `move_task`, `update_task_status`, `update_task_assignee`, `update_task_due_date`, `list_task_activity`
+- Time entries: `list_task_time_entries`, `get_time_entry`, `create_time_entry`, `update_time_entry`
- Comments: `list_task_comments`, `create_task_comment`
- Labels: `list_workspace_labels`, `create_label`, `attach_label_to_task`, `detach_label_from_task`, `delete_label`
- Task relations: `create_task_relation`, `get_task_relations`, `delete_task_relation`
+`list_project_columns` is worth calling first when setting a status: the column
+slugs it returns are exactly the values `create_task` and `update_task_status`
+accept. Likewise `list_workspace_members` resolves the user IDs the assignee
+tools expect. Time entries have no delete endpoint on the API, so there is no
+`delete_time_entry` tool.
+
## Debugging
To run the stdio server directly:
diff --git a/packages/mcp/src/tools/register.ts b/packages/mcp/src/tools/register.ts
index 11a0a19e0..eb22462cb 100644
--- a/packages/mcp/src/tools/register.ts
+++ b/packages/mcp/src/tools/register.ts
@@ -567,4 +567,220 @@ export function registerTools(
});
}),
);
+
+ server.registerTool(
+ "list_workspace_members",
+ {
+ description:
+ "List the members of a workspace. Use this to resolve the user ID an assignee tool expects.",
+ inputSchema: z.object({ workspaceId: nonEmptyString }),
+ },
+ async (args) =>
+ run(() =>
+ client.json(
+ `/api/workspace/${encodeURIComponent(args.workspaceId)}/members`,
+ ),
+ ),
+ );
+
+ server.registerTool(
+ "search",
+ {
+ description:
+ "Search across tasks, projects, workspaces, comments, and activities.",
+ inputSchema: z.object({
+ q: nonEmptyString.describe("Search query"),
+ type: z
+ .enum([
+ "all",
+ "tasks",
+ "projects",
+ "workspaces",
+ "comments",
+ "activities",
+ ])
+ .optional()
+ .describe("Restrict results to one kind. Defaults to all."),
+ workspaceId: optionalNonEmptyString.describe("Limit to one workspace"),
+ projectId: optionalNonEmptyString.describe("Limit to one project"),
+ limit: z
+ .number()
+ .int()
+ .min(1)
+ .max(50)
+ .optional()
+ .describe("Maximum results, 1 to 50. Defaults to 20."),
+ }),
+ },
+ async (args) => {
+ const qs = new URLSearchParams({ q: args.q });
+ if (args.type) qs.set("type", args.type);
+ if (args.workspaceId) qs.set("workspaceId", args.workspaceId);
+ if (args.projectId) qs.set("projectId", args.projectId);
+ if (args.limit !== undefined) qs.set("limit", String(args.limit));
+ return run(() => client.json(`/api/search?${qs.toString()}`));
+ },
+ );
+
+ server.registerTool(
+ "list_project_columns",
+ {
+ description:
+ "List a project's columns. Their slugs are the values update_task_status and create_task accept as a status.",
+ inputSchema: z.object({ projectId: nonEmptyString }),
+ },
+ async (args) =>
+ run(() =>
+ client.json(`/api/column/${encodeURIComponent(args.projectId)}`),
+ ),
+ );
+
+ server.registerTool(
+ "delete_task",
+ {
+ description: "Delete a task by ID.",
+ inputSchema: z.object({ taskId: nonEmptyString }),
+ },
+ async (args) =>
+ run(() =>
+ client.json(`/api/task/${encodeURIComponent(args.taskId)}`, {
+ method: "DELETE",
+ }),
+ ),
+ );
+
+ server.registerTool(
+ "update_task_assignee",
+ {
+ description:
+ "Assign a task to a workspace member, or pass a null userId to unassign it.",
+ inputSchema: z.object({
+ taskId: nonEmptyString,
+ userId: nonEmptyString
+ .nullable()
+ .describe("Member user ID, or null to unassign"),
+ }),
+ },
+ async (args) =>
+ run(() =>
+ client.json(`/api/task/assignee/${encodeURIComponent(args.taskId)}`, {
+ method: "PUT",
+ body: JSON.stringify({ userId: args.userId }),
+ }),
+ ),
+ );
+
+ server.registerTool(
+ "update_task_due_date",
+ {
+ description: "Set a task's due date. Omit dueDate to clear it.",
+ inputSchema: z.object({
+ taskId: nonEmptyString,
+ dueDate: optionalIsoDateTimeSchema,
+ }),
+ },
+ async (args) =>
+ run(() =>
+ client.json(`/api/task/due-date/${encodeURIComponent(args.taskId)}`, {
+ method: "PUT",
+ body: JSON.stringify(
+ args.dueDate === undefined ? {} : { dueDate: args.dueDate },
+ ),
+ }),
+ ),
+ );
+
+ server.registerTool(
+ "list_task_time_entries",
+ {
+ description: "List the time entries logged against a task.",
+ inputSchema: z.object({ taskId: nonEmptyString }),
+ },
+ async (args) =>
+ run(() =>
+ client.json(`/api/time-entry/task/${encodeURIComponent(args.taskId)}`),
+ ),
+ );
+
+ server.registerTool(
+ "get_time_entry",
+ {
+ description: "Get a single time entry by ID.",
+ inputSchema: z.object({ id: nonEmptyString }),
+ },
+ async (args) =>
+ run(() => client.json(`/api/time-entry/${encodeURIComponent(args.id)}`)),
+ );
+
+ server.registerTool(
+ "create_time_entry",
+ {
+ description:
+ "Log time against a task. Omit endTime to leave the entry running.",
+ inputSchema: z.object({
+ taskId: nonEmptyString,
+ startTime: isoDateTimeSchema,
+ endTime: optionalIsoDateTimeSchema,
+ description: optionalNonEmptyString,
+ }),
+ },
+ async (args) =>
+ run(() =>
+ client.json("/api/time-entry", {
+ method: "POST",
+ body: JSON.stringify({
+ taskId: args.taskId,
+ startTime: args.startTime,
+ ...(args.endTime ? { endTime: args.endTime } : {}),
+ ...(args.description ? { description: args.description } : {}),
+ }),
+ }),
+ ),
+ );
+
+ server.registerTool(
+ "update_time_entry",
+ {
+ description:
+ "Update a time entry. startTime is required; omit endTime to reopen the entry.",
+ inputSchema: z.object({
+ id: nonEmptyString,
+ startTime: isoDateTimeSchema,
+ endTime: optionalIsoDateTimeSchema,
+ description: optionalNonEmptyString,
+ }),
+ },
+ async (args) =>
+ run(() =>
+ client.json(`/api/time-entry/${encodeURIComponent(args.id)}`, {
+ method: "PUT",
+ body: JSON.stringify({
+ startTime: args.startTime,
+ ...(args.endTime ? { endTime: args.endTime } : {}),
+ ...(args.description ? { description: args.description } : {}),
+ }),
+ }),
+ ),
+ );
+
+ server.registerTool(
+ "list_task_activity",
+ {
+ description: "List a task's activity history.",
+ inputSchema: z.object({ taskId: nonEmptyString }),
+ },
+ async (args) =>
+ run(() =>
+ client.json(`/api/activity/${encodeURIComponent(args.taskId)}`),
+ ),
+ );
+
+ server.registerTool(
+ "list_notifications",
+ {
+ description: "List the signed-in user's notifications.",
+ inputSchema: z.object({}),
+ },
+ async () => run(() => client.json("/api/notification")),
+ );
}
diff --git a/tests/api/mcp-tools.test.ts b/tests/api/mcp-tools.test.ts
new file mode 100644
index 000000000..27be87004
--- /dev/null
+++ b/tests/api/mcp-tools.test.ts
@@ -0,0 +1,209 @@
+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
+import {
+ type McpToolRegistrar,
+ registerMcpTools,
+} from "../../apps/api/src/mcp/tools";
+
+type ToolCallback = (args: unknown) => Promise<{
+ content: Array<{ text: string }>;
+ isError?: boolean;
+}>;
+
+function collectTools() {
+ const tools = new Map<string, ToolCallback>();
+ const registrar: McpToolRegistrar = {
+ registerTool: (name, _config, callback) => tools.set(name, callback),
+ };
+ registerMcpTools(registrar, "http://api.test", "test-token");
+ return tools;
+}
+
+const tools = collectTools();
+
+function call(name: string, args: unknown = {}) {
+ const tool = tools.get(name);
+ if (!tool) throw new Error(`Tool ${name} is not registered`);
+ return tool(args);
+}
+
+let apiFetch: ReturnType<typeof vi.fn>;
+
+beforeEach(() => {
+ apiFetch = vi.fn(async () => Response.json({ ok: true }));
+ vi.stubGlobal("fetch", apiFetch);
+});
+
+afterEach(() => {
+ vi.unstubAllGlobals();
+});
+
+function lastRequest() {
+ const [input, init] = apiFetch.mock.calls.at(-1) as [
+ RequestInfo | URL,
+ RequestInit | undefined,
+ ];
+ return {
+ url: String(input),
+ method: init?.method ?? "GET",
+ body: init?.body ? JSON.parse(String(init.body)) : undefined,
+ auth: new Headers(init?.headers).get("authorization"),
+ };
+}
+
+describe("MCP tool catalog", () => {
+ it("resolves workspace members", async () => {
+ await call("list_workspace_members", { workspaceId: "ws 1" });
+
+ const request = lastRequest();
+ expect(request.url).toBe("http://api.test/api/workspace/ws%201/members");
+ expect(request.auth).toBe("Bearer test-token");
+ });
+
+ it("passes only the search filters that were supplied", async () => {
+ await call("search", { q: "login bug" });
+ expect(lastRequest().url).toBe("http://api.test/api/search?q=login+bug");
+
+ await call("search", {
+ q: "login bug",
+ type: "tasks",
+ projectId: "p1",
+ limit: 5,
+ });
+ const url = new URL(lastRequest().url);
+ expect(Object.fromEntries(url.searchParams)).toEqual({
+ q: "login bug",
+ type: "tasks",
+ projectId: "p1",
+ limit: "5",
+ });
+ });
+
+ it("rejects a search limit above the API maximum", async () => {
+ const result = await call("search", { q: "x", limit: 500 });
+
+ expect(result.isError).toBe(true);
+ expect(apiFetch).not.toHaveBeenCalled();
+ });
+
+ it("lists the columns whose slugs are valid task statuses", async () => {
+ await call("list_project_columns", { projectId: "p1" });
+
+ expect(lastRequest().url).toBe("http://api.test/api/column/p1");
+ });
+
+ it("deletes a task", async () => {
+ await call("delete_task", { taskId: "t1" });
+
+ expect(lastRequest()).toMatchObject({
+ url: "http://api.test/api/task/t1",
+ method: "DELETE",
+ });
+ });
+
+ it("assigns and unassigns a task", async () => {
+ await call("update_task_assignee", { taskId: "t1", userId: "u1" });
+ expect(lastRequest()).toMatchObject({
+ url: "http://api.test/api/task/assignee/t1",
+ method: "PUT",
+ body: { userId: "u1" },
+ });
+
+ await call("update_task_assignee", { taskId: "t1", userId: null });
+ expect(lastRequest().body).toEqual({ userId: null });
+ });
+
+ it("rejects an empty assignee id rather than sending it", async () => {
+ const result = await call("update_task_assignee", {
+ taskId: "t1",
+ userId: "",
+ });
+
+ expect(result.isError).toBe(true);
+ expect(apiFetch).not.toHaveBeenCalled();
+ });
+
+ it("sets and clears a due date", async () => {
+ await call("update_task_due_date", {
+ taskId: "t1",
+ dueDate: "2026-09-01T10:00:00Z",
+ });
+ expect(lastRequest()).toMatchObject({
+ url: "http://api.test/api/task/due-date/t1",
+ method: "PUT",
+ body: { dueDate: "2026-09-01T10:00:00Z" },
+ });
+
+ await call("update_task_due_date", { taskId: "t1" });
+ expect(lastRequest().body).toEqual({});
+ });
+
+ it("rejects a due date that is not an ISO date-time", async () => {
+ const result = await call("update_task_due_date", {
+ taskId: "t1",
+ dueDate: "next tuesday",
+ });
+
+ expect(result.isError).toBe(true);
+ expect(apiFetch).not.toHaveBeenCalled();
+ });
+
+ it("reads time entries for a task and by id", async () => {
+ await call("list_task_time_entries", { taskId: "t1" });
+ expect(lastRequest().url).toBe("http://api.test/api/time-entry/task/t1");
+
+ await call("get_time_entry", { id: "te1" });
+ expect(lastRequest().url).toBe("http://api.test/api/time-entry/te1");
+ });
+
+ it("creates a running time entry when endTime is omitted", async () => {
+ await call("create_time_entry", {
+ taskId: "t1",
+ startTime: "2026-08-10T09:00:00Z",
+ });
+
+ expect(lastRequest()).toMatchObject({
+ url: "http://api.test/api/time-entry",
+ method: "POST",
+ body: { taskId: "t1", startTime: "2026-08-10T09:00:00Z" },
+ });
+ expect(lastRequest().body).not.toHaveProperty("endTime");
+ });
+
+ it("updates a time entry", async () => {
+ await call("update_time_entry", {
+ id: "te1",
+ startTime: "2026-08-10T09:00:00Z",
+ endTime: "2026-08-10T10:30:00Z",
+ description: "pairing",
+ });
+
+ expect(lastRequest()).toMatchObject({
+ url: "http://api.test/api/time-entry/te1",
+ method: "PUT",
+ body: {
+ startTime: "2026-08-10T09:00:00Z",
+ endTime: "2026-08-10T10:30:00Z",
+ description: "pairing",
+ },
+ });
+ });
+
+ it("reads task activity and notifications", async () => {
+ await call("list_task_activity", { taskId: "t1" });
+ expect(lastRequest().url).toBe("http://api.test/api/activity/t1");
+
+ await call("list_notifications");
+ expect(lastRequest().url).toBe("http://api.test/api/notification");
+ });
+
+ it("surfaces an API failure as a tool error", async () => {
+ apiFetch.mockResolvedValueOnce(
+ Response.json({ message: "Task not found" }, { status: 404 }),
+ );
+
+ const result = await call("delete_task", { taskId: "missing" });
+
+ expect(result.isError).toBe(true);
+ expect(result.content[0].text).toContain("Task not found");
+ });
+});