@verygoodplugins/mcp-freescout 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/.claude/commands/implement-freescout-ticket.md +422 -0
- package/.claude/mcp-freescout.code-workspace +7 -0
- package/.claude/settings.json +60 -0
- package/.gitattributes +2 -0
- package/LICENSE +674 -0
- package/README.md +477 -0
- package/dist/freescout-api.d.ts +18 -0
- package/dist/freescout-api.d.ts.map +1 -0
- package/dist/freescout-api.js +79 -0
- package/dist/freescout-api.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +604 -0
- package/dist/index.js.map +1 -0
- package/dist/ticket-analyzer.d.ts +15 -0
- package/dist/ticket-analyzer.d.ts.map +1 -0
- package/dist/ticket-analyzer.js +257 -0
- package/dist/ticket-analyzer.js.map +1 -0
- package/dist/types.d.ts +77 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +54 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,604 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
3
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
4
|
+
import { CallToolRequestSchema, ListToolsRequestSchema, } from '@modelcontextprotocol/sdk/types.js';
|
|
5
|
+
import { config } from 'dotenv';
|
|
6
|
+
import { execSync } from 'child_process';
|
|
7
|
+
import { FreeScoutAPI } from './freescout-api.js';
|
|
8
|
+
import { TicketAnalyzer } from './ticket-analyzer.js';
|
|
9
|
+
// Load environment variables
|
|
10
|
+
config();
|
|
11
|
+
// Validate required environment variables
|
|
12
|
+
const FREESCOUT_URL = process.env.FREESCOUT_URL;
|
|
13
|
+
const FREESCOUT_API_KEY = process.env.FREESCOUT_API_KEY;
|
|
14
|
+
const DEFAULT_USER_ID = parseInt(process.env.FREESCOUT_DEFAULT_USER_ID || '1');
|
|
15
|
+
// WORKING_DIRECTORY defaults to current working directory if not specified
|
|
16
|
+
// This allows the server to work with the current project context automatically
|
|
17
|
+
const WORKING_DIRECTORY = process.env.WORKING_DIRECTORY || process.cwd();
|
|
18
|
+
// Helper function to extract GitHub repo from git remote
|
|
19
|
+
function getGitHubRepo() {
|
|
20
|
+
if (process.env.GITHUB_REPO) {
|
|
21
|
+
return process.env.GITHUB_REPO;
|
|
22
|
+
}
|
|
23
|
+
try {
|
|
24
|
+
// Try to get the GitHub remote URL
|
|
25
|
+
const remoteUrl = execSync('git remote get-url origin 2>/dev/null', {
|
|
26
|
+
cwd: WORKING_DIRECTORY,
|
|
27
|
+
encoding: 'utf-8'
|
|
28
|
+
}).trim();
|
|
29
|
+
// Parse GitHub repo from various URL formats
|
|
30
|
+
// SSH: git@github.com:owner/repo.git
|
|
31
|
+
// HTTPS: https://github.com/owner/repo.git
|
|
32
|
+
// HTTPS no .git: https://github.com/owner/repo
|
|
33
|
+
let match = remoteUrl.match(/github\.com[:/]([^/]+\/[^/.]+)(\.git)?$/);
|
|
34
|
+
if (match) {
|
|
35
|
+
return match[1];
|
|
36
|
+
}
|
|
37
|
+
// Try without .git extension
|
|
38
|
+
match = remoteUrl.match(/github\.com[:/]([^/]+\/[^/]+)$/);
|
|
39
|
+
if (match) {
|
|
40
|
+
return match[1];
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
// Git command failed or no remote found
|
|
45
|
+
console.error('Could not auto-detect GitHub repository. Set GITHUB_REPO environment variable if needed.');
|
|
46
|
+
}
|
|
47
|
+
return undefined;
|
|
48
|
+
}
|
|
49
|
+
// Get GitHub configuration
|
|
50
|
+
const GITHUB_REPO = getGitHubRepo();
|
|
51
|
+
const GITHUB_TOKEN = process.env.GITHUB_TOKEN;
|
|
52
|
+
if (!FREESCOUT_URL || !FREESCOUT_API_KEY) {
|
|
53
|
+
console.error('Missing required environment variables: FREESCOUT_URL and FREESCOUT_API_KEY');
|
|
54
|
+
process.exit(1);
|
|
55
|
+
}
|
|
56
|
+
// Initialize API and analyzer
|
|
57
|
+
const api = new FreeScoutAPI(FREESCOUT_URL, FREESCOUT_API_KEY);
|
|
58
|
+
const analyzer = new TicketAnalyzer();
|
|
59
|
+
// Create MCP server
|
|
60
|
+
const server = new Server({
|
|
61
|
+
name: 'mcp-freescout',
|
|
62
|
+
version: '1.0.0',
|
|
63
|
+
}, {
|
|
64
|
+
capabilities: {
|
|
65
|
+
tools: {},
|
|
66
|
+
},
|
|
67
|
+
});
|
|
68
|
+
// Define tool schemas
|
|
69
|
+
const tools = [
|
|
70
|
+
{
|
|
71
|
+
name: 'freescout_get_ticket',
|
|
72
|
+
description: 'Fetch and analyze a FreeScout ticket by ID or URL',
|
|
73
|
+
inputSchema: {
|
|
74
|
+
type: 'object',
|
|
75
|
+
properties: {
|
|
76
|
+
ticket: {
|
|
77
|
+
type: 'string',
|
|
78
|
+
description: 'Ticket ID, ticket number, or FreeScout URL',
|
|
79
|
+
},
|
|
80
|
+
includeThreads: {
|
|
81
|
+
type: 'boolean',
|
|
82
|
+
description: 'Include all conversation threads (default: true)',
|
|
83
|
+
default: true,
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
required: ['ticket'],
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
name: 'freescout_analyze_ticket',
|
|
91
|
+
description: 'Analyze a FreeScout ticket to determine issue type, root cause, and suggested solution',
|
|
92
|
+
inputSchema: {
|
|
93
|
+
type: 'object',
|
|
94
|
+
properties: {
|
|
95
|
+
ticket: {
|
|
96
|
+
type: 'string',
|
|
97
|
+
description: 'Ticket ID, ticket number, or FreeScout URL',
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
required: ['ticket'],
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
name: 'freescout_add_note',
|
|
105
|
+
description: 'Add an internal note to a FreeScout ticket',
|
|
106
|
+
inputSchema: {
|
|
107
|
+
type: 'object',
|
|
108
|
+
properties: {
|
|
109
|
+
ticket: {
|
|
110
|
+
type: 'string',
|
|
111
|
+
description: 'Ticket ID, ticket number, or FreeScout URL',
|
|
112
|
+
},
|
|
113
|
+
note: {
|
|
114
|
+
type: 'string',
|
|
115
|
+
description: 'The note content to add',
|
|
116
|
+
},
|
|
117
|
+
userId: {
|
|
118
|
+
type: 'number',
|
|
119
|
+
description: 'User ID for the note (default: from env)',
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
required: ['ticket', 'note'],
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
name: 'freescout_update_ticket',
|
|
127
|
+
description: 'Update ticket status and/or assignment',
|
|
128
|
+
inputSchema: {
|
|
129
|
+
type: 'object',
|
|
130
|
+
properties: {
|
|
131
|
+
ticket: {
|
|
132
|
+
type: 'string',
|
|
133
|
+
description: 'Ticket ID, ticket number, or FreeScout URL',
|
|
134
|
+
},
|
|
135
|
+
status: {
|
|
136
|
+
type: 'string',
|
|
137
|
+
enum: ['active', 'pending', 'closed', 'spam'],
|
|
138
|
+
description: 'New ticket status',
|
|
139
|
+
},
|
|
140
|
+
assignTo: {
|
|
141
|
+
type: 'number',
|
|
142
|
+
description: 'User ID to assign the ticket to',
|
|
143
|
+
},
|
|
144
|
+
},
|
|
145
|
+
required: ['ticket'],
|
|
146
|
+
},
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
name: 'freescout_draft_reply',
|
|
150
|
+
description: 'Generate a draft customer reply based on ticket analysis',
|
|
151
|
+
inputSchema: {
|
|
152
|
+
type: 'object',
|
|
153
|
+
properties: {
|
|
154
|
+
ticket: {
|
|
155
|
+
type: 'string',
|
|
156
|
+
description: 'Ticket ID, ticket number, or FreeScout URL',
|
|
157
|
+
},
|
|
158
|
+
fixDescription: {
|
|
159
|
+
type: 'string',
|
|
160
|
+
description: 'Description of the fix or solution implemented',
|
|
161
|
+
},
|
|
162
|
+
isExplanatory: {
|
|
163
|
+
type: 'boolean',
|
|
164
|
+
description: 'Whether this is an explanatory reply (no code changes)',
|
|
165
|
+
default: false,
|
|
166
|
+
},
|
|
167
|
+
},
|
|
168
|
+
required: ['ticket'],
|
|
169
|
+
},
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
name: 'freescout_search_tickets',
|
|
173
|
+
description: 'Search for FreeScout tickets',
|
|
174
|
+
inputSchema: {
|
|
175
|
+
type: 'object',
|
|
176
|
+
properties: {
|
|
177
|
+
query: {
|
|
178
|
+
type: 'string',
|
|
179
|
+
description: 'Search query',
|
|
180
|
+
},
|
|
181
|
+
status: {
|
|
182
|
+
type: 'string',
|
|
183
|
+
enum: ['active', 'pending', 'closed', 'spam', 'all'],
|
|
184
|
+
description: 'Filter by status (default: all)',
|
|
185
|
+
},
|
|
186
|
+
},
|
|
187
|
+
required: ['query'],
|
|
188
|
+
},
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
name: 'git_create_worktree',
|
|
192
|
+
description: 'Create a Git worktree for working on a ticket',
|
|
193
|
+
inputSchema: {
|
|
194
|
+
type: 'object',
|
|
195
|
+
properties: {
|
|
196
|
+
ticketId: {
|
|
197
|
+
type: 'string',
|
|
198
|
+
description: 'Ticket ID for the worktree',
|
|
199
|
+
},
|
|
200
|
+
branchName: {
|
|
201
|
+
type: 'string',
|
|
202
|
+
description: 'Branch name (default: fix/freescout-{ticketId})',
|
|
203
|
+
},
|
|
204
|
+
baseBranch: {
|
|
205
|
+
type: 'string',
|
|
206
|
+
description: 'Base branch to create from (default: master)',
|
|
207
|
+
default: 'master',
|
|
208
|
+
},
|
|
209
|
+
},
|
|
210
|
+
required: ['ticketId'],
|
|
211
|
+
},
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
name: 'git_remove_worktree',
|
|
215
|
+
description: 'Remove a Git worktree after work is complete',
|
|
216
|
+
inputSchema: {
|
|
217
|
+
type: 'object',
|
|
218
|
+
properties: {
|
|
219
|
+
ticketId: {
|
|
220
|
+
type: 'string',
|
|
221
|
+
description: 'Ticket ID of the worktree to remove',
|
|
222
|
+
},
|
|
223
|
+
},
|
|
224
|
+
required: ['ticketId'],
|
|
225
|
+
},
|
|
226
|
+
},
|
|
227
|
+
{
|
|
228
|
+
name: 'github_create_pr',
|
|
229
|
+
description: 'Create a GitHub pull request for the current branch',
|
|
230
|
+
inputSchema: {
|
|
231
|
+
type: 'object',
|
|
232
|
+
properties: {
|
|
233
|
+
title: {
|
|
234
|
+
type: 'string',
|
|
235
|
+
description: 'PR title',
|
|
236
|
+
},
|
|
237
|
+
body: {
|
|
238
|
+
type: 'string',
|
|
239
|
+
description: 'PR description/body',
|
|
240
|
+
},
|
|
241
|
+
ticketId: {
|
|
242
|
+
type: 'string',
|
|
243
|
+
description: 'FreeScout ticket ID for reference',
|
|
244
|
+
},
|
|
245
|
+
branch: {
|
|
246
|
+
type: 'string',
|
|
247
|
+
description: 'Branch name (defaults to current branch)',
|
|
248
|
+
},
|
|
249
|
+
baseBranch: {
|
|
250
|
+
type: 'string',
|
|
251
|
+
description: 'Base branch (default: master)',
|
|
252
|
+
default: 'master',
|
|
253
|
+
},
|
|
254
|
+
draft: {
|
|
255
|
+
type: 'boolean',
|
|
256
|
+
description: 'Create as draft PR (default: false)',
|
|
257
|
+
default: false,
|
|
258
|
+
},
|
|
259
|
+
},
|
|
260
|
+
required: ['title', 'body'],
|
|
261
|
+
},
|
|
262
|
+
},
|
|
263
|
+
{
|
|
264
|
+
name: 'freescout_implement_ticket',
|
|
265
|
+
description: 'Full workflow: analyze ticket, create worktree, and prepare implementation plan',
|
|
266
|
+
inputSchema: {
|
|
267
|
+
type: 'object',
|
|
268
|
+
properties: {
|
|
269
|
+
ticket: {
|
|
270
|
+
type: 'string',
|
|
271
|
+
description: 'Ticket ID, ticket number, or FreeScout URL',
|
|
272
|
+
},
|
|
273
|
+
additionalContext: {
|
|
274
|
+
type: 'string',
|
|
275
|
+
description: 'Additional context or suggestions for implementation',
|
|
276
|
+
},
|
|
277
|
+
autoCreateWorktree: {
|
|
278
|
+
type: 'boolean',
|
|
279
|
+
description: 'Automatically create Git worktree (default: true)',
|
|
280
|
+
default: true,
|
|
281
|
+
},
|
|
282
|
+
},
|
|
283
|
+
required: ['ticket'],
|
|
284
|
+
},
|
|
285
|
+
},
|
|
286
|
+
];
|
|
287
|
+
// Handle list tools request
|
|
288
|
+
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
289
|
+
return {
|
|
290
|
+
tools,
|
|
291
|
+
};
|
|
292
|
+
});
|
|
293
|
+
// Handle tool execution
|
|
294
|
+
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
295
|
+
const { name, arguments: args } = request.params || {};
|
|
296
|
+
if (!args) {
|
|
297
|
+
throw new Error('Arguments are missing');
|
|
298
|
+
}
|
|
299
|
+
try {
|
|
300
|
+
switch (name) {
|
|
301
|
+
case 'freescout_get_ticket': {
|
|
302
|
+
const ticketId = api.parseTicketInput(args.ticket);
|
|
303
|
+
const conversation = await api.getConversation(ticketId, args.includeThreads !== false);
|
|
304
|
+
return {
|
|
305
|
+
content: [
|
|
306
|
+
{
|
|
307
|
+
type: 'text',
|
|
308
|
+
text: JSON.stringify(conversation, null, 2),
|
|
309
|
+
},
|
|
310
|
+
],
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
case 'freescout_analyze_ticket': {
|
|
314
|
+
const ticketId = api.parseTicketInput(args.ticket);
|
|
315
|
+
const conversation = await api.getConversation(ticketId, true);
|
|
316
|
+
const analysis = analyzer.analyzeConversation(conversation);
|
|
317
|
+
return {
|
|
318
|
+
content: [
|
|
319
|
+
{
|
|
320
|
+
type: 'text',
|
|
321
|
+
text: JSON.stringify(analysis, null, 2),
|
|
322
|
+
},
|
|
323
|
+
],
|
|
324
|
+
};
|
|
325
|
+
}
|
|
326
|
+
case 'freescout_add_note': {
|
|
327
|
+
const ticketId = api.parseTicketInput(args.ticket);
|
|
328
|
+
const userId = args.userId || DEFAULT_USER_ID;
|
|
329
|
+
const thread = await api.addThread(ticketId, 'note', args.note, userId);
|
|
330
|
+
return {
|
|
331
|
+
content: [
|
|
332
|
+
{
|
|
333
|
+
type: 'text',
|
|
334
|
+
text: `Note added to ticket #${ticketId}`,
|
|
335
|
+
},
|
|
336
|
+
],
|
|
337
|
+
};
|
|
338
|
+
}
|
|
339
|
+
case 'freescout_update_ticket': {
|
|
340
|
+
const ticketId = api.parseTicketInput(args.ticket);
|
|
341
|
+
const updates = {
|
|
342
|
+
byUser: DEFAULT_USER_ID,
|
|
343
|
+
};
|
|
344
|
+
if (args.status) {
|
|
345
|
+
updates.status = args.status;
|
|
346
|
+
}
|
|
347
|
+
if (args.assignTo) {
|
|
348
|
+
updates.assignTo = args.assignTo;
|
|
349
|
+
}
|
|
350
|
+
const updated = await api.updateConversation(ticketId, updates);
|
|
351
|
+
return {
|
|
352
|
+
content: [
|
|
353
|
+
{
|
|
354
|
+
type: 'text',
|
|
355
|
+
text: `Ticket #${ticketId} updated successfully`,
|
|
356
|
+
},
|
|
357
|
+
],
|
|
358
|
+
};
|
|
359
|
+
}
|
|
360
|
+
case 'freescout_draft_reply': {
|
|
361
|
+
const ticketId = api.parseTicketInput(args.ticket);
|
|
362
|
+
const conversation = await api.getConversation(ticketId, true);
|
|
363
|
+
const analysis = analyzer.analyzeConversation(conversation);
|
|
364
|
+
const reply = analyzer.generateCustomerReply(analysis, args.fixDescription, args.isExplanatory);
|
|
365
|
+
return {
|
|
366
|
+
content: [
|
|
367
|
+
{
|
|
368
|
+
type: 'text',
|
|
369
|
+
text: reply,
|
|
370
|
+
},
|
|
371
|
+
],
|
|
372
|
+
};
|
|
373
|
+
}
|
|
374
|
+
case 'freescout_search_tickets': {
|
|
375
|
+
const results = await api.searchConversations(args.query, args.status);
|
|
376
|
+
return {
|
|
377
|
+
content: [
|
|
378
|
+
{
|
|
379
|
+
type: 'text',
|
|
380
|
+
text: JSON.stringify(results, null, 2),
|
|
381
|
+
},
|
|
382
|
+
],
|
|
383
|
+
};
|
|
384
|
+
}
|
|
385
|
+
case 'git_create_worktree': {
|
|
386
|
+
const ticketId = args.ticketId;
|
|
387
|
+
const branchName = args.branchName || `fix/freescout-${ticketId}`;
|
|
388
|
+
const baseBranch = args.baseBranch || 'master';
|
|
389
|
+
const worktreeDir = `${WORKING_DIRECTORY}/worktrees/ticket-${ticketId}`;
|
|
390
|
+
try {
|
|
391
|
+
// Create worktrees directory if it doesn't exist
|
|
392
|
+
execSync(`mkdir -p ${WORKING_DIRECTORY}/worktrees`, { cwd: WORKING_DIRECTORY });
|
|
393
|
+
// Create worktree
|
|
394
|
+
execSync(`git worktree add "${worktreeDir}" -b "${branchName}" ${baseBranch}`, { cwd: WORKING_DIRECTORY });
|
|
395
|
+
// Add to .gitignore if needed
|
|
396
|
+
try {
|
|
397
|
+
const gitignore = execSync(`cat ${WORKING_DIRECTORY}/.gitignore`, { encoding: 'utf-8' });
|
|
398
|
+
if (!gitignore.includes('worktrees/')) {
|
|
399
|
+
execSync(`echo "worktrees/" >> ${WORKING_DIRECTORY}/.gitignore`, { cwd: WORKING_DIRECTORY });
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
catch {
|
|
403
|
+
// .gitignore might not exist
|
|
404
|
+
}
|
|
405
|
+
return {
|
|
406
|
+
content: [
|
|
407
|
+
{
|
|
408
|
+
type: 'text',
|
|
409
|
+
text: `✅ Created worktree at: ${worktreeDir}\n✅ Working on branch: ${branchName}\n✅ Ready for implementation`,
|
|
410
|
+
},
|
|
411
|
+
],
|
|
412
|
+
};
|
|
413
|
+
}
|
|
414
|
+
catch (error) {
|
|
415
|
+
throw new Error(`Failed to create worktree: ${error.message}`);
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
case 'git_remove_worktree': {
|
|
419
|
+
const ticketId = args.ticketId;
|
|
420
|
+
const worktreeDir = `${WORKING_DIRECTORY}/worktrees/ticket-${ticketId}`;
|
|
421
|
+
try {
|
|
422
|
+
execSync(`git worktree remove "${worktreeDir}"`, { cwd: WORKING_DIRECTORY });
|
|
423
|
+
return {
|
|
424
|
+
content: [
|
|
425
|
+
{
|
|
426
|
+
type: 'text',
|
|
427
|
+
text: `✅ Worktree removed for ticket #${ticketId}`,
|
|
428
|
+
},
|
|
429
|
+
],
|
|
430
|
+
};
|
|
431
|
+
}
|
|
432
|
+
catch (error) {
|
|
433
|
+
throw new Error(`Failed to remove worktree: ${error.message}`);
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
case 'github_create_pr': {
|
|
437
|
+
if (!GITHUB_TOKEN) {
|
|
438
|
+
return {
|
|
439
|
+
content: [
|
|
440
|
+
{
|
|
441
|
+
type: 'text',
|
|
442
|
+
text: '⚠️ GitHub token not configured. Please set GITHUB_TOKEN environment variable to create PRs.',
|
|
443
|
+
},
|
|
444
|
+
],
|
|
445
|
+
};
|
|
446
|
+
}
|
|
447
|
+
if (!GITHUB_REPO) {
|
|
448
|
+
return {
|
|
449
|
+
content: [
|
|
450
|
+
{
|
|
451
|
+
type: 'text',
|
|
452
|
+
text: '⚠️ Could not detect GitHub repository. Please ensure you are in a Git repository with a GitHub remote, or set GITHUB_REPO environment variable.',
|
|
453
|
+
},
|
|
454
|
+
],
|
|
455
|
+
};
|
|
456
|
+
}
|
|
457
|
+
const title = args.title;
|
|
458
|
+
const body = args.body;
|
|
459
|
+
const ticketId = args.ticketId;
|
|
460
|
+
const branch = args.branch || '';
|
|
461
|
+
const baseBranch = args.baseBranch || 'master';
|
|
462
|
+
const draft = args.draft || false;
|
|
463
|
+
try {
|
|
464
|
+
// If ticketId is provided, add FreeScout link to the body
|
|
465
|
+
let enhancedBody = body;
|
|
466
|
+
if (ticketId) {
|
|
467
|
+
enhancedBody = `${body}\n\n---\n\nFreeScout Ticket: ${FREESCOUT_URL}/conversation/${ticketId}`;
|
|
468
|
+
}
|
|
469
|
+
// Create the PR using GitHub CLI
|
|
470
|
+
const draftFlag = draft ? '--draft' : '';
|
|
471
|
+
const branchFlag = branch ? `--head ${branch}` : '';
|
|
472
|
+
const command = `gh pr create --repo ${GITHUB_REPO} --title "${title.replace(/"/g, '\\"')}" --body "${enhancedBody.replace(/"/g, '\\"')}" --base ${baseBranch} ${draftFlag} ${branchFlag}`.trim();
|
|
473
|
+
const result = execSync(command, {
|
|
474
|
+
cwd: WORKING_DIRECTORY,
|
|
475
|
+
encoding: 'utf-8',
|
|
476
|
+
env: {
|
|
477
|
+
...process.env,
|
|
478
|
+
GH_TOKEN: GITHUB_TOKEN,
|
|
479
|
+
}
|
|
480
|
+
}).trim();
|
|
481
|
+
return {
|
|
482
|
+
content: [
|
|
483
|
+
{
|
|
484
|
+
type: 'text',
|
|
485
|
+
text: `✅ Pull request created successfully!\n\n${result}`,
|
|
486
|
+
},
|
|
487
|
+
],
|
|
488
|
+
};
|
|
489
|
+
}
|
|
490
|
+
catch (error) {
|
|
491
|
+
// Check if gh CLI is installed
|
|
492
|
+
if (error.message.includes('gh: command not found')) {
|
|
493
|
+
return {
|
|
494
|
+
content: [
|
|
495
|
+
{
|
|
496
|
+
type: 'text',
|
|
497
|
+
text: '⚠️ GitHub CLI (gh) is not installed. Please install it from https://cli.github.com/ or create the PR manually.',
|
|
498
|
+
},
|
|
499
|
+
],
|
|
500
|
+
};
|
|
501
|
+
}
|
|
502
|
+
throw new Error(`Failed to create PR: ${error.message}`);
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
case 'freescout_implement_ticket': {
|
|
506
|
+
const ticketId = api.parseTicketInput(args.ticket);
|
|
507
|
+
const conversation = await api.getConversation(ticketId, true);
|
|
508
|
+
const analysis = analyzer.analyzeConversation(conversation);
|
|
509
|
+
let worktreeInfo = '';
|
|
510
|
+
if (args.autoCreateWorktree !== false) {
|
|
511
|
+
try {
|
|
512
|
+
const branchName = `fix/freescout-${ticketId}`;
|
|
513
|
+
const worktreeDir = `${WORKING_DIRECTORY}/worktrees/ticket-${ticketId}`;
|
|
514
|
+
execSync(`mkdir -p ${WORKING_DIRECTORY}/worktrees`, { cwd: WORKING_DIRECTORY });
|
|
515
|
+
execSync(`git worktree add "${worktreeDir}" -b "${branchName}" master`, { cwd: WORKING_DIRECTORY });
|
|
516
|
+
worktreeInfo = `\n\n## Git Worktree Created\n- Branch: ${branchName}\n- Location: ${worktreeDir}`;
|
|
517
|
+
}
|
|
518
|
+
catch (error) {
|
|
519
|
+
worktreeInfo = `\n\n⚠️ Could not create worktree: ${error.message}`;
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
const plan = {
|
|
523
|
+
issue: analysis.issueDescription,
|
|
524
|
+
rootCause: analysis.rootCause || 'To be determined',
|
|
525
|
+
solution: analysis.suggestedSolution || 'To be implemented',
|
|
526
|
+
filesToModify: [],
|
|
527
|
+
alternativeApproaches: [],
|
|
528
|
+
hasBreakingChanges: false,
|
|
529
|
+
requiresDocumentationUpdate: false,
|
|
530
|
+
};
|
|
531
|
+
const output = `# FreeScout Ticket #${ticketId} Implementation Plan
|
|
532
|
+
|
|
533
|
+
## Customer Information
|
|
534
|
+
- Name: ${analysis.customerName}
|
|
535
|
+
- Email: ${analysis.customerEmail}
|
|
536
|
+
|
|
537
|
+
## Issue Analysis
|
|
538
|
+
- **Is Bug**: ${analysis.isBug ? 'Yes' : 'No'}
|
|
539
|
+
- **Is Third-Party Issue**: ${analysis.isThirdPartyIssue ? 'Yes' : 'No'}
|
|
540
|
+
- **Tested by Team**: ${analysis.testedByTeam ? 'Yes' : 'No'}
|
|
541
|
+
- **Reproducible**: ${analysis.isReproducible ? 'Yes' : 'No'}
|
|
542
|
+
|
|
543
|
+
## Issue Description
|
|
544
|
+
${analysis.issueDescription}
|
|
545
|
+
|
|
546
|
+
## Root Cause
|
|
547
|
+
${plan.rootCause}
|
|
548
|
+
|
|
549
|
+
## Proposed Solution
|
|
550
|
+
${plan.solution}
|
|
551
|
+
|
|
552
|
+
${analysis.codeSnippets.length > 0 ? `## Code Snippets from Ticket\n${analysis.codeSnippets.join('\n\n')}` : ''}
|
|
553
|
+
|
|
554
|
+
${analysis.errorMessages.length > 0 ? `## Error Messages\n${analysis.errorMessages.join('\n')}` : ''}
|
|
555
|
+
|
|
556
|
+
${analysis.hasAttachments ? `## Attachments\n${analysis.attachments.join('\n')}` : ''}
|
|
557
|
+
|
|
558
|
+
${args.additionalContext ? `## Additional Context\n${args.additionalContext}` : ''}
|
|
559
|
+
|
|
560
|
+
${worktreeInfo}
|
|
561
|
+
|
|
562
|
+
${GITHUB_REPO ? `## GitHub Repository\n- Repository: ${GITHUB_REPO}\n- Ready for PR creation with \`github_create_pr\` tool` : '## GitHub Repository\n- ⚠️ No GitHub repository detected. Set GITHUB_REPO env variable if needed.'}
|
|
563
|
+
|
|
564
|
+
## Next Steps
|
|
565
|
+
1. Review the analysis above
|
|
566
|
+
2. ${analysis.isBug ? 'Implement the fix in the worktree' : 'Draft an explanatory reply'}
|
|
567
|
+
3. Test the changes
|
|
568
|
+
4. Create a pull request${GITHUB_REPO ? ' using `github_create_pr` tool' : ''}
|
|
569
|
+
5. Update the FreeScout ticket`;
|
|
570
|
+
return {
|
|
571
|
+
content: [
|
|
572
|
+
{
|
|
573
|
+
type: 'text',
|
|
574
|
+
text: output,
|
|
575
|
+
},
|
|
576
|
+
],
|
|
577
|
+
};
|
|
578
|
+
}
|
|
579
|
+
default:
|
|
580
|
+
throw new Error(`Unknown tool: ${name}`);
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
catch (error) {
|
|
584
|
+
return {
|
|
585
|
+
content: [
|
|
586
|
+
{
|
|
587
|
+
type: 'text',
|
|
588
|
+
text: `Error: ${error.message}`,
|
|
589
|
+
},
|
|
590
|
+
],
|
|
591
|
+
};
|
|
592
|
+
}
|
|
593
|
+
});
|
|
594
|
+
// Start the server
|
|
595
|
+
async function main() {
|
|
596
|
+
const transport = new StdioServerTransport();
|
|
597
|
+
await server.connect(transport);
|
|
598
|
+
console.error('FreeScout MCP Server running...');
|
|
599
|
+
}
|
|
600
|
+
main().catch((error) => {
|
|
601
|
+
console.error('Server error:', error);
|
|
602
|
+
process.exit(1);
|
|
603
|
+
});
|
|
604
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EACL,qBAAqB,EACrB,sBAAsB,GAIvB,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAGtD,6BAA6B;AAC7B,MAAM,EAAE,CAAC;AAET,0CAA0C;AAC1C,MAAM,aAAa,GAAG,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC;AAChD,MAAM,iBAAiB,GAAG,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC;AACxD,MAAM,eAAe,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,yBAAyB,IAAI,GAAG,CAAC,CAAC;AAE/E,2EAA2E;AAC3E,gFAAgF;AAChF,MAAM,iBAAiB,GAAG,OAAO,CAAC,GAAG,CAAC,iBAAiB,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;AAEzE,yDAAyD;AACzD,SAAS,aAAa;IACpB,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC;QAC5B,OAAO,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC;IACjC,CAAC;IAED,IAAI,CAAC;QACH,mCAAmC;QACnC,MAAM,SAAS,GAAG,QAAQ,CAAC,uCAAuC,EAAE;YAClE,GAAG,EA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WAAW,0DAA0D,CAAC,CAAC,CAAC,mGAAmG;;;;KAI7N,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,mCAAmC,CAAC,CAAC,CAAC,4BAA4B;;0BAE9D,WAAW,CAAC,CAAC,CAAC,gCAAgC,CAAC,CAAC,CAAC,EAAE;+BAC9C,CAAC;gBAExB,OAAO;oBACL,OAAO,EAAE;wBACP;4BACE,IAAI,EAAE,MAAM;4BACZ,IAAI,EAAE,MAAM;yBACb;qBACF;iBACF,CAAC;YACJ,CAAC;YAED;gBACE,MAAM,IAAI,KAAK,CAAC,iBAAiB,IAAI,EAAE,CAAC,CAAC;QAC7C,CAAC;IACH,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QACpB,OAAO;YACL,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,UAAU,KAAK,CAAC,OAAO,EAAE;iBAChC;aACF;SACF,CAAC;IACJ,CAAC;AACH,CAAC,CAAC,CAAC;AAEH,mBAAmB;AACnB,KAAK,UAAU,IAAI;IACjB,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;IAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAChC,OAAO,CAAC,KAAK,CAAC,iCAAiC,CAAC,CAAC;AACnD,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACrB,OAAO,CAAC,KAAK,CAAC,eAAe,EAAE,KAAK,CAAC,CAAC;IACtC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { FreeScoutConversation, TicketAnalysis } from './types.js';
|
|
2
|
+
export declare class TicketAnalyzer {
|
|
3
|
+
analyzeConversation(conversation: FreeScoutConversation): TicketAnalysis;
|
|
4
|
+
private extractIssueDescription;
|
|
5
|
+
private extractCodeSnippets;
|
|
6
|
+
private extractErrorMessages;
|
|
7
|
+
private checkTestedByTeam;
|
|
8
|
+
private checkReproducible;
|
|
9
|
+
private extractAttachments;
|
|
10
|
+
private analyzeIssueType;
|
|
11
|
+
private stripHtml;
|
|
12
|
+
private looksLikeCode;
|
|
13
|
+
generateCustomerReply(analysis: TicketAnalysis, fixDescription?: string, isExplanatory?: boolean): string;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=ticket-analyzer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ticket-analyzer.d.ts","sourceRoot":"","sources":["../src/ticket-analyzer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qBAAqB,EAErB,cAAc,EACf,MAAM,YAAY,CAAC;AAEpB,qBAAa,cAAc;IACzB,mBAAmB,CAAC,YAAY,EAAE,qBAAqB,GAAG,cAAc;IAyCxE,OAAO,CAAC,uBAAuB;IAmB/B,OAAO,CAAC,mBAAmB;IAiC3B,OAAO,CAAC,oBAAoB;IA+B5B,OAAO,CAAC,iBAAiB;IAsBzB,OAAO,CAAC,iBAAiB;IAoBzB,OAAO,CAAC,kBAAkB;IAc1B,OAAO,CAAC,gBAAgB;IA6DxB,OAAO,CAAC,SAAS;IAajB,OAAO,CAAC,aAAa;IAsBrB,qBAAqB,CACnB,QAAQ,EAAE,cAAc,EACxB,cAAc,CAAC,EAAE,MAAM,EACvB,aAAa,GAAE,OAAe,GAC7B,MAAM;CAkCV"}
|