From 97ade470df8f2861abe5522b1d4f79c6534937c0 Mon Sep 17 00:00:00 2001 From: Michal Date: Sun, 22 Feb 2026 16:39:21 +0000 Subject: [PATCH] fix: resolve resource names in get/describe (not just IDs) fetchResource and fetchSingleResource now use resolveNameOrId so `mcpctl get server ha-mcp` works by name, not just by ID. Co-Authored-By: Claude Opus 4.6 --- src/cli/src/index.ts | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/cli/src/index.ts b/src/cli/src/index.ts index 35c1dc7..9e1976f 100644 --- a/src/cli/src/index.ts +++ b/src/cli/src/index.ts @@ -18,6 +18,7 @@ import { createLoginCommand, createLogoutCommand } from './commands/auth.js'; import { ApiClient } from './api-client.js'; import { loadConfig } from './config/index.js'; import { loadCredentials } from './auth/index.js'; +import { resolveNameOrId } from './commands/shared.js'; export function createProgram(): Command { const program = new Command() @@ -48,15 +49,27 @@ export function createProgram(): Command { const client = new ApiClient({ baseUrl, token: creds?.token ?? undefined }); - const fetchResource = async (resource: string, id?: string): Promise => { - if (id) { + const fetchResource = async (resource: string, nameOrId?: string): Promise => { + if (nameOrId) { + let id: string; + try { + id = await resolveNameOrId(client, resource, nameOrId); + } catch { + id = nameOrId; + } const item = await client.get(`/api/v1/${resource}/${id}`); return [item]; } return client.get(`/api/v1/${resource}`); }; - const fetchSingleResource = async (resource: string, id: string): Promise => { + const fetchSingleResource = async (resource: string, nameOrId: string): Promise => { + let id: string; + try { + id = await resolveNameOrId(client, resource, nameOrId); + } catch { + id = nameOrId; + } return client.get(`/api/v1/${resource}/${id}`); };