Skip to main content
Glama

nostr-mcp

一个用于安全探索 Nostr 的只读 Model Context Protocol 服务器。它为代理提供语义化工具,用于解析 Nostr 标识符、读取个人资料和事件、查询笔记以及检查中继元数据。

此首个版本刻意不接受私钥或发布事件。签名将通过远程签名器(如 NIP-46)添加,并带有明确的用户批准边界。

工具

工具

用途

nostr_resolve_identity

解码十六进制、npubnprofilenoteneventnaddr 标识符

nostr_get_profile

获取某个公钥最新的有效 kind 0 个人资料

nostr_get_event

通过十六进制 ID、notenevent 获取单个事件

nostr_query_notes

使用有界过滤器查询已验证的 kind 1 笔记

nostr_inspect_relay

获取并规范化中继的 NIP-11 信息文档

每个返回的事件都包含提供它的中继。无效签名会被丢弃,重复事件会被合并,部分中继故障会被报告而不是隐藏。

要求

  • Node.js 20.19 或更高版本

  • 支持 stdio 服务器的 MCP 主机

为 Codex 安装

使用一条命令安装并注册服务器:

npx -y @diegoyegros/nostr-mcp install

验证注册:

npx -y @diegoyegros/nostr-mcp doctor
codex mcp list

安装程序会将此 stdio 命令存储在 Codex 中:

npx -y @diegoyegros/nostr-mcp@latest

使用以下命令移除注册:

npx -y @diegoyegros/nostr-mcp uninstall

作为 Codex 插件安装

该仓库也是一个 Codex 插件市场,包含 MCP 服务器和一个捆绑的 Nostr 技能:

codex plugin marketplace add DiegoYegros/nostr-mcp --ref master

打开 Codex,运行 /plugins,选择 Nostr Plugins,然后安装 Nostr MCP。该插件是只读的,并添加了用于解析标识符、查询公共笔记、检查事件以及报告中继来源的指南。

直接 MCP 安装程序和插件安装是两种可选方案。安装插件后即可获得其捆绑的 MCP 服务器。

与任何 MCP 客户端一起运行

npm 包发布后,任何兼容 stdio 的 MCP 主机都可以使用以下命令启动它:

npx -y @diegoyegros/nostr-mcp@latest

示例 MCP 客户端配置:

{
  "mcpServers": {
    "nostr": {
      "command": "npx",
      "args": ["-y", "@diegoyegros/nostr-mcp@latest"],
      "env": {
        "NOSTR_RELAYS": "wss://relay.damus.io,wss://nos.lol"
      }
    }
  }
}

从源码运行

npm install
npm run build
node dist/index.js

使用 Codex 注册源码检出:

codex mcp add nostr -- "$(command -v node)" "$PWD/dist/index.js"

配置

变量

默认值

含义

NOSTR_RELAYS

wss://relay.damus.io,wss://nos.lol,wss://relay.primal.net

逗号分隔的默认中继 URL

NOSTR_QUERY_TIMEOUT_MS

5000

每次查询的超时时间,限制在 500-30000 毫秒

NOSTR_MAX_RELAYS

8

每次工具调用最多使用的中继数,限制在 1-20

默认只接受公共 wss:// 中继 URL。包含凭据、片段、回环主机或私网 IP 地址的 URL 将被拒绝。

当工具调用提供 relay_urls 时,仅查询这些中继。否则,在尝试配置的默认值之前,会先尝试来自 NIP-19 标识符的安全中继提示。

开发

npm run check

检查包括类型检查、54 个单元测试和集成测试、现代 MCP stdio 协商冒烟测试、安装程序 CLI、插件元数据一致性以及 npm 包内容。中继测试使用假中继和签名固定数据,因此它们是确定性的,不依赖于公共中继的可用性。

在不发布的情况下预览 npm 工件:

npm pack --dry-run

发布

npm 名称是 @diegoyegros/nostr-mcp。可以使用以下命令手动发布首个版本:

npm login
npm publish --access public

包含的 prepublishOnly 钩子会在发布前运行完整的验证套件。后续版本可以通过在配置仓库的 NPM_TOKEN 密钥后创建 GitHub release 来自动化。发布工作流会使用 npm 来源证明发布包。

安全模型

  • 只读 MCP 工具注解

  • 不接受 nsec 或原始私钥输入

  • 在事件到达代理之前进行签名验证

  • 严格的中继 URL 验证以降低 SSRF 风险

  • 有界的中继数量、结果大小和超时时间

  • 查询结果中的中继来源和每个中继的错误

有关报告和信任边界的详细信息,请参阅 SECURITY.md

许可证

MIT

-
license - not tested
-
quality - not tested
C
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

View all MCP Connectors

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/DiegoYegros/nostr-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server