From 767725023edf1a34cc1ef7a83adab61036cebe03 Mon Sep 17 00:00:00 2001 From: Michal Date: Mon, 23 Feb 2026 19:03:07 +0000 Subject: [PATCH] feat: --project flag scopes get servers/instances to project MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit mcpctl --project NAME get servers — shows only servers attached to the project mcpctl --project NAME get instances — shows only instances of project servers Co-Authored-By: Claude Opus 4.6 --- src/cli/src/index.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/cli/src/index.ts b/src/cli/src/index.ts index 89ad9ad..cefad1c 100644 --- a/src/cli/src/index.ts +++ b/src/cli/src/index.ts @@ -54,6 +54,21 @@ export function createProgram(): Command { })); const fetchResource = async (resource: string, nameOrId?: string): Promise => { + const projectName = program.opts().project as string | undefined; + + // --project scoping for servers and instances + if (projectName && !nameOrId && (resource === 'servers' || resource === 'instances')) { + const projectId = await resolveNameOrId(client, 'projects', projectName); + if (resource === 'servers') { + return client.get(`/api/v1/projects/${projectId}/servers`); + } + // instances: fetch project servers, then filter instances by serverId + const projectServers = await client.get>(`/api/v1/projects/${projectId}/servers`); + const serverIds = new Set(projectServers.map((s) => s.id)); + const allInstances = await client.get>(`/api/v1/instances`); + return allInstances.filter((inst) => serverIds.has(inst.serverId)); + } + if (nameOrId) { // Glob pattern — use query param filtering if (nameOrId.includes('*')) {