Skip to main content
Glama

signNostrEvent

Sign Nostr events to authenticate and publish content on decentralized social networks. Provide an unsigned event template and private key to generate a valid signed event.

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 implementation of the signNostrEvent tool, which handles either bunker-based signing or standard private key signing.
    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);
    }
  • The schema definition for the signNostrEvent tool input.
    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-80 (registration)
    The registration of the signNostrEvent tool in the MCP server instance.
    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