MCP server giving AI agents sovereign Nostr identities. 238 tools across 27 groups.
npm run build— compile TypeScript to dist/npm test— run all tests (vitest, 1098 tests)npm run test:watch— watch modenpm run lint— type-check without emitting (tsc --noEmit)npm start— run the MCP server (requires NOSTR_SECRET_KEY + NOSTR_RELAYS)node dist/cli.js --help— CLI help
Single-process MCP server. Entry points:
src/index.ts— MCP server (config → IdentityContext → RelayPool → tool registration → transport)src/cli.ts— CLI wrapper (same handlers, no MCP)
Central spine: IdentityContext in src/context.ts manages the nsec-tree root, LRU identity cache with cryptographic zeroing, and signing. TrustContext in src/trust-context.ts aggregates trust signals across verification (Signet), proximity (WoT), and access (Dominion) dimensions.
Handler extraction pattern: Each tool group has:
src/<group>/handlers.ts— pure logic functions (testable without MCP)src/<group>/tools.ts— Zod schemas +server.registerTool()wiringtest/<group>/handlers.test.ts— unit tests for handlers
Source directories (16): identity/, social/ (includes blossom, dm, groups, nips, notifications), trust/, relay/, zap/, safety/, signet/, vault/, util/, workflow/ (trust-score, feed-discover, verify-person, identity-setup, identity-recover, relay-health), dispatch/ (13 tools: send, check, reply, ack, status, cancel, refuse, failure, query, propose, capability-publish, capability-discover, capability-read), handler/, marketplace/, moderation/, privacy/, widgets/. The 27 user-facing groups in README/llms.txt split social/ into sub-groups (dm, blossom, articles, calendar, badges, communities, groups, wiki, search, scheduling, community NIPs).
Shared modules:
src/config.ts— env var + file secret loading, format detectionsrc/relay-pool.ts— relay connections with SOCKS5h proxy, write queue, Tor policysrc/nip65.ts— NIP-65 relay list fetch with signature verification + TTL cachesrc/validation.ts— Zod validators (hexId,relayUrl)
@modelcontextprotocol/sdk— MCP server frameworknostr-tools— Nostr event creation, signing, NIP-17/44/04 encryptionnsec-tree— hierarchical identity derivation from master secret@forgesworn/ring-sig— SAG ring signatures on secp256k1@forgesworn/shamir-words— Shamir Secret Sharing with BIP-39 outputnostr-attestations— NIP-VA kind 31000 attestation builders/validatorsspoken-token— HMAC-based spoken verification tokenscanary-kit— duress detection (imported via spoken-token)signet-protocol— identity verification protocol (Signet badge and credential types)dominion-protocol— epoch-based encrypted access control (Shamir, HKDF vault keys)
- British English everywhere
- Git:
type: descriptioncommits. NoCo-Authored-Bylines. - Branch: work on branches, merge to main.
forgesworn/anvil@v0handles releases via workflow_call. - Security: never return private keys in tool responses. Zeroise buffers in
finallyblocks. Validate all external input.
Be extra careful when modifying:
src/context.ts— key material lifecycle, zeroise on eviction/destroysrc/zap/handlers.ts— NWC secret handling, NIP-44 encrypt/decryptsrc/config.ts— secret loading and env var cleanupsrc/relay-pool.ts— Tor policy enforcementsrc/nip65.ts— event signature verificationsrc/index.ts— HTTP auth, rate limiting, body size limitssrc/trust-context.ts— trust signal aggregation across verification, proximity, and access dimensionssrc/signet/— Signet badge fetching, credential validation, policy enforcementsrc/vault/— Dominion vault key derivation, epoch rotation, access tier management