Skip to main content
Glama

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
NameRequiredDescriptionDefault
eventIdYesID of the event to reply to
eventPubkeyYesPubkey of the event author
contentYesReply content
rootEventIdNoRoot event ID for threading (NIP-10)
privateKeyNoPrivate key (nsec or hex). Optional when NOSTR_BUNKER_URI is configured.
relaysNoRelays to publish to

Implementation Reference

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

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