Skip to main content
Glama

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
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

  • 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 };
    }
  • 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));
    });

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