This commit is contained in:
Bastian Wagner
2026-06-11 17:45:40 +02:00
parent 3a1d4ba2e3
commit 4dec991c4a
4 changed files with 304 additions and 1 deletions

View File

@@ -9,6 +9,15 @@ import { ListSuggestionAgentService } from './list-suggestion-agent.service';
const listKindSchema = z
.enum(['packing', 'shopping', 'todo', 'custom'])
.optional();
const listItemInputSchema = {
title: z.string().trim().min(1).describe('List item title.'),
notes: z.string().trim().min(1).optional().describe('Optional item notes.'),
quantity: z.number().positive().optional().describe('Optional item quantity.'),
required: z
.boolean()
.optional()
.describe('Whether the item is required. Defaults to true.'),
};
@Injectable()
export class McpServerService {
@@ -144,6 +153,78 @@ export class McpServerService {
},
);
server.registerTool(
'create_list',
{
title: 'Create list',
description:
'Creates a new list for the authenticated user and optionally adds initial items.',
inputSchema: {
name: z.string().trim().min(1).describe('List name.'),
description: z
.string()
.trim()
.min(1)
.optional()
.describe('Optional list description.'),
kind: listKindSchema.describe('Optional list kind.'),
items: z
.array(z.object(listItemInputSchema))
.max(50)
.optional()
.describe('Optional initial list items.'),
},
annotations: {
readOnlyHint: false,
destructiveHint: false,
idempotentHint: false,
openWorldHint: false,
},
},
async ({ name, description, kind, items = [] }) => {
let list = await this.listsService.createList(userId, {
name,
description,
kind: kind as ListTemplateKind | undefined,
});
for (const item of items) {
list = await this.listsService.addItem(userId, list.id, item);
}
return this.toToolResult({ list });
},
);
server.registerTool(
'add_list_item',
{
title: 'Add list item',
description:
'Adds an item to an existing list the authenticated user can access.',
inputSchema: {
listId: z.string().trim().min(1).describe('Target list id.'),
...listItemInputSchema,
},
annotations: {
readOnlyHint: false,
destructiveHint: false,
idempotentHint: false,
openWorldHint: false,
},
},
async ({ listId, title, notes, quantity, required }) => {
const list = await this.listsService.addItem(userId, listId, {
title,
notes,
quantity,
required,
});
return this.toToolResult({ list });
},
);
return server;
}