@backendkit-labs/mcp-connectors 0.1.2 → 0.1.4
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/dist/ai-vault/server.d.ts +3 -0
- package/dist/ai-vault/server.d.ts.map +1 -0
- package/dist/ai-vault/server.js +9 -0
- package/dist/ai-vault/server.js.map +1 -0
- package/dist/ai-vault/tools.d.ts +35 -0
- package/dist/ai-vault/tools.d.ts.map +1 -0
- package/dist/ai-vault/tools.js +166 -0
- package/dist/ai-vault/tools.js.map +1 -0
- package/dist/gcal/server.js +2 -149
- package/dist/gcal/server.js.map +1 -1
- package/dist/gcal/tools.d.ts +3 -0
- package/dist/gcal/tools.d.ts.map +1 -0
- package/dist/gcal/tools.js +149 -0
- package/dist/gcal/tools.js.map +1 -0
- package/dist/hubspot/server.js +3 -118
- package/dist/hubspot/server.js.map +1 -1
- package/dist/hubspot/tools.d.ts +3 -0
- package/dist/hubspot/tools.d.ts.map +1 -0
- package/dist/hubspot/tools.js +117 -0
- package/dist/hubspot/tools.js.map +1 -0
- package/dist/jira/server.js +3 -117
- package/dist/jira/server.js.map +1 -1
- package/dist/jira/tools.d.ts +3 -0
- package/dist/jira/tools.d.ts.map +1 -0
- package/dist/jira/tools.js +114 -0
- package/dist/jira/tools.js.map +1 -0
- package/dist/odoo/server.js +2 -142
- package/dist/odoo/server.js.map +1 -1
- package/dist/odoo/tools.d.ts +3 -0
- package/dist/odoo/tools.d.ts.map +1 -0
- package/dist/odoo/tools.js +161 -0
- package/dist/odoo/tools.js.map +1 -0
- package/dist/shared/http-client.d.ts +14 -0
- package/dist/shared/http-client.d.ts.map +1 -0
- package/dist/shared/http-client.js +66 -0
- package/dist/shared/http-client.js.map +1 -0
- package/dist/shared/server-runner.d.ts +11 -1
- package/dist/shared/server-runner.d.ts.map +1 -1
- package/dist/shared/server-runner.js +51 -8
- package/dist/shared/server-runner.js.map +1 -1
- package/package.json +49 -35
package/dist/hubspot/server.js
CHANGED
|
@@ -1,130 +1,15 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
const mcp_js_1 = require("@modelcontextprotocol/sdk/server/mcp.js");
|
|
5
|
-
const zod_1 = require("zod");
|
|
6
4
|
const server_runner_js_1 = require("../shared/server-runner.js");
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
if (!TOKEN) {
|
|
5
|
+
const tools_js_1 = require("./tools.js");
|
|
6
|
+
if (!process.env.HUBSPOT_TOKEN) {
|
|
10
7
|
process.stderr.write('[bk-mcp-hubspot] HUBSPOT_TOKEN env var is required (HubSpot Private App token).\n');
|
|
11
8
|
process.exit(1);
|
|
12
9
|
}
|
|
13
|
-
const BASE = 'https://api.hubapi.com';
|
|
14
|
-
async function hs(method, path, body) {
|
|
15
|
-
const res = await fetch(`${BASE}${path}`, {
|
|
16
|
-
method,
|
|
17
|
-
headers: {
|
|
18
|
-
'Authorization': `Bearer ${TOKEN}`,
|
|
19
|
-
'Content-Type': 'application/json',
|
|
20
|
-
},
|
|
21
|
-
body: body !== undefined ? JSON.stringify(body) : undefined,
|
|
22
|
-
});
|
|
23
|
-
if (!res.ok) {
|
|
24
|
-
throw new Error(`HubSpot ${method} ${path.split('?')[0]} → ${res.status}: ${await res.text()}`);
|
|
25
|
-
}
|
|
26
|
-
return res.json();
|
|
27
|
-
}
|
|
28
|
-
// ── Tools ─────────────────────────────────────────────────────────────────────
|
|
29
|
-
function buildServer() {
|
|
30
|
-
const srv = new mcp_js_1.McpServer({ name: 'bk-mcp-hubspot', version: '0.1.0' });
|
|
31
|
-
// Cast to any to prevent TypeScript from attempting deep Zod schema inference
|
|
32
|
-
// during declaration emit — the MCP SDK validates schemas at runtime.
|
|
33
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
34
|
-
const t = srv.tool.bind(srv);
|
|
35
|
-
t('crm_search_contacts', 'Search HubSpot CRM contacts by name, email, or company.', {
|
|
36
|
-
query: zod_1.z.string().describe('Search term — name, email, or company'),
|
|
37
|
-
limit: zod_1.z.number().optional().describe('Max results (default 10)'),
|
|
38
|
-
}, async ({ query, limit }) => {
|
|
39
|
-
const data = await hs('POST', '/crm/v3/objects/contacts/search', {
|
|
40
|
-
query,
|
|
41
|
-
limit: limit ?? 10,
|
|
42
|
-
properties: ['firstname', 'lastname', 'email', 'phone', 'company'],
|
|
43
|
-
});
|
|
44
|
-
const lines = data.results.map(c => {
|
|
45
|
-
const p = c.properties;
|
|
46
|
-
return `ID:${c.id} ${p.firstname ?? ''} ${p.lastname ?? ''} <${p.email ?? ''}> ${p.company ?? ''} ${p.phone ?? ''}`.trim();
|
|
47
|
-
});
|
|
48
|
-
return {
|
|
49
|
-
content: [{ type: 'text', text: lines.length ? lines.join('\n') : 'No contacts found.' }],
|
|
50
|
-
};
|
|
51
|
-
});
|
|
52
|
-
t('crm_get_contact', 'Get full property details for a HubSpot contact by ID.', {
|
|
53
|
-
id: zod_1.z.string().describe('HubSpot contact ID'),
|
|
54
|
-
}, async ({ id }) => {
|
|
55
|
-
const props = 'firstname,lastname,email,phone,company,jobtitle,lifecyclestage,createdate,lastmodifieddate';
|
|
56
|
-
const data = await hs('GET', `/crm/v3/objects/contacts/${id}?properties=${props}`);
|
|
57
|
-
const lines = Object.entries(data.properties)
|
|
58
|
-
.filter(([, v]) => v)
|
|
59
|
-
.map(([k, v]) => `${k}: ${v}`);
|
|
60
|
-
return {
|
|
61
|
-
content: [{ type: 'text', text: `Contact ${id}\n${lines.join('\n')}` }],
|
|
62
|
-
};
|
|
63
|
-
});
|
|
64
|
-
t('crm_create_contact', 'Create a new contact in HubSpot CRM.', {
|
|
65
|
-
email: zod_1.z.string().describe('Email address (required)'),
|
|
66
|
-
firstname: zod_1.z.string().optional(),
|
|
67
|
-
lastname: zod_1.z.string().optional(),
|
|
68
|
-
phone: zod_1.z.string().optional(),
|
|
69
|
-
company: zod_1.z.string().optional(),
|
|
70
|
-
jobtitle: zod_1.z.string().optional(),
|
|
71
|
-
}, async (props) => {
|
|
72
|
-
const properties = {};
|
|
73
|
-
for (const [k, v] of Object.entries(props)) {
|
|
74
|
-
if (v)
|
|
75
|
-
properties[k] = v;
|
|
76
|
-
}
|
|
77
|
-
const data = await hs('POST', '/crm/v3/objects/contacts', { properties });
|
|
78
|
-
return { content: [{ type: 'text', text: `Created contact ID: ${data.id}` }] };
|
|
79
|
-
});
|
|
80
|
-
t('crm_search_deals', 'Search HubSpot CRM deals by name and/or deal stage.', {
|
|
81
|
-
query: zod_1.z.string().optional().describe('Deal name search term'),
|
|
82
|
-
stage: zod_1.z.string().optional().describe('Deal stage key (e.g. appointmentscheduled, closedwon)'),
|
|
83
|
-
limit: zod_1.z.number().optional().describe('Max results (default 10)'),
|
|
84
|
-
}, async ({ query, stage, limit }) => {
|
|
85
|
-
const body = {
|
|
86
|
-
limit: limit ?? 10,
|
|
87
|
-
properties: ['dealname', 'dealstage', 'amount', 'closedate'],
|
|
88
|
-
};
|
|
89
|
-
if (query)
|
|
90
|
-
body.query = query;
|
|
91
|
-
if (stage) {
|
|
92
|
-
body.filterGroups = [{
|
|
93
|
-
filters: [{ propertyName: 'dealstage', operator: 'EQ', value: stage }],
|
|
94
|
-
}];
|
|
95
|
-
}
|
|
96
|
-
const data = await hs('POST', '/crm/v3/objects/deals/search', body);
|
|
97
|
-
const lines = data.results.map(d => {
|
|
98
|
-
const p = d.properties;
|
|
99
|
-
return `ID:${d.id} ${p.dealname ?? ''} stage:${p.dealstage ?? ''} $${p.amount ?? '0'} close:${p.closedate?.slice(0, 10) ?? '-'}`;
|
|
100
|
-
});
|
|
101
|
-
return {
|
|
102
|
-
content: [{ type: 'text', text: lines.length ? lines.join('\n') : 'No deals found.' }],
|
|
103
|
-
};
|
|
104
|
-
});
|
|
105
|
-
t('crm_create_note', 'Log an activity note in HubSpot, optionally associated with a contact or deal.', {
|
|
106
|
-
body: zod_1.z.string().describe('Note text content'),
|
|
107
|
-
contact_id: zod_1.z.string().optional().describe('HubSpot contact ID to associate'),
|
|
108
|
-
deal_id: zod_1.z.string().optional().describe('HubSpot deal ID to associate'),
|
|
109
|
-
}, async ({ body, contact_id, deal_id }) => {
|
|
110
|
-
const associations = [];
|
|
111
|
-
if (contact_id) {
|
|
112
|
-
associations.push({ to: { id: contact_id }, types: [{ associationCategory: 'HUBSPOT_DEFINED', associationTypeId: 202 }] });
|
|
113
|
-
}
|
|
114
|
-
if (deal_id) {
|
|
115
|
-
associations.push({ to: { id: deal_id }, types: [{ associationCategory: 'HUBSPOT_DEFINED', associationTypeId: 214 }] });
|
|
116
|
-
}
|
|
117
|
-
const data = await hs('POST', '/crm/v3/objects/notes', {
|
|
118
|
-
properties: { hs_note_body: body, hs_timestamp: Date.now().toString() },
|
|
119
|
-
associations,
|
|
120
|
-
});
|
|
121
|
-
return { content: [{ type: 'text', text: `Created note ID: ${data.id}` }] };
|
|
122
|
-
});
|
|
123
|
-
return srv;
|
|
124
|
-
}
|
|
125
10
|
// ── Start ─────────────────────────────────────────────────────────────────────
|
|
126
11
|
const { httpMode, port } = (0, server_runner_js_1.parseCliArgs)();
|
|
127
|
-
(0, server_runner_js_1.runMcpServer)(buildServer, { httpMode, port, label: 'bk-mcp-hubspot' }).catch(err => {
|
|
12
|
+
(0, server_runner_js_1.runMcpServer)(tools_js_1.buildServer, { httpMode, port, label: 'bk-mcp-hubspot' }).catch(err => {
|
|
128
13
|
process.stderr.write(`[bk-mcp-hubspot] Fatal: ${err.message}\n`);
|
|
129
14
|
process.exit(1);
|
|
130
15
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/hubspot/server.ts"],"names":[],"mappings":";;;AACA,
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/hubspot/server.ts"],"names":[],"mappings":";;;AACA,iEAAwE;AACxE,yCAAyC;AAEzC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE,CAAC;IAC7B,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,mFAAmF,CAAC,CAAC;IAC1G,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACpB,CAAC;AAED,iFAAiF;AAEjF,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,IAAA,+BAAY,GAAE,CAAC;AAC1C,IAAA,+BAAY,EAAC,sBAAW,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,gBAAgB,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE;IAC/E,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,2BAA4B,GAAa,CAAC,OAAO,IAAI,CAAC,CAAC;IAC5E,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACpB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../src/hubspot/tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAsBpE,wBAAgB,WAAW,IAAI,SAAS,CAmIvC"}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildServer = buildServer;
|
|
4
|
+
const mcp_js_1 = require("@modelcontextprotocol/sdk/server/mcp.js");
|
|
5
|
+
const zod_1 = require("zod");
|
|
6
|
+
const http_client_js_1 = require("../shared/http-client.js");
|
|
7
|
+
// ── Auth ──────────────────────────────────────────────────────────────────────
|
|
8
|
+
const TOKEN = process.env.HUBSPOT_TOKEN;
|
|
9
|
+
const BASE = 'https://api.hubapi.com';
|
|
10
|
+
async function hs(method, path, body) {
|
|
11
|
+
return (0, http_client_js_1.fetchJson)('HubSpot', `${BASE}${path}`, {
|
|
12
|
+
method,
|
|
13
|
+
headers: {
|
|
14
|
+
'Authorization': `Bearer ${TOKEN}`,
|
|
15
|
+
'Content-Type': 'application/json',
|
|
16
|
+
},
|
|
17
|
+
body: body !== undefined ? JSON.stringify(body) : undefined,
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
// ── Tools ─────────────────────────────────────────────────────────────────────
|
|
21
|
+
function buildServer() {
|
|
22
|
+
const srv = new mcp_js_1.McpServer({ name: 'bk-mcp-hubspot', version: '0.1.0' });
|
|
23
|
+
// Cast to any to prevent TypeScript from attempting deep Zod schema inference
|
|
24
|
+
// during declaration emit — the MCP SDK validates schemas at runtime.
|
|
25
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
26
|
+
const t = srv.tool.bind(srv);
|
|
27
|
+
t('crm_search_contacts', 'Search HubSpot CRM contacts by name, email, or company.', {
|
|
28
|
+
query: zod_1.z.string().describe('Search term — name, email, or company'),
|
|
29
|
+
limit: zod_1.z.number().min(1).max(100).optional().describe('Max results (default 10, max 100)'),
|
|
30
|
+
}, async ({ query, limit }) => {
|
|
31
|
+
const data = await hs('POST', '/crm/v3/objects/contacts/search', {
|
|
32
|
+
query,
|
|
33
|
+
limit: limit ?? 10,
|
|
34
|
+
properties: ['firstname', 'lastname', 'email', 'phone', 'company'],
|
|
35
|
+
});
|
|
36
|
+
const lines = data.results.map(c => {
|
|
37
|
+
const p = c.properties;
|
|
38
|
+
return `ID:${c.id} ${p.firstname ?? ''} ${p.lastname ?? ''} <${p.email ?? ''}> ${p.company ?? ''} ${p.phone ?? ''}`.trim();
|
|
39
|
+
});
|
|
40
|
+
return {
|
|
41
|
+
content: [{ type: 'text', text: lines.length ? lines.join('\n') : 'No contacts found.' }],
|
|
42
|
+
};
|
|
43
|
+
});
|
|
44
|
+
t('crm_get_contact', 'Get full property details for a HubSpot contact by ID.', {
|
|
45
|
+
id: zod_1.z.string().describe('HubSpot contact ID'),
|
|
46
|
+
}, async ({ id }) => {
|
|
47
|
+
const props = 'firstname,lastname,email,phone,company,jobtitle,lifecyclestage,createdate,lastmodifieddate';
|
|
48
|
+
const data = await hs('GET', `/crm/v3/objects/contacts/${id}?properties=${props}`);
|
|
49
|
+
const lines = Object.entries(data.properties)
|
|
50
|
+
.filter(([, v]) => v)
|
|
51
|
+
.map(([k, v]) => `${k}: ${v}`);
|
|
52
|
+
return {
|
|
53
|
+
content: [{ type: 'text', text: `Contact ${id}\n${lines.join('\n')}` }],
|
|
54
|
+
};
|
|
55
|
+
});
|
|
56
|
+
t('crm_create_contact', 'Create a new contact in HubSpot CRM.', {
|
|
57
|
+
email: zod_1.z.string().describe('Email address (required)'),
|
|
58
|
+
firstname: zod_1.z.string().optional(),
|
|
59
|
+
lastname: zod_1.z.string().optional(),
|
|
60
|
+
phone: zod_1.z.string().optional(),
|
|
61
|
+
company: zod_1.z.string().optional(),
|
|
62
|
+
jobtitle: zod_1.z.string().optional(),
|
|
63
|
+
}, async (props) => {
|
|
64
|
+
const properties = {};
|
|
65
|
+
for (const [k, v] of Object.entries(props)) {
|
|
66
|
+
if (v)
|
|
67
|
+
properties[k] = v;
|
|
68
|
+
}
|
|
69
|
+
const data = await hs('POST', '/crm/v3/objects/contacts', { properties });
|
|
70
|
+
return { content: [{ type: 'text', text: `Created contact ID: ${data.id}` }] };
|
|
71
|
+
});
|
|
72
|
+
t('crm_search_deals', 'Search HubSpot CRM deals by name and/or deal stage.', {
|
|
73
|
+
query: zod_1.z.string().optional().describe('Deal name search term'),
|
|
74
|
+
stage: zod_1.z.string().optional().describe('Deal stage key (e.g. appointmentscheduled, closedwon)'),
|
|
75
|
+
limit: zod_1.z.number().min(1).max(100).optional().describe('Max results (default 10, max 100)'),
|
|
76
|
+
}, async ({ query, stage, limit }) => {
|
|
77
|
+
const body = {
|
|
78
|
+
limit: limit ?? 10,
|
|
79
|
+
properties: ['dealname', 'dealstage', 'amount', 'closedate'],
|
|
80
|
+
};
|
|
81
|
+
if (query)
|
|
82
|
+
body.query = query;
|
|
83
|
+
if (stage) {
|
|
84
|
+
body.filterGroups = [{
|
|
85
|
+
filters: [{ propertyName: 'dealstage', operator: 'EQ', value: stage }],
|
|
86
|
+
}];
|
|
87
|
+
}
|
|
88
|
+
const data = await hs('POST', '/crm/v3/objects/deals/search', body);
|
|
89
|
+
const lines = data.results.map(d => {
|
|
90
|
+
const p = d.properties;
|
|
91
|
+
return `ID:${d.id} ${p.dealname ?? ''} stage:${p.dealstage ?? ''} $${p.amount ?? '0'} close:${p.closedate?.slice(0, 10) ?? '-'}`;
|
|
92
|
+
});
|
|
93
|
+
return {
|
|
94
|
+
content: [{ type: 'text', text: lines.length ? lines.join('\n') : 'No deals found.' }],
|
|
95
|
+
};
|
|
96
|
+
});
|
|
97
|
+
t('crm_create_note', 'Log an activity note in HubSpot, optionally associated with a contact or deal.', {
|
|
98
|
+
body: zod_1.z.string().describe('Note text content'),
|
|
99
|
+
contact_id: zod_1.z.string().optional().describe('HubSpot contact ID to associate'),
|
|
100
|
+
deal_id: zod_1.z.string().optional().describe('HubSpot deal ID to associate'),
|
|
101
|
+
}, async ({ body, contact_id, deal_id }) => {
|
|
102
|
+
const associations = [];
|
|
103
|
+
if (contact_id) {
|
|
104
|
+
associations.push({ to: { id: contact_id }, types: [{ associationCategory: 'HUBSPOT_DEFINED', associationTypeId: 202 }] });
|
|
105
|
+
}
|
|
106
|
+
if (deal_id) {
|
|
107
|
+
associations.push({ to: { id: deal_id }, types: [{ associationCategory: 'HUBSPOT_DEFINED', associationTypeId: 214 }] });
|
|
108
|
+
}
|
|
109
|
+
const data = await hs('POST', '/crm/v3/objects/notes', {
|
|
110
|
+
properties: { hs_note_body: body, hs_timestamp: Date.now().toString() },
|
|
111
|
+
associations,
|
|
112
|
+
});
|
|
113
|
+
return { content: [{ type: 'text', text: `Created note ID: ${data.id}` }] };
|
|
114
|
+
});
|
|
115
|
+
return srv;
|
|
116
|
+
}
|
|
117
|
+
//# sourceMappingURL=tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.js","sourceRo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E,iBAAiB,EAAE,iBAAiB,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC;QAC5H,CAAC;QACD,MAAM,IAAI,GAAG,MAAM,EAAE,CAAiB,MAAM,EAAE,uBAAuB,EAAE;YACnE,UAAU,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,EAAE;YACvE,YAAY;SACf,CAAC,CAAC;QACH,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,oBAAoB,IAAI,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC;IACzF,CAAC,CACJ,CAAC;IAEF,OAAO,GAAG,CAAC;AACf,CAAC"}
|
package/dist/jira/server.js
CHANGED
|
@@ -1,130 +1,16 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
const mcp_js_1 = require("@modelcontextprotocol/sdk/server/mcp.js");
|
|
5
|
-
const zod_1 = require("zod");
|
|
6
4
|
const server_runner_js_1 = require("../shared/server-runner.js");
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
const EMAIL = process.env.JIRA_EMAIL;
|
|
10
|
-
const TOKEN = process.env.JIRA_TOKEN; // Jira API token (not password)
|
|
11
|
-
const missing = [!HOST && 'JIRA_HOST', !EMAIL && 'JIRA_EMAIL', !TOKEN && 'JIRA_TOKEN'].filter(Boolean);
|
|
5
|
+
const tools_js_1 = require("./tools.js");
|
|
6
|
+
const missing = [!process.env.JIRA_HOST && 'JIRA_HOST', !process.env.JIRA_EMAIL && 'JIRA_EMAIL', !process.env.JIRA_TOKEN && 'JIRA_TOKEN'].filter(Boolean);
|
|
12
7
|
if (missing.length) {
|
|
13
8
|
process.stderr.write(`[bk-mcp-jira] Missing env vars: ${missing.join(', ')}\n`);
|
|
14
9
|
process.exit(1);
|
|
15
10
|
}
|
|
16
|
-
const BASE = `https://${HOST}/rest/api/3`;
|
|
17
|
-
const AUTH = Buffer.from(`${EMAIL}:${TOKEN}`).toString('base64');
|
|
18
|
-
async function jira(method, path, body) {
|
|
19
|
-
const res = await fetch(`${BASE}${path}`, {
|
|
20
|
-
method,
|
|
21
|
-
headers: {
|
|
22
|
-
'Authorization': `Basic ${AUTH}`,
|
|
23
|
-
'Content-Type': 'application/json',
|
|
24
|
-
'Accept': 'application/json',
|
|
25
|
-
},
|
|
26
|
-
body: body !== undefined ? JSON.stringify(body) : undefined,
|
|
27
|
-
});
|
|
28
|
-
if (res.status === 204)
|
|
29
|
-
return undefined;
|
|
30
|
-
if (!res.ok) {
|
|
31
|
-
throw new Error(`Jira ${method} ${path.split('?')[0]} → ${res.status}: ${await res.text()}`);
|
|
32
|
-
}
|
|
33
|
-
return res.json();
|
|
34
|
-
}
|
|
35
|
-
function adfText(node) {
|
|
36
|
-
if (!node)
|
|
37
|
-
return '';
|
|
38
|
-
if (node.text)
|
|
39
|
-
return node.text;
|
|
40
|
-
if (!node.content)
|
|
41
|
-
return '';
|
|
42
|
-
const sep = node.type === 'paragraph' || node.type === 'doc' ? '\n' : '';
|
|
43
|
-
return node.content.map(adfText).join(sep);
|
|
44
|
-
}
|
|
45
|
-
function adfDoc(text) {
|
|
46
|
-
return {
|
|
47
|
-
type: 'doc', version: 1,
|
|
48
|
-
content: [{ type: 'paragraph', content: [{ type: 'text', text }] }],
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
// ── Tools ─────────────────────────────────────────────────────────────────────
|
|
52
|
-
function buildServer() {
|
|
53
|
-
const srv = new mcp_js_1.McpServer({ name: 'bk-mcp-jira', version: '0.1.0' });
|
|
54
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
55
|
-
const t = srv.tool.bind(srv);
|
|
56
|
-
t('jira_search', 'Search Jira issues using JQL (Jira Query Language). Returns key, summary, status, and assignee.', {
|
|
57
|
-
jql: zod_1.z.string().describe('JQL query (e.g. "project=PROJ AND status=\\"In Progress\\"")'),
|
|
58
|
-
limit: zod_1.z.number().optional().describe('Max results (default 20)'),
|
|
59
|
-
}, async ({ jql, limit }) => {
|
|
60
|
-
const data = await jira('GET', `/search?jql=${encodeURIComponent(jql)}&maxResults=${limit ?? 20}&fields=summary,status,assignee,priority`);
|
|
61
|
-
const lines = data.issues.map(i => {
|
|
62
|
-
const f = i.fields;
|
|
63
|
-
return `${i.key} [${f.status.name}] ${f.priority?.name ?? '-'} ${f.summary} @${f.assignee?.displayName ?? 'unassigned'}`;
|
|
64
|
-
});
|
|
65
|
-
return {
|
|
66
|
-
content: [{ type: 'text', text: lines.length ? lines.join('\n') : 'No issues found.' }],
|
|
67
|
-
};
|
|
68
|
-
});
|
|
69
|
-
t('jira_get_issue', 'Get full details for a Jira issue including description and recent comments.', {
|
|
70
|
-
key: zod_1.z.string().describe('Jira issue key (e.g. PROJ-123)'),
|
|
71
|
-
}, async ({ key }) => {
|
|
72
|
-
const data = await jira('GET', `/issue/${key}?fields=summary,status,assignee,description,comment`);
|
|
73
|
-
const f = data.fields;
|
|
74
|
-
const desc = adfText(f.description);
|
|
75
|
-
const comments = f.comment.comments.slice(-3).map(c => ` [${c.author.displayName} · ${c.created.slice(0, 10)}]: ${adfText(c.body)}`);
|
|
76
|
-
const parts = [
|
|
77
|
-
`${key}: ${f.summary}`,
|
|
78
|
-
`Status: ${f.status.name} Assignee: ${f.assignee?.displayName ?? 'unassigned'}`,
|
|
79
|
-
desc ? `\nDescription:\n${desc}` : '',
|
|
80
|
-
comments.length ? `\nComments (last ${comments.length}):\n${comments.join('\n')}` : '',
|
|
81
|
-
].filter(Boolean);
|
|
82
|
-
return { content: [{ type: 'text', text: parts.join('\n') }] };
|
|
83
|
-
});
|
|
84
|
-
t('jira_create_issue', 'Create a new Jira issue.', {
|
|
85
|
-
project: zod_1.z.string().describe('Project key (e.g. PROJ)'),
|
|
86
|
-
summary: zod_1.z.string().describe('Issue title/summary'),
|
|
87
|
-
description: zod_1.z.string().optional().describe('Issue description (plain text)'),
|
|
88
|
-
issue_type: zod_1.z.string().optional().describe('Issue type (e.g. Task, Bug, Story). Default: Task'),
|
|
89
|
-
priority: zod_1.z.string().optional().describe('Priority (e.g. High, Medium, Low)'),
|
|
90
|
-
}, async ({ project, summary, description, issue_type, priority }) => {
|
|
91
|
-
const fields = {
|
|
92
|
-
project: { key: project },
|
|
93
|
-
summary,
|
|
94
|
-
issuetype: { name: issue_type ?? 'Task' },
|
|
95
|
-
};
|
|
96
|
-
if (description)
|
|
97
|
-
fields.description = adfDoc(description);
|
|
98
|
-
if (priority)
|
|
99
|
-
fields.priority = { name: priority };
|
|
100
|
-
const data = await jira('POST', '/issue', { fields });
|
|
101
|
-
return { content: [{ type: 'text', text: `Created ${data.key} (ID: ${data.id})` }] };
|
|
102
|
-
});
|
|
103
|
-
t('jira_add_comment', 'Add a comment to a Jira issue.', {
|
|
104
|
-
key: zod_1.z.string().describe('Issue key (e.g. PROJ-123)'),
|
|
105
|
-
body: zod_1.z.string().describe('Comment text'),
|
|
106
|
-
}, async ({ key, body }) => {
|
|
107
|
-
await jira('POST', `/issue/${key}/comment`, { body: adfDoc(body) });
|
|
108
|
-
return { content: [{ type: 'text', text: `Comment added to ${key}.` }] };
|
|
109
|
-
});
|
|
110
|
-
t('jira_transition', 'Move a Jira issue to a new status (e.g. "In Progress", "Done").', {
|
|
111
|
-
key: zod_1.z.string().describe('Issue key (e.g. PROJ-123)'),
|
|
112
|
-
status: zod_1.z.string().describe('Target status name (e.g. Done, In Progress, To Do)'),
|
|
113
|
-
}, async ({ key, status }) => {
|
|
114
|
-
const { transitions } = await jira('GET', `/issue/${key}/transitions`);
|
|
115
|
-
const match = transitions.find(t => t.name.toLowerCase() === status.toLowerCase());
|
|
116
|
-
if (!match) {
|
|
117
|
-
const available = transitions.map(t => t.name).join(', ');
|
|
118
|
-
throw new Error(`Status "${status}" not available for ${key}. Options: ${available}`);
|
|
119
|
-
}
|
|
120
|
-
await jira('POST', `/issue/${key}/transitions`, { transition: { id: match.id } });
|
|
121
|
-
return { content: [{ type: 'text', text: `${key} → "${match.name}"` }] };
|
|
122
|
-
});
|
|
123
|
-
return srv;
|
|
124
|
-
}
|
|
125
11
|
// ── Start ─────────────────────────────────────────────────────────────────────
|
|
126
12
|
const { httpMode, port } = (0, server_runner_js_1.parseCliArgs)();
|
|
127
|
-
(0, server_runner_js_1.runMcpServer)(buildServer, { httpMode, port, label: 'bk-mcp-jira' }).catch(err => {
|
|
13
|
+
(0, server_runner_js_1.runMcpServer)(tools_js_1.buildServer, { httpMode, port, label: 'bk-mcp-jira' }).catch(err => {
|
|
128
14
|
process.stderr.write(`[bk-mcp-jira] Fatal: ${err.message}\n`);
|
|
129
15
|
process.exit(1);
|
|
130
16
|
});
|
package/dist/jira/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/jira/server.ts"],"names":[],"mappings":";;;AACA,
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/jira/server.ts"],"names":[],"mappings":";;;AACA,iEAAwE;AACxE,yCAAyC;AAEzC,MAAM,OAAO,GAAG,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,IAAI,WAAW,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,IAAI,YAAY,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,IAAI,YAAY,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;AAC1J,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IACjB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,mCAAmC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAChF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACpB,CAAC;AAED,iFAAiF;AAEjF,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,IAAA,+BAAY,GAAE,CAAC;AAC1C,IAAA,+BAAY,EAAC,sBAAW,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,aAAa,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE;IAC5E,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,wBAAyB,GAAa,CAAC,OAAO,IAAI,CAAC,CAAC;IACzE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACpB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../src/jira/tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AA2CpE,wBAAgB,WAAW,IAAI,SAAS,CA+HvC"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildServer = buildServer;
|
|
4
|
+
const mcp_js_1 = require("@modelcontextprotocol/sdk/server/mcp.js");
|
|
5
|
+
const zod_1 = require("zod");
|
|
6
|
+
const http_client_js_1 = require("../shared/http-client.js");
|
|
7
|
+
// ── Auth ──────────────────────────────────────────────────────────────────────
|
|
8
|
+
const HOST = process.env.JIRA_HOST; // e.g. mycompany.atlassian.net
|
|
9
|
+
const EMAIL = process.env.JIRA_EMAIL;
|
|
10
|
+
const TOKEN = process.env.JIRA_TOKEN; // Jira API token (not password)
|
|
11
|
+
const BASE = `https://${HOST}/rest/api/3`;
|
|
12
|
+
const AUTH = Buffer.from(`${EMAIL}:${TOKEN}`).toString('base64');
|
|
13
|
+
async function jira(method, path, body) {
|
|
14
|
+
return (0, http_client_js_1.fetchJson)('Jira', `${BASE}${path}`, {
|
|
15
|
+
method,
|
|
16
|
+
headers: {
|
|
17
|
+
'Authorization': `Basic ${AUTH}`,
|
|
18
|
+
'Content-Type': 'application/json',
|
|
19
|
+
'Accept': 'application/json',
|
|
20
|
+
},
|
|
21
|
+
body: body !== undefined ? JSON.stringify(body) : undefined,
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
function adfText(node) {
|
|
25
|
+
if (!node)
|
|
26
|
+
return '';
|
|
27
|
+
if (node.text)
|
|
28
|
+
return node.text;
|
|
29
|
+
if (!node.content)
|
|
30
|
+
return '';
|
|
31
|
+
const sep = node.type === 'paragraph' || node.type === 'doc' ? '\n' : '';
|
|
32
|
+
return node.content.map(adfText).join(sep);
|
|
33
|
+
}
|
|
34
|
+
function adfDoc(text) {
|
|
35
|
+
return {
|
|
36
|
+
type: 'doc', version: 1,
|
|
37
|
+
content: [{ type: 'paragraph', content: [{ type: 'text', text }] }],
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
// ── Tools ─────────────────────────────────────────────────────────────────────
|
|
41
|
+
function buildServer() {
|
|
42
|
+
const srv = new mcp_js_1.McpServer({ name: 'bk-mcp-jira', version: '0.1.0' });
|
|
43
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
44
|
+
const t = srv.tool.bind(srv);
|
|
45
|
+
t('jira_search', 'Search Jira issues using JQL (Jira Query Language). Returns key, summary, status, and assignee.', {
|
|
46
|
+
jql: zod_1.z.string().describe('JQL query (e.g. "project=PROJ AND status=\\"In Progress\\"")'),
|
|
47
|
+
limit: zod_1.z.number().min(1).max(100).optional().describe('Max results (default 20, max 100)'),
|
|
48
|
+
}, async ({ jql, limit }) => {
|
|
49
|
+
const data = await jira('GET', `/search?jql=${encodeURIComponent(jql)}&maxResults=${limit ?? 20}&fields=summary,status,assignee,priority`);
|
|
50
|
+
const lines = data.issues.map(i => {
|
|
51
|
+
const f = i.fields;
|
|
52
|
+
return `${i.key} [${f.status.name}] ${f.priority?.name ?? '-'} ${f.summary} @${f.assignee?.displayName ?? 'unassigned'}`;
|
|
53
|
+
});
|
|
54
|
+
return {
|
|
55
|
+
content: [{ type: 'text', text: lines.length ? lines.join('\n') : 'No issues found.' }],
|
|
56
|
+
};
|
|
57
|
+
});
|
|
58
|
+
t('jira_get_issue', 'Get full details for a Jira issue including description and recent comments.', {
|
|
59
|
+
key: zod_1.z.string().describe('Jira issue key (e.g. PROJ-123)'),
|
|
60
|
+
}, async ({ key }) => {
|
|
61
|
+
const data = await jira('GET', `/issue/${key}?fields=summary,status,assignee,description,comment`);
|
|
62
|
+
const f = data.fields;
|
|
63
|
+
const desc = adfText(f.description);
|
|
64
|
+
const comments = f.comment.comments.slice(-3).map(c => ` [${c.author.displayName} · ${c.created.slice(0, 10)}]: ${adfText(c.body)}`);
|
|
65
|
+
const parts = [
|
|
66
|
+
`${key}: ${f.summary}`,
|
|
67
|
+
`Status: ${f.status.name} Assignee: ${f.assignee?.displayName ?? 'unassigned'}`,
|
|
68
|
+
desc ? `\nDescription:\n${desc}` : '',
|
|
69
|
+
comments.length ? `\nComments (last ${comments.length}):\n${comments.join('\n')}` : '',
|
|
70
|
+
].filter(Boolean);
|
|
71
|
+
return { content: [{ type: 'text', text: parts.join('\n') }] };
|
|
72
|
+
});
|
|
73
|
+
t('jira_create_issue', 'Create a new Jira issue.', {
|
|
74
|
+
project: zod_1.z.string().describe('Project key (e.g. PROJ)'),
|
|
75
|
+
summary: zod_1.z.string().describe('Issue title/summary'),
|
|
76
|
+
description: zod_1.z.string().optional().describe('Issue description (plain text)'),
|
|
77
|
+
issue_type: zod_1.z.string().optional().describe('Issue type (e.g. Task, Bug, Story). Default: Task'),
|
|
78
|
+
priority: zod_1.z.string().optional().describe('Priority (e.g. High, Medium, Low)'),
|
|
79
|
+
}, async ({ project, summary, description, issue_type, priority }) => {
|
|
80
|
+
const fields = {
|
|
81
|
+
project: { key: project },
|
|
82
|
+
summary,
|
|
83
|
+
issuetype: { name: issue_type ?? 'Task' },
|
|
84
|
+
};
|
|
85
|
+
if (description)
|
|
86
|
+
fields.description = adfDoc(description);
|
|
87
|
+
if (priority)
|
|
88
|
+
fields.priority = { name: priority };
|
|
89
|
+
const data = await jira('POST', '/issue', { fields });
|
|
90
|
+
return { content: [{ type: 'text', text: `Created ${data.key} (ID: ${data.id})` }] };
|
|
91
|
+
});
|
|
92
|
+
t('jira_add_comment', 'Add a comment to a Jira issue.', {
|
|
93
|
+
key: zod_1.z.string().describe('Issue key (e.g. PROJ-123)'),
|
|
94
|
+
body: zod_1.z.string().describe('Comment text'),
|
|
95
|
+
}, async ({ key, body }) => {
|
|
96
|
+
await jira('POST', `/issue/${key}/comment`, { body: adfDoc(body) });
|
|
97
|
+
return { content: [{ type: 'text', text: `Comment added to ${key}.` }] };
|
|
98
|
+
});
|
|
99
|
+
t('jira_transition', 'Move a Jira issue to a new status (e.g. "In Progress", "Done").', {
|
|
100
|
+
key: zod_1.z.string().describe('Issue key (e.g. PROJ-123)'),
|
|
101
|
+
status: zod_1.z.string().describe('Target status name (e.g. Done, In Progress, To Do)'),
|
|
102
|
+
}, async ({ key, status }) => {
|
|
103
|
+
const { transitions } = await jira('GET', `/issue/${key}/transitions`);
|
|
104
|
+
const match = transitions.find(t => t.name.toLowerCase() === status.toLowerCase());
|
|
105
|
+
if (!match) {
|
|
106
|
+
const available = transitions.map(t => t.name).join(', ');
|
|
107
|
+
throw new Error(`Status "${status}" not available for ${key}. Options: ${available}`);
|
|
108
|
+
}
|
|
109
|
+
await jira('POST', `/issue/${key}/transitions`, { transition: { id: match.id } });
|
|
110
|
+
return { content: [{ type: 'text', text: `${key} → "${match.name}"` }] };
|
|
111
|
+
});
|
|
112
|
+
return srv;
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.js","sourceRoot":"","sources":["../../src/jira/tools.ts"],"names":[],"mappings":";;AA2CA,kCA+HC;AA1KD,oEAAoE;AACpE,6BAAwB;AACxB,6DAAqD;AAErD,iFAAiF;AAEjF,MAAM,IAAI,GAAI,OAAO,CAAC,GAAG,CAAC,SAAS,CA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