signNote
Sign Nostr events with private keys to authenticate and publish content on decentralized networks.
Instructions
Sign a note event
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| unsignedEvent | Yes | The unsigned event to sign | |
| privateKey | No | Private key (nsec or hex). Optional when NOSTR_BUNKER_URI is configured. |
Implementation Reference
- src/tools/note-tools.ts:57-75 (handler)The signNote tool handler logic that signs a note event, either using a provided private key or by calling signEventWithBunker if in bunker mode.
export async function signNote({ unsignedEvent, privateKey }: z.infer<typeof signNoteSchema>): Promise<VerifiedEvent> { if (isBunkerMode()) { const template: EventTemplate = { kind: unsignedEvent.kind, content: unsignedEvent.content, tags: unsignedEvent.tags, created_at: unsignedEvent.created_at, }; return signEventWithBunker(template); } if (!privateKey) throw new Error('privateKey is required when NOSTR_BUNKER_URI is not configured'); const sk = normalizePrivateKey(privateKey); return finalizeEvent({ kind: unsignedEvent.kind, content: unsignedEvent.content, tags: unsignedEvent.tags, created_at: unsignedEvent.created_at, }, sk); } - src/tools/note-tools.ts:16-25 (schema)The Zod schema defining the input parameters for the signNote tool.
export const signNoteSchema = z.object({ unsignedEvent: z.object({ kind: z.number(), content: z.string(), tags: z.array(z.array(z.string())), created_at: z.number(), pubkey: z.string(), }).describe('The unsigned event to sign'), privateKey: z.string().optional().describe(privateKeyDesc), }); - src/index.ts:61-63 (registration)The registration of the signNote tool in the MCP server.
server.tool('signNote', 'Sign a note event', signNoteSchema.shape, async (params) => { return textResult(await signNote(params)); });