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
| Name | Required | Description | Default |
|---|---|---|---|
| content | Yes | Text content of the note | |
| tags | No | Event tags | |
| privateKey | No | Private key (nsec or hex). Optional when NOSTR_BUNKER_URI is configured. | |
| relays | No | Relays to publish to |
Implementation Reference
- src/tools/note-tools.ts:77-96 (handler)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 }; } - src/tools/note-tools.ts:27-32 (schema)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));