nostr-bray 3.12.1 → 3.12.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/relay/tools.js +12 -1
- package/package.json +1 -1
package/dist/relay/tools.js
CHANGED
|
@@ -7,6 +7,7 @@ import { handleRelayCount } from './count.js';
|
|
|
7
7
|
import { handleRelayAuth } from './auth.js';
|
|
8
8
|
import { handleCastSpell } from './spell.js';
|
|
9
9
|
import { flatOrWrapped, mergeFlatAndWrapped } from '../util/schema.js';
|
|
10
|
+
import { isNormalRequestEnd } from '../relay-pool.js';
|
|
10
11
|
export function registerRelayTools(server, deps) {
|
|
11
12
|
server.registerTool('relay-list', {
|
|
12
13
|
description: 'List the relay set (read/write) for the active identity. Optionally check for shared relays with another identity.',
|
|
@@ -51,7 +52,7 @@ export function registerRelayTools(server, deps) {
|
|
|
51
52
|
};
|
|
52
53
|
});
|
|
53
54
|
server.registerTool('relay-query', {
|
|
54
|
-
description: 'Query events from Nostr relays by kind, author, ids, tags, or time range. Useful for discovering events, scanning for specific kinds, or investigating unknown event schemas. Uses explicit relays if provided, otherwise the active identity\'s read relays. Filter fields may be supplied either as top-level arguments or wrapped in a single "filter" object (both shapes are accepted).',
|
|
55
|
+
description: 'Query events from Nostr relays by kind, author, ids, tags, or time range. Useful for discovering events, scanning for specific kinds, or investigating unknown event schemas. Uses explicit relays if provided, otherwise the active identity\'s read relays. Filter fields may be supplied either as top-level arguments or wrapped in a single "filter" object (both shapes are accepted). Relays that refuse the REQ (for example "auth-required:" or "restricted:") or cannot be reached are listed under "refused", with their reasons.',
|
|
55
56
|
inputSchema: {
|
|
56
57
|
ids: z.array(z.string()).optional().describe('Event IDs (hex) to fetch directly'),
|
|
57
58
|
kinds: z.array(z.number().int()).optional().describe('Event kinds to filter by (e.g. [30301, 31000])'),
|
|
@@ -86,6 +87,9 @@ export function registerRelayTools(server, deps) {
|
|
|
86
87
|
// "filter" key and the handler receives an empty object, yielding a firehose response.
|
|
87
88
|
const f = args.filter ?? {};
|
|
88
89
|
const mergedLimit = args.limit ?? f.limit ?? 50;
|
|
90
|
+
// Relays that refused the REQ or could not be reached, once each. Without
|
|
91
|
+
// them a refusal reads as "no matching events".
|
|
92
|
+
const refused = new Map();
|
|
89
93
|
const events = await handleRelayQuery(deps.pool, deps.ctx.activeNpub, {
|
|
90
94
|
ids: args.ids ?? f.ids,
|
|
91
95
|
kinds: args.kinds ?? f.kinds,
|
|
@@ -98,6 +102,12 @@ export function registerRelayTools(server, deps) {
|
|
|
98
102
|
search: args.search ?? f.search,
|
|
99
103
|
paginate: args.paginate,
|
|
100
104
|
maxPages: args.max_pages,
|
|
105
|
+
onRelayClose: reasons => {
|
|
106
|
+
for (const { url, reason } of reasons) {
|
|
107
|
+
if (!isNormalRequestEnd(reason))
|
|
108
|
+
refused.set(`${url}\n${reason}`, { relay: url, reason });
|
|
109
|
+
}
|
|
110
|
+
},
|
|
101
111
|
});
|
|
102
112
|
const summary = events.map(e => ({
|
|
103
113
|
id: e.id,
|
|
@@ -116,6 +126,7 @@ export function registerRelayTools(server, deps) {
|
|
|
116
126
|
...(maybeMore ? {
|
|
117
127
|
note: `Returned exactly the limit (${mergedLimit}), so there may be more. Re-run with paginate: true to collect the full set, or raise the limit.`,
|
|
118
128
|
} : {}),
|
|
129
|
+
...(refused.size ? { refused: [...refused.values()] } : {}),
|
|
119
130
|
events: summary,
|
|
120
131
|
}, null, 2) }],
|
|
121
132
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nostr-bray",
|
|
3
|
-
"version": "3.12.
|
|
3
|
+
"version": "3.12.2",
|
|
4
4
|
"mcpName": "dev.forgesworn/bray",
|
|
5
5
|
"description": "Trust-aware Nostr MCP server, CLI and TypeScript SDK for AI agents and humans. Three dimensions of trust -- verification, proximity, and access -- woven into every interaction.",
|
|
6
6
|
"type": "module",
|