@vira_m/jira-mcp-server 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env.example +2 -0
- package/dist/index.js +42 -0
- package/package.json +21 -0
- package/src/index.ts +55 -0
- package/tsconfig.json +11 -0
package/.env.example
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
3
|
+
import axios from "axios";
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
const JIRA_BASE_URL = process.env.JIRA_BASE_URL;
|
|
6
|
+
const JIRA_PAT = process.env.JIRA_PAT;
|
|
7
|
+
if (!JIRA_BASE_URL || !JIRA_PAT) {
|
|
8
|
+
console.error("Missing JIRA_BASE_URL or JIRA_PAT environment variables");
|
|
9
|
+
process.exit(1);
|
|
10
|
+
}
|
|
11
|
+
const jira = axios.create({
|
|
12
|
+
baseURL: `${JIRA_BASE_URL}/rest/api/2`,
|
|
13
|
+
headers: {
|
|
14
|
+
Authorization: `Bearer ${JIRA_PAT}`,
|
|
15
|
+
"Content-Type": "application/json",
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
const server = new McpServer({
|
|
19
|
+
name: "jira-mcp-server",
|
|
20
|
+
version: "1.0.0",
|
|
21
|
+
});
|
|
22
|
+
server.tool("get_jira_issue", "Fetch a Jira issue by its key (e.g. PROJ-123)", { issue_key: z.string().describe("Jira issue key, e.g. PROJ-123") }, async ({ issue_key }) => {
|
|
23
|
+
const { data } = await jira.get(`/issue/${issue_key}`);
|
|
24
|
+
const f = data.fields;
|
|
25
|
+
const result = {
|
|
26
|
+
key: data.key,
|
|
27
|
+
summary: f.summary,
|
|
28
|
+
status: f.status?.name,
|
|
29
|
+
priority: f.priority?.name,
|
|
30
|
+
assignee: f.assignee?.displayName ?? null,
|
|
31
|
+
reporter: f.reporter?.displayName ?? null,
|
|
32
|
+
description: f.description ?? null,
|
|
33
|
+
labels: f.labels ?? [],
|
|
34
|
+
created: f.created,
|
|
35
|
+
updated: f.updated,
|
|
36
|
+
};
|
|
37
|
+
return {
|
|
38
|
+
content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
|
|
39
|
+
};
|
|
40
|
+
});
|
|
41
|
+
const transport = new StdioServerTransport();
|
|
42
|
+
await server.connect(transport);
|
package/package.json
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@vira_m/jira-mcp-server",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "MCP server for fetching Jira issues",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "tsc",
|
|
9
|
+
"start": "node dist/index.js",
|
|
10
|
+
"dev": "tsx src/index.ts"
|
|
11
|
+
},
|
|
12
|
+
"dependencies": {
|
|
13
|
+
"@modelcontextprotocol/sdk": "^1.0.0",
|
|
14
|
+
"axios": "^1.7.0"
|
|
15
|
+
},
|
|
16
|
+
"devDependencies": {
|
|
17
|
+
"@types/node": "^22.0.0",
|
|
18
|
+
"tsx": "^4.0.0",
|
|
19
|
+
"typescript": "^5.0.0"
|
|
20
|
+
}
|
|
21
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
3
|
+
import axios from "axios";
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
|
|
6
|
+
const JIRA_BASE_URL = process.env.JIRA_BASE_URL!;
|
|
7
|
+
const JIRA_PAT = process.env.JIRA_PAT!;
|
|
8
|
+
|
|
9
|
+
if (!JIRA_BASE_URL || !JIRA_PAT) {
|
|
10
|
+
console.error("Missing JIRA_BASE_URL or JIRA_PAT environment variables");
|
|
11
|
+
process.exit(1);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const jira = axios.create({
|
|
15
|
+
baseURL: `${JIRA_BASE_URL}/rest/api/2`,
|
|
16
|
+
headers: {
|
|
17
|
+
Authorization: `Bearer ${JIRA_PAT}`,
|
|
18
|
+
"Content-Type": "application/json",
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
const server = new McpServer({
|
|
23
|
+
name: "jira-mcp-server",
|
|
24
|
+
version: "1.0.0",
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
server.tool(
|
|
28
|
+
"get_jira_issue",
|
|
29
|
+
"Fetch a Jira issue by its key (e.g. PROJ-123)",
|
|
30
|
+
{ issue_key: z.string().describe("Jira issue key, e.g. PROJ-123") },
|
|
31
|
+
async ({ issue_key }) => {
|
|
32
|
+
const { data } = await jira.get(`/issue/${issue_key}`);
|
|
33
|
+
const f = data.fields;
|
|
34
|
+
|
|
35
|
+
const result = {
|
|
36
|
+
key: data.key,
|
|
37
|
+
summary: f.summary,
|
|
38
|
+
status: f.status?.name,
|
|
39
|
+
priority: f.priority?.name,
|
|
40
|
+
assignee: f.assignee?.displayName ?? null,
|
|
41
|
+
reporter: f.reporter?.displayName ?? null,
|
|
42
|
+
description: f.description ?? null,
|
|
43
|
+
labels: f.labels ?? [],
|
|
44
|
+
created: f.created,
|
|
45
|
+
updated: f.updated,
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
return {
|
|
49
|
+
content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
const transport = new StdioServerTransport();
|
|
55
|
+
await server.connect(transport);
|