Skip to content

Commit 95b4439

Browse files
committed
feat: add getProcessInfo tool to retrieve BPMN representation of a process
- Implemented a new tool `getProcessInfo` that fetches the BPMN representation of a process based on the provided process ID. - Added Zod schema for input validation. - Defined tool metadata including name, description, and hints for usage. - Updated dependencies in yarn.lock to include new versions and additional packages.
1 parent 5879fe5 commit 95b4439

File tree

4 files changed

+232
-204
lines changed

4 files changed

+232
-204
lines changed

src/management-system-v2/tools/getAllProcesses.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { z } from 'zod';
22
import { type InferSchema } from 'xmcp';
3+
import prisma from '@/lib/data/db';
34

45
// Define the schema for tool parameters
56
export const schema = {};
@@ -18,5 +19,10 @@ export const metadata = {
1819

1920
// Tool implementation
2021
export default async function getProcesses({}: InferSchema<typeof schema>) {
21-
return `[{id: "74393", name: "Vacation Application", versions: 5, lastModified: "2025-01-15T10:23:45Z"}, {id: "83920", name: "Expense Reimbursement", versions: 3, lastModified: "2025-02-20T14:12:30Z"}]`;
22+
const result = await prisma.process.findMany({
23+
select: { id: true, name: true, description: true, lastEditedOn: true },
24+
take: 100,
25+
});
26+
27+
return result ?? `Error: No processes found.`;
2228
}

src/management-system-v2/tools/getBPMN.ts

Lines changed: 0 additions & 186 deletions
This file was deleted.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { z } from 'zod';
2+
import { type InferSchema } from 'xmcp';
3+
import prisma from '@/lib/data/db';
4+
5+
// Define the schema for tool parameters
6+
export const schema = {
7+
processId: z.string().describe('The ID of the process'),
8+
};
9+
10+
// Define tool metadata
11+
export const metadata = {
12+
name: 'get-process-info',
13+
description: 'Get the BPMN representation of a process',
14+
annotations: {
15+
title: 'Get process info',
16+
readOnlyHint: true,
17+
destructiveHint: false,
18+
idempotentHint: true,
19+
},
20+
};
21+
22+
// Tool implementation
23+
export default async function getProcessInfo({ processId }: InferSchema<typeof schema>) {
24+
const result = await prisma.process.findUnique({
25+
where: { id: processId },
26+
select: { bpmn: true },
27+
});
28+
29+
return result?.bpmn ?? `Error: Process with ID ${processId} not found.`;
30+
}

0 commit comments

Comments
 (0)