Skip to content

Claude Code. Any Model. The most powerful AI coding agent now speaks every language.

fix(mcp): list models in list_models without provider specs

Jack Rudenkoec80094ed97a
diff --git a/packages/cli/src/recommended-capabilities.test.ts b/packages/cli/src/recommended-capabilities.test.ts
index 33e313de..31d2de91 100644
--- a/packages/cli/src/recommended-capabilities.test.ts
+++ b/packages/cli/src/recommended-capabilities.test.ts
@@ -36,7 +36,6 @@ const catalog: RecommendationCatalogSnapshot = {
const now = new Date(meta.capturedAt);
const project = (snapshot = catalog) =>
projectRecommendations(recommendations, snapshot, top100.models, now);
-const noNativePrefix = (_vendorSlug: string): string | null => null;
const capabilityLines = (markdown: string) =>
markdown.split("\n").filter((line) => line.startsWith("- **Capabilities**:"));
const expectedCapabilityLine = (entry: SlimEntry) => {
@@ -102,7 +101,7 @@ describe("recommended model capabilities", () => {
test("renders one nonempty capabilities line per recorded row with flags in contract order", () => {
const doc = project();
- const lines = capabilityLines(renderRecommendedMarkdown(doc, noNativePrefix));
+ const lines = capabilityLines(renderRecommendedMarkdown(doc));
expect(doc.models.length).toBeGreaterThanOrEqual(20);
expect(lines).toHaveLength(doc.models.length);
expect(lines).not.toContain("- **Capabilities**: none");
@@ -119,15 +118,13 @@ describe("recommended model capabilities", () => {
const { modelId, doc } = withoutCapabilities();
const affected = doc.models.filter((row) => row.id === modelId);
expect(affected.length).toBeGreaterThan(0);
- const lines = capabilityLines(renderRecommendedMarkdown(doc, noNativePrefix));
+ const lines = capabilityLines(renderRecommendedMarkdown(doc));
expect(lines).toHaveLength(doc.models.length);
expect(lines.filter((line) => line === "- **Capabilities**: none")).toHaveLength(
affected.length
);
// Render only the affected projected rows to verify which model owns the none lines.
- const modelLines = capabilityLines(
- renderRecommendedMarkdown({ ...doc, models: affected }, noNativePrefix)
- );
+ const modelLines = capabilityLines(renderRecommendedMarkdown({ ...doc, models: affected }));
expect(modelLines).toHaveLength(affected.length);
for (const line of modelLines) expect(line).toBe("- **Capabilities**: none");
});
diff --git a/packages/cli/src/recommended-effort-table.test.ts b/packages/cli/src/recommended-effort-table.test.ts
new file mode 100644
index 00000000..9006568f
--- /dev/null
+++ b/packages/cli/src/recommended-effort-table.test.ts
@@ -0,0 +1,164 @@
+import { afterEach, describe, expect, spyOn, test } from "bun:test";
+import { mkdtempSync, readFileSync, rmSync } from "node:fs";
+import { tmpdir } from "node:os";
+import { join } from "node:path";
+import {
+ type EffortRecommendation,
+ latestEffortRecommendations,
+ writeEffortRecommendations,
+} from "./providers/effort-recommendations.js";
+import { renderEffortTableMarkdown } from "./recommended-listing.js";
+
+type Efforts = Record<string, Record<string, EffortRecommendation>>;
+const capture = JSON.parse(
+ readFileSync(
+ join(import.meta.dir, "test-fixtures/effort-recommendations/recommended-2.3.0.json"),
+ "utf8"
+ )
+) as { generationId: string; data: { recommendations: { efforts: Efforts } } };
+const raw = capture.data.recommendations.efforts;
+const models = Object.keys(raw).sort();
+const taskTypes = [...new Set(Object.values(raw).flatMap((tasks) => Object.keys(tasks)))].sort();
+
+function tableRows(markdown: string): string[][] {
+ return markdown
+ .split("\n")
+ .filter((line) => line.startsWith("|"))
+ .map((line) =>
+ line
+ .split("|")
+ .slice(1, -1)
+ .map((cell) => cell.trim())
+ );
+}
+
+describe("renderEffortTableMarkdown with captured recommendations", () => {
+ test("includes the heading and every task type as a sorted column", () => {
+ const markdown = renderEffortTableMarkdown(raw);
+ expect(markdown).toContain("## Recommended effort by task type");
+ expect(taskTypes.length).toBeGreaterThan(0);
+ expect(tableRows(markdown)[0]).toEqual(["model", ...taskTypes]);
+ });
+
+ test("renders exactly one sorted row per canonical model id and every captured effort", () => {
+ // Reverse both dimensions so insertion order cannot satisfy the sorting assertions.
+ const reversed = Object.fromEntries(
+ [...models]
+ .reverse()
+ .map((model) => [
+ model,
+ Object.fromEntries(Object.entries(raw[model]).sort(([a], [b]) => b.localeCompare(a))),
+ ])
+ );
+ const rows = tableRows(renderEffortTableMarkdown(reversed));
+ expect(rows[0]).toEqual(["model", ...taskTypes]);
+ expect(rows.slice(2).map(([model]) => model)).toEqual(models);
+ expect(rows).toHaveLength(models.length + 2);
+ for (const [index, model] of models.entries()) {
+ expect(rows[index + 2]).toEqual([
+ model,
+ ...taskTypes.map((task) => raw[model][task]?.effort ?? "-"),
+ ]);
+ }
+ });
+
+ test("renders a missing cell as a dash without dropping its row or column", () => {
+ const sparse = structuredClone(raw);
+ const model = models[0];
+ const task = Object.keys(sparse[model]).sort()[0];
+ // Negative variant of the real capture: remove one cell, invent no replacements.
+ expect(sparse[model][task]).toBeDefined();
+ delete sparse[model][task];
+ const rows = tableRows(renderEffortTableMarkdown(sparse));
+ const column = rows[0].indexOf(task);
+ expect(column).toBeGreaterThan(0);
+ expect(rows.slice(2).map(([id]) => id)).toEqual(models);
+ expect(rows[models.indexOf(model) + 2][column]).toBe("-");
+ for (const [index, id] of models.entries()) {
+ expect(rows[index + 2]).toEqual([
+ id,
+ ...taskTypes.map((type) =>
+ id === model && type === task ? "-" : (raw[id][type]?.effort ?? "-")
+ ),
+ ]);
+ }
+ });
+
+ test("returns an empty string for no recommendations", () => {
+ expect(renderEffortTableMarkdown({})).toBe("");
+ });
+});
+
+const dirs: string[] = [];
+function sidecarPath(): string {
+ const dir = mkdtempSync(join(tmpdir(), "latest-effort-test-"));
+ dirs.push(dir);
+ return join(dir, "catalog.efforts.json");
+}
+afterEach(() => {
+ for (const dir of dirs.splice(0)) rmSync(dir, { recursive: true, force: true });
+});
+
+function expectedCells(efforts: Efforts): Efforts {
+ return Object.fromEntries(
+ Object.entries(efforts).map(([model, tasks]) => [
+ model,
+ Object.fromEntries(
+ Object.entries(tasks).map(([task, cell]) => [
+ task,
+ { effort: cell.effort, basis: cell.basis, sendableOn: cell.sendableOn },
+ ])
+ ),
+ ])
+ );
+}
+
+describe("latestEffortRecommendations with a test-owned sidecar", () => {
+ test("returns null when the sidecar does not exist", () => {
+ expect(latestEffortRecommendations(sidecarPath())).toBeNull();
+ });
+
+ test("returns the newest written generation and its data after an earlier read", () => {
+ const path = sidecarPath();
+ const firstId = `${capture.generationId}-z`;
+ const secondId = `${capture.generationId}-a`;
+ const subset = { [models[0]]: raw[models[0]] };
+ const clock = spyOn(Date, "now");
+ try {
+ clock.mockReturnValue(1000);
+ writeEffortRecommendations(firstId, subset, path);
+ expect(latestEffortRecommendations(path)).toEqual({
+ generationId: firstId,
+ efforts: expectedCells(subset),
+ });
+ clock.mockReturnValue(2000);
+ writeEffortRecommendations(secondId, raw, path);
+ } finally {
+ clock.mockRestore();
+ }
+ expect(latestEffortRecommendations(path)).toEqual({
+ generationId: secondId,
+ efforts: expectedCells(raw),
+ });
+ });
+
+ test("selects by writtenAt rather than generation id or insertion order", () => {
+ const path = sidecarPath();
+ const newestId = `${capture.generationId}-a`;
+ const olderId = `${capture.generationId}-z`;
+ const subset = { [models[0]]: raw[models[0]] };
+ const clock = spyOn(Date, "now");
+ try {
+ clock.mockReturnValue(2000);
+ writeEffortRecommendations(newestId, raw, path);
+ clock.mockReturnValue(1000);
+ writeEffortRecommendations(olderId, subset, path);
+ } finally {
+ clock.mockRestore();
+ }
+ expect(latestEffortRecommendations(path)).toEqual({
+ generationId: newestId,
+ efforts: expectedCells(raw),
+ });
+ });
+});
diff --git a/packages/cli/src/recommended-listing.muse-access.test.ts b/packages/cli/src/recommended-listing.muse-access.test.ts
index e873b6f8..bbb9ac43 100644
--- a/packages/cli/src/recommended-listing.muse-access.test.ts
+++ b/packages/cli/src/recommended-listing.muse-access.test.ts
@@ -8,7 +8,7 @@ import {
} from "./recommended-listing.js";
import museCatalog from "./test-fixtures/catalog-v3/muse-code-g-20261021063612126-17350b71.json";
-// MTL-189 follow-up: D — Access lists only published routes and wire ids (generation g-20261021063612126-17350b71).
+// MTL-189 follow-up: CLI access lists published routes; MCP markdown names no provider.
const data = museCatalog as DiskCacheV3;
const plan = data.plans[0]!;
@@ -25,10 +25,13 @@ function listing(modelId: string) {
);
}
-function access(modelId: string): string {
- return renderRecommendedMarkdown(listing(modelId), nativeShortcutForVendor)
- .split("\n")
- .find((line) => line.startsWith("- **Access**:"))!;
+function expectProviderFreeMarkdown(modelId: string): void {
+ const markdown = renderRecommendedMarkdown(listing(modelId));
+ expect(markdown).toContain(modelId);
+ expect(markdown).not.toContain("**Access**");
+ expect(markdown).not.toContain("meta@");
+ expect(markdown).not.toContain("muse@");
+ expect(markdown).not.toContain("@");
}
test("Wonder Full has no metered Meta connection in the real data", () => {
@@ -39,12 +42,13 @@ test("Wonder Full has no metered Meta connection in the real data", () => {
expect(listing(model.modelId).models[0]!.subscription!.command).toBe("[email protected]");
});
-test("Wonder Full Access does not offer the unserved meta@ route", () => {
- expect(access("muse-wonder-full")).not.toContain("`meta@muse-wonder-full`");
+test("Wonder Full markdown names no provider for its base model", () => {
+ expectProviderFreeMarkdown("muse-wonder-full");
});
-test("Wonder Full Access offers the muse@ subscription shortcut", () => {
- expect(access("muse-wonder-full")).toContain("`muse@muse-wonder-full`");
+test("Wonder Full markdown omits the subscription command's provider", () => {
+ const modelId = data.entries.find((entry) => entry.modelId === "muse-wonder-full")!.modelId;
+ expectProviderFreeMarkdown(modelId);
});
test("Wonder Full text lists muse@ without the unserved meta@ route", () => {
@@ -59,8 +63,7 @@ test("Spark retains meta@ where the native API publishes a connection", () => {
expect(model.aggregators).toContainEqual(
expect.objectContaining({ route: { routeId: "meta", routeProfileId: "direct-api" } })
);
- expect(access(model.modelId)).toContain("`[email protected]`");
- expect(access(model.modelId)).toContain("`[email protected]`");
+ expectProviderFreeMarkdown(model.modelId);
const text = renderRecommendedText(listing(model.modelId), nativeShortcutForVendor);
const via = text.split("\n").find((line) => line.includes("via:"))!;
expect(via).toContain("meta@");
diff --git a/packages/cli/src/recommended-listing.test.ts b/packages/cli/src/recommended-listing.test.ts
index bba89d7c..c578e18d 100644
--- a/packages/cli/src/recommended-listing.test.ts
+++ b/packages/cli/src/recommended-listing.test.ts
@@ -180,7 +180,10 @@ describe("recommended listing renderers", () => {
test("T10/T14a R6/R8/R10 markdown prints ordered headings with descriptions on the next nonblank line", () => {
const doc = project(snapshot);
const before = structuredClone(doc);
- const output = renderRecommendedMarkdown(doc, noNativePrefix);
+ const output = renderRecommendedMarkdown(doc);
+ expect(output).not.toContain("**Access**");
+ expect(output).not.toContain("@");
+ expect(output).toContain("Pass each model by its bare id");
const lines = output.split("\n");
expect(
lines.filter(
@@ -215,10 +218,7 @@ describe("recommended listing renderers", () => {
expect(absent.some((section) => section.recommendationTier === "luxury")).toBe(true);
const doc = project(dryrun);
const groups = groupRecommendedModels(doc.models);
- const outputs = [
- renderRecommendedText(doc, noNativePrefix),
- renderRecommendedMarkdown(doc, noNativePrefix),
- ];
+ const outputs = [renderRecommendedText(doc, noNativePrefix), renderRecommendedMarkdown(doc)];
for (const def of absent) {
expect(groups.some((section) => section.recommendationTier === def.recommendationTier)).toBe(
false
@@ -249,7 +249,7 @@ describe("recommended listing renderers", () => {
const rows = doc.models.filter((row) => row.recommendationTier === "luxury");
expect(rows.map((row) => row.id)).toEqual([...new Set(expectedIds)]);
const text = renderRecommendedText(doc, noNativePrefix);
- const markdown = renderRecommendedMarkdown(doc, noNativePrefix);
+ const markdown = renderRecommendedMarkdown(doc);
for (const row of rows) {
const rich = live.richModels.find((model) => model.modelId === row.id);
expect(typeof rich?.pricing?.input).toBe("number");
@@ -270,7 +270,7 @@ describe("recommended listing renderers", () => {
const rows = doc.models.filter((row) => row.recommendationTier === "luxury");
expect(rows.length).toBeGreaterThan(0);
const text = renderRecommendedText(doc, noNativePrefix);
- const markdown = renderRecommendedMarkdown(doc, noNativePrefix);
+ const markdown = renderRecommendedMarkdown(doc);
for (const row of rows) {
expect(row.pricing).toEqual({ input: "N/A", output: "N/A", average: "N/A" });
expect(formatListingPrice(row, { compact: true })).toBe("N/A");
@@ -303,7 +303,7 @@ describe("recommended listing renderers", () => {
doc,
row,
renderRecommendedText(doc, noNativePrefix),
- renderRecommendedMarkdown(doc, noNativePrefix)
+ renderRecommendedMarkdown(doc)
);
for (const other of doc.models.filter((candidate) => candidate.id !== seed.id)) {
const previous = baseline.models.find(
@@ -325,7 +325,7 @@ describe("recommended listing renderers", () => {
if (!section) throw new Error("T14a requires a recorded nonempty subscription section");
expect(section.groups.length).toBeGreaterThan(0);
const text = renderRecommendedText(doc, noNativePrefix);
- const markdown = renderRecommendedMarkdown(doc, noNativePrefix);
+ const markdown = renderRecommendedMarkdown(doc);
for (const group of section.groups) {
const row = group.primary;
expect(typeof row.subscription?.command).toBe("string");
@@ -342,7 +342,7 @@ describe("recommended listing renderers", () => {
const error = spyOn(console, "error").mockImplementation(() => {});
try {
expect(typeof renderRecommendedText(doc, noNativePrefix)).toBe("string");
- expect(typeof renderRecommendedMarkdown(doc, noNativePrefix)).toBe("string");
+ expect(typeof renderRecommendedMarkdown(doc)).toBe("string");
expect(log).not.toHaveBeenCalled();
expect(warn).not.toHaveBeenCalled();
expect(error).not.toHaveBeenCalled();
diff --git a/packages/cli/src/recommended-listing.ts b/packages/cli/src/recommended-listing.ts
index 4ebaf46b..533f54e5 100644
--- a/packages/cli/src/recommended-listing.ts
+++ b/packages/cli/src/recommended-listing.ts
@@ -1,6 +1,7 @@
/**
* The two renderings of the recommended-models list: the `claudish --models-top`
- * text and the MCP `list_models` markdown.
+ * text and the MCP `list_models` markdown, plus the recommended-effort table
+ * `list_models` appends.
*
* Pure: each function returns text and prints nothing. Section order, headings and
* descriptions come from `RECOMMENDATION_SECTIONS` through `groupRecommendedModels`;
@@ -19,6 +20,7 @@ import {
normalizePricingDisplay,
quickPickCandidates,
} from "./model-loader.js";
+import type { ModelEffortRecommendations } from "./providers/effort-recommendations.js";
import { BUILTIN_PROVIDERS } from "./providers/provider-definitions.js";
import { nativeProviderForVendor } from "./providers/route-candidates.js";
@@ -128,7 +130,10 @@ export function renderRecommendedText(
return lines.join("\n");
}
-function markdownRow(group: RecommendedModelGroup, getNativePrefix: NativePrefixLookup): string {
+// No provider on any line: the MCP caller passes the bare heading id and claudish
+// routing picks the provider from the user's setup. An Access line listing the
+// catalog's `provider@` specs was copied into tool calls and bypassed that routing.
+function markdownRow(group: RecommendedModelGroup): string {
const m = group.primary;
const pricing = formatListingPrice(m);
const ctx = m.context || "N/A";
@@ -138,33 +143,27 @@ function markdownRow(group: RecommendedModelGroup, getNativePrefix: NativePrefix
if (m.supportsVision) caps.push("vision");
const capsLine = caps.length > 0 ? caps.join(", ") : "none";
- const prefixes = collectRoutingPrefixes(group, getNativePrefix);
- const accessLine =
- prefixes.length > 0 ? prefixes.map((p) => `\`${p}@${m.id}\``).join(" · ") : `\`${m.id}\``;
-
return [
`### ${m.id}`,
`- **Pricing**: ${pricing} avg · ${ctx} context`,
`- **Capabilities**: ${capsLine}`,
- `- **Access**: ${accessLine}`,
"",
].join("\n");
}
/** The full MCP `list_models` markdown. Prints nothing. */
-export function renderRecommendedMarkdown(
- doc: RecommendedModelsDoc,
- getNativePrefix: NativePrefixLookup
-): string {
+export function renderRecommendedMarkdown(doc: RecommendedModelsDoc): string {
const sections = groupRecommendedModels(doc.models);
let output = "# Recommended Models\n\n";
output += `_Last updated: ${doc.lastUpdated || "unknown"}_\n\n`;
+ output +=
+ "Pass each model by its bare id (the heading); claudish routing picks the provider.\n\n";
for (const section of sections) {
output += `## ${section.title}\n\n`;
if (section.description) output += `_${section.description}_\n\n`;
- for (const group of section.groups) output += markdownRow(group, getNativePrefix);
+ for (const group of section.groups) output += markdownRow(group);
}
const picks = computeQuickPicks(quickPickCandidates(sections));
@@ -190,3 +189,33 @@ export function renderRecommendedMarkdown(
return output;
}
+
+/**
+ * The catalog's recommended effort as one markdown table: a row per canonical
+ * model id, a column per task type, `-` where the catalog has no cell. The
+ * calling agent maps its own task to a column and passes the cell to `team`
+ * (`efforts`), `create_session` or `run_prompt` (`effort`). Empty string when
+ * there is nothing to show.
+ */
+export function renderEffortTableMarkdown(
+ efforts: Readonly<Record<string, ModelEffortRecommendations>>
+): string {
+ const models = Object.keys(efforts).sort();
+ if (models.length === 0) return "";
+ const taskTypes = [...new Set(models.flatMap((m) => Object.keys(efforts[m])))].sort();
+ const lines = [
+ "## Recommended effort by task type",
+ "",
+ "Map your task to a column, take the cell for each model you run, and pass it: " +
+ '`team` `efforts: {"<model>": "<level>"}` (keys exactly as in `models`), ' +
+ "`create_session` / `run_prompt` `effort`. A model with no cell keeps Claude Code's " +
+ "own effort.",
+ "",
+ `| model | ${taskTypes.join(" | ")} |`,
+ `|---|${taskTypes.map(() => "---").join("|")}|`,
+ ...models.map(
+ (m) => `| ${m} | ${taskTypes.map((t) => efforts[m][t]?.effort ?? "-").join(" | ")} |`
+ ),
+ ];
+ return lines.join("\n");
+}