Skip to main content
Glama

reactToEvent

Enable AI agents to publish reactions to Nostr events by signing and broadcasting kind 7 messages to specified relays.

Instructions

React to an event (kind 7)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
eventIdYesID of the event to react to
eventPubkeyYesPubkey of the event author
reactionNoReaction content (default: "+")+
privateKeyNoPrivate key (nsec or hex). Optional when NOSTR_BUNKER_URI is configured.
relaysNoRelays to publish to

Implementation Reference

  • The implementation of the reactToEvent handler which constructs a NIP-25 reaction event template and publishes it.
    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 };
    }
  • The Zod schema defining inputs for reactToEvent.
    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-108 (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));

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/jorgenclaw/nostr-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server