toolmenu 0.28.0 → 0.28.1

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 CHANGED
@@ -131,7 +131,7 @@ jobs:
131
131
  - uses: actions/setup-node@v7
132
132
  with: { node-version: 22 }
133
133
  - run: npm ci && npm run build
134
- - uses: niksa90/toolmenu@v0.28.0
134
+ - uses: niksa90/toolmenu@v0.28.1
135
135
  with:
136
136
  command: node dist/server.js
137
137
  baseline: menu.json # your committed snapshot
package/dist/auth.d.ts CHANGED
@@ -90,6 +90,7 @@ export declare function pastedRedirect(text: string): URLSearchParams | undefine
90
90
  export declare function login(serverUrl: string, options?: LoginOptions): Promise<{
91
91
  name?: string;
92
92
  tools: number;
93
+ authenticated: boolean;
93
94
  }>;
94
95
  export declare function logout(serverUrl: string): Promise<boolean>;
95
96
  /** Stored logins: the server, its issuer, and when the tokens were saved. No secrets. */
package/dist/auth.js CHANGED
@@ -281,6 +281,8 @@ function printForPaste(port) {
281
281
  */
282
282
  export async function login(serverUrl, options = {}) {
283
283
  const port = options.port ?? DEFAULT_PORT;
284
+ // What was stored before this login (a registered client, a rejected token) is kept.
285
+ const stored = hasLogin(serverUrl);
284
286
  const callback = await listenForCallback(port, options.timeoutMs ?? 300_000);
285
287
  try {
286
288
  const provider = new StoredOAuthProvider(serverUrl, {
@@ -338,7 +340,13 @@ export async function login(serverUrl, options = {}) {
338
340
  await transport.finishAuth(params);
339
341
  await endSession(client, transport);
340
342
  }
341
- return await check(serverUrl);
343
+ // A server that never asked for credentials leaves nothing to log in with: the
344
+ // file the discovery step wrote holds no token, so drop it rather than list a login.
345
+ // A file from before this login stays: it may hold a registered client.
346
+ const authenticated = Boolean(await provider.tokens());
347
+ if (!authenticated && !stored)
348
+ await logout(serverUrl);
349
+ return { ...(await check(serverUrl)), authenticated };
342
350
  }
343
351
  catch (error) {
344
352
  // GitHub's hosted server, for one: no dynamic registration, so toolmenu can't
package/dist/cli.js CHANGED
@@ -575,7 +575,11 @@ async function authCommand(args, values) {
575
575
  if (values['client-secret'] && !values['client-id'])
576
576
  throw new UsageError('--client-secret goes with --client-id');
577
577
  const result = await login(url, { port, scope: values.scope, clientId: values['client-id'], clientSecret: values['client-secret'], noBrowser: values['no-browser'] });
578
- process.stdout.write(`Logged in to ${plain(result.name ?? url)} (${url}): it lists ${result.tools} tool${result.tools === 1 ? '' : 's'} with this login.\nsnapshot and session use it from now on (--no-auth to skip it); stored in ${authDir()}.\n`);
578
+ const count = `${result.tools} tool${result.tools === 1 ? '' : 's'}`;
579
+ process.stdout.write(result.authenticated
580
+ ? `Logged in to ${plain(result.name ?? url)} (${url}): it lists ${count} with this login.\nsnapshot and session use it from now on (--no-auth to skip it); stored in ${authDir()}.\n`
581
+ : `No login made for ${plain(result.name ?? url)} (${url}): it listed ${count} without asking for credentials, so nothing was stored.\n` +
582
+ `→ Next: A server like this usually asks for a login only when a tool is called. If session reports session/untested, pass a token with --header "Authorization: Bearer <token>".\n`);
579
583
  return 0;
580
584
  }
581
585
  /**
package/dist/connect.js CHANGED
@@ -182,6 +182,27 @@ export async function connect(target, options = {}) {
182
182
  await stderrEnded(stdioStderr, trace.exit ? STDERR_AFTER_EXIT_MS : 1000);
183
183
  }
184
184
  await endSession(client, transport);
185
+ // A 401 or 403 to server/discover alone isn't the server's last word: Dreamwork
186
+ // 1.10.0 answers it with a 401 while its 2025 handshake serves a guest menu. With
187
+ // the handshake left to toolmenu, and no stored login (a refused one is reported as
188
+ // such), try the 2025 one before calling it a login wall. A server that wants
189
+ // credentials refuses that too; one that fails it any other way (a 2026-only
190
+ // server) is reported with the first refusal, which is the one that explains it.
191
+ const discover = trace.http.get('server/discover')?.status;
192
+ if (target.kind === 'http' &&
193
+ !oauth &&
194
+ (!target.protocol || target.protocol === 'auto') &&
195
+ (discover === 401 || discover === 403) &&
196
+ !trace.sent.some((s) => s.method === 'initialize')) {
197
+ const refused = explain(error, trace, context);
198
+ try {
199
+ return await connect({ ...target, protocol: 'legacy' }, options);
200
+ }
201
+ catch (retry) {
202
+ const status = retry.status;
203
+ throw status === 401 || status === 403 ? retry : refused;
204
+ }
205
+ }
185
206
  throw explain(error, trace, context);
186
207
  }
187
208
  const wire = new WireLog();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "toolmenu",
3
- "version": "0.28.0",
3
+ "version": "0.28.1",
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)",