reactToEvent
Publish reactions to Nostr events using kind 7 protocol. Enable AI agents to respond to content with emoji or text reactions on the decentralized social network.
Instructions
React to an event (kind 7)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| eventId | Yes | ID of the event to react to | |
| eventPubkey | Yes | Pubkey of the event author | |
| reaction | No | Reaction content (default: "+") | + |
| 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:113-127 (handler)Implementation of the reactToEvent tool.
export async function reactToEvent({ eventId, eventPubkey, reaction, privateKey, relays }: z.infer<typeof reactToEventSchema>) { const template: EventTemplate = { kind: KINDS.REACTION, content: reaction ?? '+', tags: [ ['e', eventId], ['p', normalizePubkey(eventPubkey)], ], 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:21-28 (schema)Schema for the reactToEvent tool parameters.
export const reactToEventSchema = z.object({ eventId: z.string().describe('ID of the event to react to'), eventPubkey: z.string().describe('Pubkey of the event author'), reaction: z.string().optional().default('+').describe('Reaction content (default: "+")'), privateKey: z.string().optional().describe(privateKeyDesc), relays: z.array(z.string()).optional().describe('Relays to publish to'), }); - src/index.ts:107-109 (registration)Registration of the reactToEvent tool in the MCP server.
server.tool('reactToEvent', 'React to an event (kind 7)', reactToEventSchema.shape, async (params) => { return textResult(await reactToEvent(params)); });