mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-01 00:43:15 +00:00
feat(mcp): add_journey_comment, the MCP side of commenting on an entry
The REST route let everyone on a journey comment, but MCP could only list, hide and delete. The tool runs through the same service and checks. The in-app assistant is not offered it, since a comment speaks in the user's name to the journey's people and the link's readers.
This commit is contained in:
@@ -75,7 +75,8 @@ export const ASSISTANT_DENIED_TOOLS: Readonly<Record<string, string>> = {
|
||||
get_journey_share_link: 'reads a public link token',
|
||||
create_journey_share_link: 'mints a public link token',
|
||||
delete_journey_share_link: 'belongs with the share links above',
|
||||
list_journey_subscribers: 'reads the email addresses of people without an account, which would reach the AI provider',
|
||||
add_journey_comment: "speaks in the user's name to the journey's people and the readers of its share link",
|
||||
list_journey_subscribers:'reads the email addresses of people without an account, which would reach the AI provider',
|
||||
remove_journey_subscriber: 'belongs with the followers above',
|
||||
get_trip_calendar_feed: 'reads a calendar feed token',
|
||||
enable_trip_calendar_feed: 'mints a calendar feed token',
|
||||
|
||||
@@ -12,14 +12,15 @@ import { addonGate } from '../addons/addon-gate';
|
||||
import { AddonsService } from '../addons/addons.service';
|
||||
import { JourneyCommentsService } from './journey-comments.service';
|
||||
import { JourneySubscriptionsService } from './journey-subscriptions.service';
|
||||
import { idSchema, journeyCommentHideRequestSchema } from '@trek/shared';
|
||||
import { idSchema, journeyCommentCreateRequestSchema, journeyCommentHideRequestSchema } from '@trek/shared';
|
||||
|
||||
const journeyAddonOn = addonGate(ADDON_IDS.JOURNEY);
|
||||
|
||||
/**
|
||||
* The comments under a journey's entries and the addresses following its
|
||||
* share link (#1702, #1669), over the same services and checks as
|
||||
* `JourneySocialController`: the comments for everyone on the journey (hiding
|
||||
* `JourneySocialController`: the comments for everyone on the journey (writing
|
||||
* for everyone on it, hiding
|
||||
* for its editors, deleting for the author or an editor), the followers for
|
||||
* the journey's owner only, under the share scope like the link itself.
|
||||
*/
|
||||
@@ -44,6 +45,26 @@ export class JourneySocialMcp {
|
||||
return ok(await this.comments.list(journeyId, ctx.userId));
|
||||
}
|
||||
|
||||
@Tool({
|
||||
name: 'add_journey_comment',
|
||||
description:
|
||||
'Comment under an entry of a journey the caller is on, as plain text (at most 2000 characters, no markdown). The comment shows to everyone on the journey and, while the share link allows comments, to every reader of the link. Answers with the new comment.',
|
||||
inputSchema: {
|
||||
journeyId: idSchema,
|
||||
entryId: idSchema,
|
||||
body: journeyCommentCreateRequestSchema.shape.body,
|
||||
},
|
||||
annotations: TOOL_ANNOTATIONS_WRITE,
|
||||
when: journeyAddonOn,
|
||||
access: { group: 'journey', mode: 'write' },
|
||||
})
|
||||
async addJourneyComment(
|
||||
{ journeyId, entryId, body }: { journeyId: number; entryId: number; body: string },
|
||||
ctx: McpContext,
|
||||
) {
|
||||
return ok({ comment: await this.comments.add(journeyId, entryId, ctx.userId, body) });
|
||||
}
|
||||
|
||||
@Tool({
|
||||
name: 'set_journey_comment_hidden',
|
||||
description:
|
||||
|
||||
Reference in New Issue
Block a user