targetprocess-mcp-server 2.2.8 → 2.2.9-b
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/build/index.js +132 -0
- package/build/tp.js +51 -0
- package/package.json +1 -1
package/build/index.js
CHANGED
|
@@ -1557,6 +1557,138 @@ server.registerTool('get_card_current_status', {
|
|
|
1557
1557
|
}],
|
|
1558
1558
|
};
|
|
1559
1559
|
});
|
|
1560
|
+
server.registerTool('get_in_progress_tasks_and_bugs', {
|
|
1561
|
+
title: 'Get in-progress tasks and bugs for a user',
|
|
1562
|
+
description: 'Get all Tasks and Bugs currently in "In Progress" state assigned to a given user ID',
|
|
1563
|
+
inputSchema: {
|
|
1564
|
+
userId: z.string()
|
|
1565
|
+
.describe('Targetprocess user ID (e.g. 123)'),
|
|
1566
|
+
},
|
|
1567
|
+
}, async ({ userId }) => {
|
|
1568
|
+
const result = await tp.getInProgressTasksAndBugs(userId);
|
|
1569
|
+
const tasks = result.tasks.map((t) => ({
|
|
1570
|
+
type: 'Task',
|
|
1571
|
+
id: t.Id,
|
|
1572
|
+
name: t.Name,
|
|
1573
|
+
state: t.EntityState?.Name,
|
|
1574
|
+
userStoryId: t.UserStory?.Id,
|
|
1575
|
+
userStoryName: t.UserStory?.Name,
|
|
1576
|
+
featureId: t.UserStory?.Feature?.Id,
|
|
1577
|
+
featureName: t.UserStory?.Feature?.Name,
|
|
1578
|
+
}));
|
|
1579
|
+
const bugs = result.bugs.map((b) => ({
|
|
1580
|
+
type: 'Bug',
|
|
1581
|
+
id: b.Id,
|
|
1582
|
+
name: b.Name,
|
|
1583
|
+
state: b.EntityState?.Name,
|
|
1584
|
+
userStoryId: b.UserStory?.Id,
|
|
1585
|
+
userStoryName: b.UserStory?.Name,
|
|
1586
|
+
featureId: b.UserStory?.Feature?.Id ?? b.Feature?.Id,
|
|
1587
|
+
featureName: b.UserStory?.Feature?.Name ?? b.Feature?.Name,
|
|
1588
|
+
}));
|
|
1589
|
+
const items = [...tasks, ...bugs];
|
|
1590
|
+
if (items.length === 0) {
|
|
1591
|
+
return {
|
|
1592
|
+
content: [{
|
|
1593
|
+
type: 'text',
|
|
1594
|
+
text: `No in-progress tasks or bugs found for user ID: ${userId}`,
|
|
1595
|
+
}],
|
|
1596
|
+
};
|
|
1597
|
+
}
|
|
1598
|
+
return {
|
|
1599
|
+
content: [{
|
|
1600
|
+
type: 'text',
|
|
1601
|
+
text: JSON.stringify(items),
|
|
1602
|
+
}],
|
|
1603
|
+
};
|
|
1604
|
+
});
|
|
1605
|
+
server.registerTool('create_task', {
|
|
1606
|
+
title: 'Create a new task',
|
|
1607
|
+
description: 'Create a new task linked to a user story.',
|
|
1608
|
+
inputSchema: {
|
|
1609
|
+
title: z.string()
|
|
1610
|
+
.describe('Task title'),
|
|
1611
|
+
userStoryId: z.string()
|
|
1612
|
+
.min(5)
|
|
1613
|
+
.max(6)
|
|
1614
|
+
.describe('User story ID to link the task to (e.g. 145789)'),
|
|
1615
|
+
description: z.string()
|
|
1616
|
+
.optional()
|
|
1617
|
+
.describe('Task description (optional)'),
|
|
1618
|
+
},
|
|
1619
|
+
}, async ({ title, userStoryId, description }) => {
|
|
1620
|
+
const taskResponse = await tp.createTask({ title, userStoryId, description });
|
|
1621
|
+
if (!taskResponse) {
|
|
1622
|
+
return {
|
|
1623
|
+
content: [{
|
|
1624
|
+
type: 'text',
|
|
1625
|
+
text: `Failed to create task "${title}"\n JSON: ${JSON.stringify(taskResponse, null, 2)}`
|
|
1626
|
+
}]
|
|
1627
|
+
};
|
|
1628
|
+
}
|
|
1629
|
+
return {
|
|
1630
|
+
content: [{
|
|
1631
|
+
type: 'text',
|
|
1632
|
+
text: JSON.stringify(taskResponse)
|
|
1633
|
+
}],
|
|
1634
|
+
};
|
|
1635
|
+
});
|
|
1636
|
+
server.registerTool('get_commit_message', {
|
|
1637
|
+
title: 'Get commit message for a task or bug',
|
|
1638
|
+
description: `Returns the formatted commit message string for a given task or bug ID.
|
|
1639
|
+
Formats:
|
|
1640
|
+
- Task on a user story: "F#<featureId> US#<userStoryId> T#<taskId> <title>"
|
|
1641
|
+
- Bug on a user story: "F#<featureId> US#<userStoryId> B#<bugId> <title>"
|
|
1642
|
+
- Standalone bug (no user story): "B#<bugId> <title>"`,
|
|
1643
|
+
inputSchema: {
|
|
1644
|
+
id: z.string()
|
|
1645
|
+
.describe('The task or bug ID (e.g. 145789)'),
|
|
1646
|
+
type: z.enum(['task', 'bug'])
|
|
1647
|
+
.describe('Whether the ID refers to a task or a bug'),
|
|
1648
|
+
},
|
|
1649
|
+
}, async ({ id, type }) => {
|
|
1650
|
+
if (type === 'task') {
|
|
1651
|
+
const task = await tp.getTask(id);
|
|
1652
|
+
if (!task) {
|
|
1653
|
+
return {
|
|
1654
|
+
content: [{ type: 'text', text: `Failed to get task with id: ${id}` }],
|
|
1655
|
+
};
|
|
1656
|
+
}
|
|
1657
|
+
const userStory = task.UserStory;
|
|
1658
|
+
const feature = userStory?.Feature;
|
|
1659
|
+
if (!userStory) {
|
|
1660
|
+
return {
|
|
1661
|
+
content: [{ type: 'text', text: `Task ${id} has no linked user story` }],
|
|
1662
|
+
};
|
|
1663
|
+
}
|
|
1664
|
+
const prefix = feature
|
|
1665
|
+
? `F#${feature.Id} US#${userStory.Id} T#${task.Id}`
|
|
1666
|
+
: `US#${userStory.Id} T#${task.Id}`;
|
|
1667
|
+
return {
|
|
1668
|
+
content: [{ type: 'text', text: `${prefix} ${task.Name}` }],
|
|
1669
|
+
};
|
|
1670
|
+
}
|
|
1671
|
+
// type === 'bug'
|
|
1672
|
+
const bug = await tp.getBugWithRelations(id);
|
|
1673
|
+
if (!bug) {
|
|
1674
|
+
return {
|
|
1675
|
+
content: [{ type: 'text', text: `Failed to get bug with id: ${id}` }],
|
|
1676
|
+
};
|
|
1677
|
+
}
|
|
1678
|
+
const userStory = bug.UserStory;
|
|
1679
|
+
const feature = userStory?.Feature ?? bug.Feature;
|
|
1680
|
+
if (!userStory) {
|
|
1681
|
+
return {
|
|
1682
|
+
content: [{ type: 'text', text: `B#${bug.Id} ${bug.Name}` }],
|
|
1683
|
+
};
|
|
1684
|
+
}
|
|
1685
|
+
const prefix = feature
|
|
1686
|
+
? `F#${feature.Id} US#${userStory.Id} B#${bug.Id}`
|
|
1687
|
+
: `US#${userStory.Id} B#${bug.Id}`;
|
|
1688
|
+
return {
|
|
1689
|
+
content: [{ type: 'text', text: `${prefix} ${bug.Name}` }],
|
|
1690
|
+
};
|
|
1691
|
+
});
|
|
1560
1692
|
async function main() {
|
|
1561
1693
|
const transport = new StdioServerTransport();
|
|
1562
1694
|
await server.connect(transport);
|
package/build/tp.js
CHANGED
|
@@ -591,6 +591,57 @@ export class TpClient {
|
|
|
591
591
|
param: { "format": "json" }
|
|
592
592
|
});
|
|
593
593
|
}
|
|
594
|
+
async getInProgressTasksAndBugs(userId) {
|
|
595
|
+
const where = `(EntityState.Name eq 'In Progress') and (AssignedUser.Id eq ${userId})`;
|
|
596
|
+
const include = "[Id,Name,EntityState[Name],UserStory[Id,Name,Feature[Id,Name]]]";
|
|
597
|
+
const param = { "format": "json", "where": where, "include": include, "orderByDesc": "ModifyDate" };
|
|
598
|
+
const [tasks, bugs] = await Promise.all([
|
|
599
|
+
this.get({ pathParam: ["Tasks"], param }),
|
|
600
|
+
this.get({ pathParam: ["Bugs"], param }),
|
|
601
|
+
]);
|
|
602
|
+
return {
|
|
603
|
+
tasks: tasks?.Items ?? [],
|
|
604
|
+
bugs: bugs?.Items ?? [],
|
|
605
|
+
};
|
|
606
|
+
}
|
|
607
|
+
async getTask(taskId) {
|
|
608
|
+
const response = await this.get({
|
|
609
|
+
pathParam: ["Tasks", taskId],
|
|
610
|
+
param: {
|
|
611
|
+
"format": "json",
|
|
612
|
+
"include": "[Id,Name,UserStory[Id,Name,Feature[Id,Name]]]",
|
|
613
|
+
}
|
|
614
|
+
});
|
|
615
|
+
return response;
|
|
616
|
+
}
|
|
617
|
+
async getBugWithRelations(bugId) {
|
|
618
|
+
const response = await this.get({
|
|
619
|
+
pathParam: ["Bugs", bugId],
|
|
620
|
+
param: {
|
|
621
|
+
"format": "json",
|
|
622
|
+
"include": "[Id,Name,UserStory[Id,Name,Feature[Id,Name]]]",
|
|
623
|
+
}
|
|
624
|
+
});
|
|
625
|
+
return response;
|
|
626
|
+
}
|
|
627
|
+
async createTask({ title, description, userStoryId }) {
|
|
628
|
+
const task = {
|
|
629
|
+
"Name": title,
|
|
630
|
+
"Project": {
|
|
631
|
+
"Id": config.tp.projectId
|
|
632
|
+
},
|
|
633
|
+
"UserStory": {
|
|
634
|
+
"Id": userStoryId
|
|
635
|
+
},
|
|
636
|
+
};
|
|
637
|
+
if (description) {
|
|
638
|
+
task["Description"] = description;
|
|
639
|
+
}
|
|
640
|
+
return this.post({
|
|
641
|
+
pathParam: ["Tasks"],
|
|
642
|
+
param: { "format": "json" },
|
|
643
|
+
}, task);
|
|
644
|
+
}
|
|
594
645
|
async addAttachedFile(generalId, source) {
|
|
595
646
|
let blob;
|
|
596
647
|
let fileName;
|