Skip to main content
Glama

postNote

Create, sign, and publish text notes on the Nostr network for AI agents to share information publicly.

Instructions

Create, sign, and publish a text note (all-in-one)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contentYesText content of the note
tagsNoEvent tags
privateKeyNoPrivate key (nsec or hex). Optional when NOSTR_BUNKER_URI is configured.
relaysNoRelays to publish to

Implementation Reference

  • The postNote handler creates a note, signs it using either a bunker or a provided private key, and publishes it to relays.
    export async function postNote({ content, tags, privateKey, relays }: z.infer<typeof postNoteSchema>) {
      const template: EventTemplate = {
        kind: KINDS.TEXT,
        content,
        tags: tags ?? [],
        created_at: Math.floor(Date.now() / 1000),
      };
    
      let signed: VerifiedEvent;
      if (isBunkerMode()) {
        signed = await signEventWithBunker(template);
      } else {
        if (!privateKey) throw new Error('privateKey is required when NOSTR_BUNKER_URI is not configured');
        const sk = normalizePrivateKey(privateKey);
        signed = finalizeEvent(template, sk);
      }
    
      const result = await publishEvent(signed, relays ?? DEFAULT_RELAYS);
      return { event: signed, published: result };
    }
  • Schema validation for the postNote tool inputs.
    export const postNoteSchema = z.object({
      content: z.string().describe('Text content of the note'),
      tags: z.array(z.array(z.string())).optional().describe('Event tags'),
      privateKey: z.string().optional().describe(privateKeyDesc),
      relays: z.array(z.string()).optional().describe('Relays to publish to'),
    });
  • src/index.ts:65-66 (registration)
    Tool registration for postNote in the MCP server setup.
    server.tool('postNote', 'Create, sign, and publish a text note (all-in-one)', postNoteSchema.shape, async (params) => {
      return textResult(await postNote(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