nostr-mcp-auth
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@nostr-mcp-authwhat tools do I have access to with my Nostr key?"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
nostr-mcp-auth
Lock MCP tools to a Nostr key
No proof, no tools. Agents sign every HTTP call with a Nostr secret. The server checks the signature offline. Wrong key, bad sig, stale event, or body swap: 401. Tool code never runs.
pip install -e .
nostr-mcp-auth quickstart
nostr-mcp-auth serve
# other terminal:
nostr-mcp-auth call --tool whoamiCrypto identity for agent tool access. No OAuth dance required for the lab or fleet path.
What is Nostr?
Nostr is a simple open protocol for signed messages. Each user (or agent) has:
Piece | What it is |
nsec | Private key. Signs. Keep offline / in a vault. |
npub | Public key. Identity. Safe to put on an allowlist. |
Messages (events) are JSON objects with a BIP-340 Schnorr signature. Anyone can verify who signed without a central account server.
Common uses: social apps, relays, Lightning wallet connect. The part we care about for MCP is pure crypto identity: prove key possession.
You do not need Damus, a public relay, or a social profile for this package. Verification is local.
NIP-98 (HTTP auth)
NIP-98 defines how to authorize an HTTP request with a short-lived signed event:
Kind 27235
Tags bind the request: URL (
u), method (method), optional body hash (payload)Header:
Authorization: Nostr <base64-encoded event>
That is the protocol. This repo turns it into a gate in front of MCP tools.
Related MCP server: Agent Identity MCP Server
How we use Nostr for MCP
MCP (Model Context Protocol) is how agents call tools over stdio or HTTP. Network MCP needs auth. We put NIP-98 on POST /mcp.
Step | What happens |
1 | Agent (or sidecar) builds a NIP-98 event for this exact URL, method, and body. |
2 | Signs with nsec. |
3 | Sends JSON-RPC ( |
4 | Server verifies: kind, signature, time window, URL/method match, body hash, allowlist, optional roles, replay. |
5 | Only then does the tool run. |
Agent / sidecar MCP server (this package)
| |
| POST /mcp |
| Authorization: Nostr <signed event> |
| tools/call { name, arguments } |
|----------------------------------------->|
| | verify NIP-98 (offline)
| | allowlist + roles
| | run tool OR 401/403
|<-----------------------------------------|What we take from Nostr
Keypair identity (
npub/nsec)Event shape + Schnorr signatures
NIP-98 request binding
What we do not need
Public relays for auth
Social graph, follows, or notes
Publishing the auth event anywhere
What we add
Fail-closed HTTP MCP surface (
tools/list,tools/call)Allow / deny lists and optional tool roles
Process-local replay defense
Operator CLI:
quickstart,serve,call,doctorRed-team tested gate (see
docs/)
Plug in
Install
git clone https://github.com/SamsonCyber/nostr-mcp-auth.git
cd nostr-mcp-auth
pip install -e .Bootstrap
nostr-mcp-auth quickstartFile | Purpose |
| Agent secret (never commit) |
| Public identity |
| Server config; npub already allowlisted |
Serve
nostr-mcp-auth serve
# http://127.0.0.1:8787/mcp
# http://127.0.0.1:8787/health (public)serve refuses auth.open=true and auth.trust_proxy=true unless you pass
--force-open or --force-trust-proxy (lab / reverse-proxy only).
Call
nostr-mcp-auth call --tool whoami
nostr-mcp-auth call --tool protected_echo --arg text=hello
nostr-mcp-auth list-tools
nostr-mcp-auth doctorPython
from nostr_mcp_auth.client import call_tool
print(call_tool("http://127.0.0.1:8787/mcp", "caller.nsec", "whoami"))See examples/python_agent.py.
Agent UIs that cannot sign (Claude Desktop, etc.)
Most hosts do not implement NIP-98. Options:
Local signing sidecar that holds
nsecand forwards signed HTTP.Keep high-risk tools on this HTTP gate; use stdio only where local trust is enough.
Unsigned or plain Bearer clients get 401. That is the gate doing its job.
Endpoints and demo tools
Path | Auth |
| Public |
| Public |
| Required |
Tool | Access |
| Allowlisted identity |
| Allowlisted identity |
| Role |
Wire real tools behind the same pattern, or terminate network MCP at this process.
Fail-closed checks
Check | Result |
Missing / wrong auth | 401, no tool side effects |
Bad signature / wrong kind | 401 |
Clock skew outside window | 401 |
URL or method mismatch | 401 |
Body hash mismatch | 401 |
Empty allowlist | 401 for everyone |
Deny list | Wins over allow |
Replay (same event id) | 401 (process-local) |
Missing tool role | 403 |
Auth failure body | Generic |
MCP responses |
|
Defaults: open: false, trust_proxy: false. Auth logs never print nsec or full
Authorization tokens. Multi-instance shared replay and stolen allowlisted nsec
remain residual (see residual risks).
More: SPEC · residual risks · red-team · wave 2
Config
auth:
open: false
allow_npubs:
- npub1...
roles:
npub1...: [tools:admin]
tools:
admin_ping:
roles: [tools:admin]
server:
host: 127.0.0.1
port: 8787Add agents by generating keys and appending npubs. Example: examples/mcp-auth.example.yaml.
CLI
Command | Job |
| Identity + config |
| Authenticated MCP HTTP ( |
| Signed client |
| Config + nsec + allowlist check |
| Manual pieces |
Dev
pip install -e ".[dev]"
pytest -qPython 3.10+. Uses coincurve for BIP-340.
License
MIT
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- AlicenseAqualityBmaintenanceMCP server that gates API calls to AI agents using proof-of-work (free) or Lightning payment (3 sats), providing challenge, verify, and status tools for per-call authentication without accounts.Last updated3671MIT
- Alicense-qualityDmaintenanceMCP Server for AI agent identity and authorization. Create, verify, and manage agent identities with trust scores and scoped authorization tokens.Last updatedMIT
- Flicense-qualityCmaintenanceRemote MCP server with built-in OAuth authentication via Cloudflare Access, enabling secure tool usage like math and image generation with user-based access control.Last updated
- Alicense-qualityCmaintenanceA read-only MCP server for AI agents to access Nostr profiles, notes, search, and relay lists through user-chosen relays, without requiring an account or keys.Last updatedMIT
Related MCP Connectors
MCP server teaching AI agents to implement TideCloak: auth, E2EE, IGA, security analysis
No-key MCP: audit/certify MCPs, signed trust history; join Gold Rush Town & build with your LLM.
MCP server connecting AI agents to non-custodial staking data across 130+ networks.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
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/SamsonCyber/nostr-mcp-auth'
If you have feedback or need assistance with the MCP directory API, please join our Discord server