toolmenu 0.27.0 → 0.28.0
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/README.md +144 -876
- package/dist/apps.d.ts +4 -0
- package/dist/apps.js +3 -2
- package/dist/cli.js +14 -3
- package/dist/config.d.ts +4 -0
- package/dist/config.js +4 -0
- package/dist/connect.d.ts +2 -0
- package/dist/connect.js +6 -4
- package/dist/help.js +5 -3
- package/dist/mcp.d.ts +1 -1
- package/dist/mcp.js +47 -7
- package/dist/options.d.ts +6 -0
- package/dist/options.js +2 -0
- package/dist/report.d.ts +5 -1
- package/dist/report.js +4 -1
- package/dist/resource-read.d.ts +74 -0
- package/dist/resource-read.js +311 -0
- package/dist/review.js +1 -1
- package/dist/rule-docs.json +16 -1
- package/dist/rules/apps.js +50 -1
- package/dist/rules/index.js +4 -1
- package/dist/rules/lists.d.ts +3 -0
- package/dist/rules/lists.js +164 -2
- package/dist/rules/rule.d.ts +2 -0
- package/dist/snapshot.d.ts +10 -0
- package/dist/snapshot.js +20 -1
- package/package.json +1 -1
package/dist/rules/rule.d.ts
CHANGED
|
@@ -50,6 +50,8 @@ export interface RuleContext {
|
|
|
50
50
|
serverUrl?: string;
|
|
51
51
|
/** snapshot: what resources/read gave for each ui:// resource the tools name (MCP Apps). */
|
|
52
52
|
appResources?: import('../apps.js').AppResource[];
|
|
53
|
+
/** snapshot --read-resources: what resources/read gave for the listed resources (lists/resource-* rules). */
|
|
54
|
+
resourceReads?: import('../resource-read.js').ResourceReads;
|
|
53
55
|
/**
|
|
54
56
|
* Set by runRules from the `ignore` setting. Rules that sum many tools up in
|
|
55
57
|
* one finding use it to leave ignored tools out of the summary; findings about
|
package/dist/snapshot.d.ts
CHANGED
|
@@ -26,6 +26,10 @@ export interface SnapshotOptions extends RuleSettings {
|
|
|
26
26
|
identities?: Identity[];
|
|
27
27
|
/** --lists: which lists besides tools to read and check (prompts, resources). */
|
|
28
28
|
lists?: string[];
|
|
29
|
+
/** --read-resources: resources/read on each resource resources/list names (needs resources in lists). */
|
|
30
|
+
readResources?: boolean;
|
|
31
|
+
/** --max-reads: at most this many reads, spread over the list. */
|
|
32
|
+
maxReads?: number;
|
|
29
33
|
/** --client: check the menu for this client (src/clients.ts): its description cut, its search, its name format. */
|
|
30
34
|
client?: string;
|
|
31
35
|
/** --offline-check (stdio): list the menu once more with the network cut off (menu/network-dependent). */
|
|
@@ -40,6 +44,12 @@ export interface SnapshotResult {
|
|
|
40
44
|
cost?: ClientCost;
|
|
41
45
|
/** --lists: lists asked for that the server declares no capability for, so weren't read. */
|
|
42
46
|
notOffered?: ListKind[];
|
|
47
|
+
/** --read-resources: how many listed resources were read, of how many listed. */
|
|
48
|
+
resourcesRead?: {
|
|
49
|
+
read: number;
|
|
50
|
+
listed: number;
|
|
51
|
+
byApps?: number;
|
|
52
|
+
};
|
|
43
53
|
}
|
|
44
54
|
/** Establish the menu: connect, list the tools twice, run the menu rules. */
|
|
45
55
|
export declare function snapshot(given: Target, options?: SnapshotOptions): Promise<SnapshotResult>;
|
package/dist/snapshot.js
CHANGED
|
@@ -5,6 +5,7 @@ import { buildMenu } from './menu.js';
|
|
|
5
5
|
import { asIdentity, connectPatiently, isContainerWrapper, MAIN_SEED, PROBE_SEED, probeMenu, probeSameEra, probeVariance, seeded } from './probe.js';
|
|
6
6
|
import { kindsToRead, readList } from './lists.js';
|
|
7
7
|
import { agentMenu, readAppResources, resourceUriOf } from './apps.js';
|
|
8
|
+
import { readResources } from './resource-read.js';
|
|
8
9
|
import { readServerCard } from './card.js';
|
|
9
10
|
import { listingsDiffer } from './rules/capabilities.js';
|
|
10
11
|
import { isCredentialHeader } from './explain.js';
|
|
@@ -14,6 +15,8 @@ import { MENU_RULES, runRules } from './rules/index.js';
|
|
|
14
15
|
import { catalogFindings, readCatalog } from './catalog.js';
|
|
15
16
|
import { SEVERITY_RANK } from './types.js';
|
|
16
17
|
import { shellWord } from './init.js';
|
|
18
|
+
/** The rules about --read-resources: with all of them off, nothing is read. */
|
|
19
|
+
const READ_RULES = ['lists/resource-unreadable', 'lists/resource-read-schema', 'lists/resource-unread'];
|
|
17
20
|
/** Establish the menu: connect, list the tools twice, run the menu rules. */
|
|
18
21
|
export async function snapshot(given, options = {}) {
|
|
19
22
|
const [mainIdentity, ...otherIdentities] = options.identities ?? [];
|
|
@@ -31,6 +34,7 @@ export async function snapshot(given, options = {}) {
|
|
|
31
34
|
const reads = [];
|
|
32
35
|
let undeclared = [];
|
|
33
36
|
let appResources;
|
|
37
|
+
let resourceReads;
|
|
34
38
|
try {
|
|
35
39
|
first = await patiently(() => listTools(connection, options), { error: tooMany });
|
|
36
40
|
const second = await patiently(() => listTools(connection, options), { error: tooMany });
|
|
@@ -58,6 +62,20 @@ export async function snapshot(given, options = {}) {
|
|
|
58
62
|
if (options.rules?.['apps/resource'] !== 'off' && menu.tools.some((t) => resourceUriOf(t)?.startsWith('ui://'))) {
|
|
59
63
|
appResources = await readAppResources(connection, menu.tools, options.timeoutMs);
|
|
60
64
|
}
|
|
65
|
+
// --read-resources: each listed resource, read as a client does when one is picked.
|
|
66
|
+
// Only when the list was read, and some rule would say something about the reads.
|
|
67
|
+
const resources = reads.find((r) => r.kind === 'resources');
|
|
68
|
+
if (options.readResources && resources && !resources.first.error && READ_RULES.some((id) => options.rules?.[id] !== 'off')) {
|
|
69
|
+
resourceReads = await readResources(connection, resources.first.items, {
|
|
70
|
+
timeoutMs: options.timeoutMs,
|
|
71
|
+
maxReads: options.maxReads,
|
|
72
|
+
// A ui:// resource the Apps pass has a record for is apps/resource's, whatever it got.
|
|
73
|
+
appUris: (appResources ?? []).map((r) => r.uri),
|
|
74
|
+
second: resources.second && !resources.second.error ? resources.second.items : undefined,
|
|
75
|
+
protocolVersion: connection.protocolVersion,
|
|
76
|
+
truncated: resources.first.truncated,
|
|
77
|
+
});
|
|
78
|
+
}
|
|
61
79
|
if (options.catalog) {
|
|
62
80
|
menu.catalog = await readCatalog(connection, menu.tools, { ...(typeof options.catalog === 'object' ? options.catalog : {}), timeoutMs: options.timeoutMs });
|
|
63
81
|
}
|
|
@@ -162,6 +180,7 @@ export async function snapshot(given, options = {}) {
|
|
|
162
180
|
...(offline ? { offline } : {}),
|
|
163
181
|
...(plain ? { plain } : {}),
|
|
164
182
|
...(appResources ? { appResources } : {}),
|
|
183
|
+
...(resourceReads ? { resourceReads } : {}),
|
|
165
184
|
...(card ? { serverCard: card } : {}),
|
|
166
185
|
...(target.kind === 'http' ? { serverUrl: new URL(target.url).origin + new URL(target.url).pathname } : {}),
|
|
167
186
|
...(connection.era === 'legacy' && eras.has('modern') ? { laterModern: true } : {}),
|
|
@@ -181,7 +200,7 @@ export async function snapshot(given, options = {}) {
|
|
|
181
200
|
}
|
|
182
201
|
// What the agent pays: app-only tools aren't in its list.
|
|
183
202
|
const cost = options.client ? clientCost(options.client, agentMenu(menu).shown) : undefined;
|
|
184
|
-
return { menu, findings, ...(identities ? { identities } : {}), ...(cost ? { cost } : {}), ...(undeclared.length ? { notOffered: undeclared } : {}) };
|
|
203
|
+
return { menu, findings, ...(identities ? { identities } : {}), ...(cost ? { cost } : {}), ...(undeclared.length ? { notOffered: undeclared } : {}), ...(resourceReads ? { resourcesRead: { read: resourceReads.reads.length, listed: resourceReads.listed, ...(resourceReads.byApps ? { byApps: resourceReads.byApps } : {}) } } : {}) };
|
|
185
204
|
}
|
|
186
205
|
/**
|
|
187
206
|
* The target with every credential it carries swapped for one that can't be valid,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "toolmenu",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.28.0",
|
|
4
4
|
"mcpName": "io.github.niksa90/toolmenu",
|
|
5
5
|
"description": "Test your MCP server the way agents and clients meet it: the menu, the calls, the results, the sign-in, and every release after. No LLM involved.",
|
|
6
6
|
"author": "Nikša Perović (https://niksa.me)",
|