This commit is contained in:
Bastian Wagner
2026-06-13 15:41:57 +02:00
parent 6642575ea9
commit 22c93f9ca1
10 changed files with 874 additions and 19 deletions

View File

@@ -18,6 +18,24 @@ const listItemInputSchema = {
.optional()
.describe('Whether the item is required. Defaults to true.'),
};
const templateItemInputSchema = {
title: z.string().trim().min(1).describe('Template item title.'),
notes: z
.string()
.trim()
.min(1)
.optional()
.describe('Optional template item notes.'),
quantity: z
.number()
.positive()
.optional()
.describe('Optional template item quantity.'),
required: z
.boolean()
.optional()
.describe('Whether the template item is required. Defaults to true.'),
};
@Injectable()
export class McpServerService {
@@ -225,6 +243,79 @@ export class McpServerService {
},
);
server.registerTool(
'create_template',
{
title: 'Create template',
description:
'Creates a new list template for the authenticated user and optionally adds template items.',
inputSchema: {
name: z.string().trim().min(1).describe('Template name.'),
description: z
.string()
.trim()
.min(1)
.optional()
.describe('Optional template description.'),
kind: listKindSchema.describe('Optional template kind.'),
items: z
.array(z.object(templateItemInputSchema))
.max(50)
.optional()
.describe('Optional initial template items.'),
},
annotations: {
readOnlyHint: false,
destructiveHint: false,
idempotentHint: false,
openWorldHint: false,
},
},
async ({ name, description, kind, items = [] }) => {
const template = await this.listTemplatesService.createTemplate(userId, {
name,
description,
kind: kind as ListTemplateKind | undefined,
items,
});
return this.toToolResult({ template });
},
);
server.registerTool(
'add_template_item',
{
title: 'Add template item',
description:
'Adds an item to an existing list template owned by the authenticated user.',
inputSchema: {
templateId: z.string().trim().min(1).describe('Target template id.'),
...templateItemInputSchema,
},
annotations: {
readOnlyHint: false,
destructiveHint: false,
idempotentHint: false,
openWorldHint: false,
},
},
async ({ templateId, title, notes, quantity, required }) => {
const template = await this.listTemplatesService.addItem(
userId,
templateId,
{
title,
notes,
quantity,
required,
},
);
return this.toToolResult({ template });
},
);
return server;
}