Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/choosekit-mcp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Select and configure the backend when the MCP process starts. `CHOOSEKIT_BACKEND
| All | `CHOOSEKIT_MODE` | `labels` | `labels` for every backend; `minimal-prefix` is llama.cpp only |
| All | `CHOOSEKIT_IMAGE_ROOT` | Current working directory | Root directory for files supplied through `imagePaths` |
| llama.cpp | `CHOOSEKIT_BASE_URL` | Required | Base URL of the llama.cpp server, for example `http://127.0.0.1:8080` |
| llama.cpp | `CHOOSEKIT_PROBE_MISSING_LOGPROBS` | `false` | Set to `true` to score choices outside the returned top logprobs with additional requests |
| Ollama | `CHOOSEKIT_BASE_URL` | `http://127.0.0.1:11434` | Base URL of the Ollama server |
| OpenRouter | `OPENROUTER_API_KEY` | Required | OpenRouter API key |
| OpenRouter | `OPENROUTER_PROVIDER` | Not set | Pins one provider and disables fallback |
Expand Down Expand Up @@ -93,7 +94,7 @@ Relative paths are resolved from `CHOOSEKIT_IMAGE_ROOT`, which defaults to the M

With `labels`, choosekit maps the supplied choice keys to A/B/C labels for scoring, so each description must contain the option's full meaning. With `minimal-prefix`, it scores the shortest token prefixes that distinguish the original keys. When no supplied option may apply, add an explicit choice such as `insufficient_information`.

The result contains the selected key, the complete normalized distribution, raw scores, margin, entropy, token-boundary rollback, and backend usage when available. A score is `null` when the upstream backend did not return a log probability for that choice; its probability in the distribution is `0`. Probabilities represent relative preference among the supplied choices. Estimating correctness requires separate calibration.
The result contains the selected key, the normalized distribution, raw scores, margin, entropy, token-boundary rollback, and backend usage when available. A score is `null` when the upstream backend did not return a log probability for that choice; its probability in the distribution is `0`. Probabilities represent relative preference among the supplied choices. Estimating correctness requires separate calibration.

## Requirements

Expand Down
12 changes: 6 additions & 6 deletions packages/choosekit-mcp/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/choosekit-mcp/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "choosekit-mcp",
"version": "0.3.0",
"version": "0.4.0",
"description": "Use choosekit as an MCP server.",
"license": "Apache-2.0",
"author": {
Expand Down Expand Up @@ -37,7 +37,7 @@
},
"dependencies": {
"@modelcontextprotocol/server": "2.0.0",
"choosekit": "^0.6.0",
"choosekit": "^0.7.0",
"zod": "^4.6.4"
},
"devDependencies": {
Expand Down
1 change: 1 addition & 0 deletions packages/choosekit-mcp/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ try {
baseURL: config.baseURL,
...(config.model === undefined ? {} : { model: config.model }),
mode: config.mode,
probeMissingLogprobs: config.probeMissingLogprobs,
});
break;
case "ollama":
Expand Down
6 changes: 6 additions & 0 deletions packages/choosekit-mcp/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export type Config =
readonly imageRoot?: string;
readonly model?: string;
readonly mode: "labels" | "minimal-prefix";
readonly probeMissingLogprobs: boolean;
}
| {
readonly backend: "openrouter";
Expand Down Expand Up @@ -89,11 +90,16 @@ export function loadConfig(env: NodeJS.ProcessEnv = process.env): Config {
if (mode !== "labels" && mode !== "minimal-prefix") {
throw new TypeError("CHOOSEKIT_MODE must be labels or minimal-prefix.");
}
const probe = env.CHOOSEKIT_PROBE_MISSING_LOGPROBS?.trim() ?? "false";
if (probe !== "true" && probe !== "false") {
throw new TypeError("CHOOSEKIT_PROBE_MISSING_LOGPROBS must be true or false.");
}
return {
backend,
baseURL,
...(imageRoot === undefined ? {} : { imageRoot }),
...(model === undefined ? {} : { model }),
mode,
probeMissingLogprobs: probe === "true",
};
}
4 changes: 4 additions & 0 deletions packages/choosekit-mcp/tests/cli.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const configurationKeys = [
"CHOOSEKIT_IMAGE_ROOT",
"CHOOSEKIT_MODEL",
"CHOOSEKIT_MODE",
"CHOOSEKIT_PROBE_MISSING_LOGPROBS",
"OPENROUTER_API_KEY",
"OPENROUTER_PROVIDER",
];
Expand Down Expand Up @@ -134,6 +135,8 @@ test("reports invalid environment configuration without writing to stdout", () =
"CHOOSEKIT_BASE_URL must be a valid URL."],
["invalid mode", { CHOOSEKIT_MODE: "keys" },
"CHOOSEKIT_MODE must be labels or minimal-prefix."],
["invalid missing-logprob setting", { CHOOSEKIT_PROBE_MISSING_LOGPROBS: "1" },
"CHOOSEKIT_PROBE_MISSING_LOGPROBS must be true or false."],
["unknown backend", { CHOOSEKIT_BACKEND: "other" },
"CHOOSEKIT_BACKEND must be llama-cpp, ollama, or openrouter."],
["Ollama without model", {
Expand Down Expand Up @@ -296,6 +299,7 @@ test("serves a minimal-prefix choice using the configured llama.cpp endpoint", a
CHOOSEKIT_BASE_URL: `http://127.0.0.1:${port}`,
CHOOSEKIT_MODEL: "fixture-model",
CHOOSEKIT_MODE: "minimal-prefix",
CHOOSEKIT_PROBE_MISSING_LOGPROBS: "true",
}));
t.after(() => process_.close());
await initialize(process_);
Expand Down
1 change: 1 addition & 0 deletions packages/choosekit-mcp/tests/package.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ function llamaEnvironment() {
"CHOOSEKIT_BASE_URL",
"CHOOSEKIT_MODEL",
"CHOOSEKIT_MODE",
"CHOOSEKIT_PROBE_MISSING_LOGPROBS",
"OPENROUTER_API_KEY",
"OPENROUTER_PROVIDER",
]) delete env[key];
Expand Down
Loading