replyToEvent
Create threaded replies to Nostr events using NIP-10 standards for organized conversations.
Instructions
Reply to an event with NIP-10 threading
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| eventId | Yes | ID of the event to reply to | |
| eventPubkey | Yes | Pubkey of the event author | |
| content | Yes | Reply content | |
| rootEventId | No | Root event ID for threading (NIP-10) | |
| privateKey | No | Private key (nsec or hex). Optional when NOSTR_BUNKER_URI is configured. | |
| relays | No | Relays to publish to |
Implementation Reference
- src/tools/social-tools.ts:157-179 (handler)The core handler function for the 'replyToEvent' tool.
export async function replyToEvent({ eventId, eventPubkey, content, rootEventId, privateKey, relays }: z.infer<typeof replyToEventSchema>) { const tags: string[][] = [['p', normalizePubkey(eventPubkey)]]; if (rootEventId && rootEventId !== eventId) { // Threaded reply: root + reply markers (NIP-10) tags.push(['e', rootEventId, '', 'root']); tags.push(['e', eventId, '', 'reply']); } else { // Direct reply tags.push(['e', eventId, '', 'root']); } const template: EventTemplate = { kind: KINDS.TEXT, content, tags, created_at: Math.floor(Date.now() / 1000), }; const signed = await signTemplate(template, privateKey); const result = await publishEvent(signed, relays ?? DEFAULT_RELAYS); return { event: signed, published: result }; } - src/tools/social-tools.ts:44-48 (schema)The input schema for the 'replyToEvent' tool.
export const replyToEventSchema = z.object({ eventId: z.string().describe('ID of the event to reply to'), eventPubkey: z.string().describe('Pubkey of the event author'), content: z.string().describe('Reply content'), rootEventId: z.string().optional().describe('Root event ID for threading (NIP-10)'), - src/index.ts:119-121 (registration)MCP tool registration for 'replyToEvent'.
server.tool('replyToEvent', 'Reply to an event with NIP-10 threading', replyToEventSchema.shape, async (params) => { return textResult(await replyToEvent(params)); });