Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Give your AI coding agents full visibility into your CI test results. The Curren
| `currents-list-pull-requests` | List pull-request cards for a project (runs grouped by meta.pr.id). |
| `currents-list-project-terms` | List cursor-paginated project terms for one type (tag, branch, authorName, etc.). |
| `currents-create-jira-issue` | Create a Jira issue from a run test using the organization Jira integration. |
| `currents-link-jira-issue` | Link an existing Jira issue to a run test using the organization Jira integration. |
| `currents-list-jira-projects` | List Jira projects available for the organization integration. |
| `currents-list-jira-issue-types` | List Jira issue types and custom fields for a Jira project. |
| `currents-get-runs` | Retrieves a list of runs for a specific project with optional filtering. |
Expand Down
6 changes: 6 additions & 0 deletions mcp-server/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## Unreleased (2026-06-12)

### Added

- MCP tool `currents-link-jira-issue` for `POST /projects/{projectId}/jira/issues/{jiraIssueKey}/link` (link an existing Jira issue to a run test).

## Unreleased (2026-05-27)

### Added
Expand Down
11 changes: 11 additions & 0 deletions mcp-server/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { updateActionTool } from "./tools/actions/update-action.js";
import { getContextTool } from "./tools/context/get-context.js";
// Integrations tools
import { createJiraIssueFromRunTestTool } from "./tools/integrations/create-jira-issue.js";
import { linkJiraIssueFromRunTestTool } from "./tools/integrations/link-jira-issue.js";
import { listJiraIssueTypesTool } from "./tools/integrations/list-jira-issue-types.js";
import { listJiraProjectsTool } from "./tools/integrations/list-jira-projects.js";
// Projects tools
Expand Down Expand Up @@ -233,6 +234,16 @@ server.registerTool(
createJiraIssueFromRunTestTool.handler,
);

server.registerTool(
"currents-link-jira-issue",
{
description:
"Link an existing Jira issue to a run test using the organization Jira integration. Requires projectId, jiraIssueKey, runId, testId, jiraInstallationId, jiraProjectId, and jiraIssueType. Optional comment and includeContextInComment.",
inputSchema: linkJiraIssueFromRunTestTool.schema,
},
linkJiraIssueFromRunTestTool.handler,
);

server.registerTool(
"currents-list-jira-projects",
{
Expand Down
69 changes: 69 additions & 0 deletions mcp-server/src/tools/integrations/link-jira-issue.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import { describe, expect, it, vi } from "vitest";
import * as request from "../../lib/request.js";
import { linkJiraIssueFromRunTestTool } from "./link-jira-issue.js";

describe("linkJiraIssueFromRunTestTool", () => {
it("calls POST /projects/{projectId}/jira/issues/{jiraIssueKey}/link with required body fields", async () => {
vi.spyOn(request, "postApi").mockResolvedValue({ status: "OK", data: {} });

await linkJiraIssueFromRunTestTool.handler({
projectId: "p1",
jiraIssueKey: "PROJ-42",
runId: "run-1",
testId: "test-1",
jiraInstallationId: "inst-1",
jiraProjectId: "10000",
jiraIssueType: "10001",
});

expect(request.postApi).toHaveBeenCalledWith(
"/projects/p1/jira/issues/PROJ-42/link",
{
runId: "run-1",
testId: "test-1",
jiraInstallationId: "inst-1",
jiraProjectId: "10000",
jiraIssueType: "10001",
}
);
});

it("includes optional comment and includeContextInComment in request body", async () => {
vi.spyOn(request, "postApi").mockResolvedValue({ status: "OK", data: {} });

await linkJiraIssueFromRunTestTool.handler({
projectId: "p1",
jiraIssueKey: "PROJ-42",
runId: "run-1",
testId: "test-1",
jiraInstallationId: "inst-1",
jiraProjectId: "10000",
jiraIssueType: "10001",
comment: "Manual note",
includeContextInComment: false,
});

expect(request.postApi).toHaveBeenCalledWith(
"/projects/p1/jira/issues/PROJ-42/link",
expect.objectContaining({
comment: "Manual note",
includeContextInComment: false,
})
);
});

it("schema requires comment when includeContextInComment is false", () => {
const result = linkJiraIssueFromRunTestTool.schema.safeParse({
projectId: "p1",
jiraIssueKey: "PROJ-42",
runId: "run-1",
testId: "test-1",
jiraInstallationId: "inst-1",
jiraProjectId: "10000",
jiraIssueType: "10001",
includeContextInComment: false,
});

expect(result.success).toBe(false);
});
});
89 changes: 89 additions & 0 deletions mcp-server/src/tools/integrations/link-jira-issue.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
import { z } from "zod";
import { postApi } from "../../lib/request.js";
import { logger } from "../../lib/logger.js";

const zodSchema = z
.object({
projectId: z.string().describe("Currents project ID."),
jiraIssueKey: z
.string()
.min(1)
.describe("Existing Jira issue key to link (e.g. PROJ-123)."),
runId: z.string().min(1).describe("Currents run ID containing the test."),
testId: z.string().min(1).describe("Test ID within the run."),
jiraInstallationId: z
.string()
.min(1)
.describe("Jira installation ID for the org integration (dashboard Installation ID)."),
jiraProjectId: z.string().min(1).describe("Jira project ID for the linked issue."),
jiraIssueType: z
.string()
.min(1)
.describe("Jira issue type identifier stored on the Currents ticket."),
comment: z
.string()
.optional()
.describe(
"Optional text prepended to the Jira comment and Currents issue description before automated test context."
),
includeContextInComment: z
.boolean()
.optional()
.describe(
"When true (default), appends automated test context to the Jira comment. When false, comment is required and used alone."
),
})
.superRefine((val, ctx) => {
if (val.includeContextInComment === false && !val.comment?.trim()) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
message: "comment is required when includeContextInComment is false",
path: ["comment"],
});
}
});

const handler = async ({
projectId,
jiraIssueKey,
runId,
testId,
jiraInstallationId,
jiraProjectId,
jiraIssueType,
comment,
includeContextInComment,
}: z.infer<typeof zodSchema>) => {
const body: Record<string, unknown> = {
runId,
testId,
jiraInstallationId,
jiraProjectId,
jiraIssueType,
};
if (comment !== undefined) {
body.comment = comment;
}
if (includeContextInComment !== undefined) {
body.includeContextInComment = includeContextInComment;
}

const path = `/projects/${encodeURIComponent(projectId)}/jira/issues/${encodeURIComponent(jiraIssueKey)}/link`;
logger.info(`Linking Jira issue: ${path}`);

const data = await postApi(path, body);
if (!data) {
return {
content: [{ type: "text" as const, text: "Failed to link Jira issue" }],
};
}

return {
content: [{ type: "text" as const, text: JSON.stringify(data, null, 2) }],
};
};

export const linkJiraIssueFromRunTestTool = {
schema: zodSchema,
handler,
};
Loading