Skip to main content
Glama

signNostrEvent

Sign unsigned Nostr events to authenticate and publish content on decentralized networks using private keys.

Instructions

Sign any unsigned Nostr event

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
unsignedEventYesUnsigned event template
privateKeyNoPrivate key (nsec or hex). Optional when NOSTR_BUNKER_URI is configured.

Implementation Reference

  • The signNostrEvent handler function which determines if it should use a NIP-46 bunker signer or a direct private key signer.
    export async function signNostrEvent({ unsignedEvent, privateKey }: z.infer<typeof signNostrEventSchema>): Promise<VerifiedEvent> {
      const template: EventTemplate = {
        kind: unsignedEvent.kind,
        content: unsignedEvent.content,
        tags: unsignedEvent.tags,
        created_at: unsignedEvent.created_at,
      };
    
      if (isBunkerMode()) {
        return signEventWithBunker(template);
      }
      if (!privateKey) throw new Error('privateKey is required when NOSTR_BUNKER_URI is not configured');
      const sk = normalizePrivateKey(privateKey);
      return finalizeEvent(template, sk);
    }
  • Zod schema defining the input for signNostrEvent.
    export const signNostrEventSchema = z.object({
      unsignedEvent: z.object({
        kind: z.number(),
        content: z.string(),
        tags: z.array(z.array(z.string())),
        created_at: z.number(),
      }).describe('Unsigned event template'),
      privateKey: z.string().optional().describe(privateKeyDesc),
    });
  • src/index.ts:79-81 (registration)
    Tool registration for 'signNostrEvent' within the MCP server.
    server.tool('signNostrEvent', 'Sign any unsigned Nostr event', signNostrEventSchema.shape, async (params) => {
      return textResult(await signNostrEvent(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