feat(ops): add read-only comment listing
This commit is contained in:
@@ -103,3 +103,51 @@ test("tasker_audit_comments rejects pages above the incident-response bound", as
|
||||
)
|
||||
);
|
||||
});
|
||||
|
||||
test("tasker_list_comments is read-only and forwards stable paging arguments", async () => {
|
||||
const tool = getToolsForSession(session).find((candidate) => candidate.name === "tasker_list_comments");
|
||||
assert.ok(tool);
|
||||
assert.equal(tool.annotations?.readOnlyHint, true);
|
||||
assert.deepEqual(tool.inputSchema.required, ["issue_id", "project_id"]);
|
||||
|
||||
const forwarded: unknown[] = [];
|
||||
const taskerClient = new TaskerClient({ baseUrl: "http://tasker.test", internalAccessToken: "test" });
|
||||
taskerClient.listComments = async (...args) => {
|
||||
forwarded.push(args);
|
||||
return { ok: true, comments: [{ id: "comment-1", body: "anchor" }], total_count: 1 };
|
||||
};
|
||||
|
||||
const result = await executeMcpTool(
|
||||
session,
|
||||
"tasker_list_comments",
|
||||
{
|
||||
issue_id: "issue-1",
|
||||
project_id: "project-1",
|
||||
workspace_slug: "nodedc",
|
||||
order: "desc",
|
||||
offset: 25,
|
||||
limit: 50,
|
||||
},
|
||||
{ taskerClient }
|
||||
);
|
||||
|
||||
assert.deepEqual(forwarded, [
|
||||
[
|
||||
session,
|
||||
"issue-1",
|
||||
{
|
||||
issue_id: "issue-1",
|
||||
project_id: "project-1",
|
||||
workspace_slug: "nodedc",
|
||||
order: "desc",
|
||||
offset: 25,
|
||||
limit: 50,
|
||||
},
|
||||
],
|
||||
]);
|
||||
assert.deepEqual(result.structuredContent, {
|
||||
ok: true,
|
||||
comments: [{ id: "comment-1", body: "anchor" }],
|
||||
total_count: 1,
|
||||
});
|
||||
});
|
||||
|
||||
@@ -176,6 +176,23 @@ export const mcpRuntimeTools: McpToolRuntimeDefinition[] = [
|
||||
},
|
||||
annotations: { readOnlyHint: true },
|
||||
},
|
||||
{
|
||||
name: "tasker_list_comments",
|
||||
title: "NODE.DC Ops: List Card Comments",
|
||||
description:
|
||||
"Direct NODE.DC Ops MCP read-only tool. Page through active comments on one granted Tasker/Ops card in stable chronological or reverse-chronological order.",
|
||||
requiredScopes: ["issue:read"],
|
||||
inputSchema: {
|
||||
...projectAndIssueInputSchema,
|
||||
properties: {
|
||||
...projectAndIssueInputSchema.properties,
|
||||
order: { type: "string", enum: ["asc", "desc"], default: "asc" },
|
||||
offset: { type: "integer", minimum: 0, maximum: 1000000, default: 0 },
|
||||
limit: { type: "integer", minimum: 1, maximum: 500, default: 100 },
|
||||
},
|
||||
},
|
||||
annotations: { readOnlyHint: true },
|
||||
},
|
||||
{
|
||||
name: "tasker_create_issue",
|
||||
title: "NODE.DC Ops: Create Card",
|
||||
@@ -384,6 +401,11 @@ const issueArgsSchema = z.object({
|
||||
project_id: z.string().min(1),
|
||||
workspace_slug: z.string().min(1).nullish(),
|
||||
});
|
||||
const listCommentsArgsSchema = issueArgsSchema.extend({
|
||||
order: z.enum(["asc", "desc"]).default("asc"),
|
||||
offset: z.number().int().min(0).max(1_000_000).default(0),
|
||||
limit: z.number().int().min(1).max(500).default(100),
|
||||
});
|
||||
const updateIssueArgsSchema = issueArgsSchema.extend({
|
||||
title: z.string().min(1).max(500).optional(),
|
||||
description: z.string().max(20000).optional(),
|
||||
@@ -532,6 +554,11 @@ async function executeMcpToolOnce(
|
||||
requireToolAccess(session, "issue:read", input.project_id, input.workspace_slug);
|
||||
return asToolResult(await deps.taskerClient.auditComments(session, input));
|
||||
}
|
||||
case "tasker_list_comments": {
|
||||
const input = listCommentsArgsSchema.parse(args);
|
||||
requireToolAccess(session, "issue:read", input.project_id, input.workspace_slug);
|
||||
return asToolResult(await deps.taskerClient.listComments(session, input.issue_id, input));
|
||||
}
|
||||
case "tasker_create_issue": {
|
||||
const input = createIssueArgsSchema.parse(args);
|
||||
requireToolAccess(session, "issue:create", input.project_id, input.workspace_slug);
|
||||
|
||||
@@ -134,6 +134,29 @@ export async function registerToolRoutes(app: FastifyInstance, deps: ToolRouteDe
|
||||
return result.structuredContent;
|
||||
});
|
||||
|
||||
app.get("/api/v1/tools/issues/:issueId/comments", async (request) => {
|
||||
const session = await authenticateAgent(request, deps);
|
||||
const params = request.params as { issueId: string };
|
||||
const query = request.query as {
|
||||
project_id?: string;
|
||||
workspace_slug?: string;
|
||||
order?: "asc" | "desc";
|
||||
offset?: number;
|
||||
limit?: number;
|
||||
};
|
||||
const result = await executeMcpTool(
|
||||
session,
|
||||
"tasker_list_comments",
|
||||
{
|
||||
...query,
|
||||
issue_id: params.issueId,
|
||||
},
|
||||
deps,
|
||||
toolOptions(request)
|
||||
);
|
||||
return result.structuredContent;
|
||||
});
|
||||
|
||||
app.patch("/api/v1/tools/issues/:issueId/comments/:commentId", async (request) => {
|
||||
const session = await authenticateAgent(request, deps);
|
||||
const params = request.params as { issueId: string; commentId: string };
|
||||
|
||||
@@ -86,6 +86,14 @@ export type AuditCommentsInput = {
|
||||
limit?: number;
|
||||
};
|
||||
|
||||
export type ListCommentsInput = {
|
||||
project_id: string;
|
||||
workspace_slug?: string | null;
|
||||
order?: "asc" | "desc";
|
||||
offset?: number;
|
||||
limit?: number;
|
||||
};
|
||||
|
||||
export type SetLabelsInput = {
|
||||
project_id: string;
|
||||
workspace_slug?: string | null;
|
||||
@@ -225,6 +233,25 @@ export class TaskerClient {
|
||||
);
|
||||
}
|
||||
|
||||
async listComments(session: AgentSessionRecord, issueId: string, input: ListCommentsInput): Promise<unknown> {
|
||||
const searchParams = new URLSearchParams({ project_id: input.project_id });
|
||||
|
||||
if (input.workspace_slug) {
|
||||
searchParams.set("workspace_slug", input.workspace_slug);
|
||||
}
|
||||
searchParams.set("order", input.order ?? "asc");
|
||||
searchParams.set("offset", String(input.offset ?? 0));
|
||||
searchParams.set("limit", String(input.limit ?? 100));
|
||||
|
||||
return this.request(
|
||||
`/api/internal/nodedc/agent/issues/${encodeURIComponent(issueId)}/comments?${searchParams.toString()}`,
|
||||
{
|
||||
method: "GET",
|
||||
session,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
async setLabels(session: AgentSessionRecord, issueId: string, input: SetLabelsInput): Promise<unknown> {
|
||||
return this.request(`/api/internal/nodedc/agent/issues/${encodeURIComponent(issueId)}/labels`, {
|
||||
method: "PUT",
|
||||
|
||||
Reference in New Issue
Block a user