Skip to main content
Glama
decision-mcp-server

decision-mcp-server

decision-mcp-server

Vibe-coded by Gérard Métrailler with Claude Opus 5.5 (Anthropic) · www.orionplaybook.com

⚠️ Disclaimer: this software is provided as is, without warranty of any kind: no guarantee that it is useful, correct or fit for any purpose, and no support is offered. Use it at your own risk. See LICENSE.

An MCP server and a command line for local decision models. It lets an agent (Claude Code, or any MCP client) and your scripts ask a small, fast model running on your own machine for calibrated judgements about a piece of text: which team should handle this message, how urgent is it, is it spam. The model answers with numbers, not prose, in a fraction of a second.

  • Five MCP tools: decide (the full request), decide_choice, decide_score, decide_noul and models, with descriptions written for agents to act on.

  • Talks to any server that implements the Jev decision API (POST /v1/systemone): LM Studio by default, others by changing one URL. Answers come back exactly as the backend sent them, plus the latency.

  • Streamable HTTP on 127.0.0.1 only, one bearer token per consumer (stored hashed). The logs name the consumer, the tool, the model and the latency, never the token, the backend key or the text being judged.

  • decide, a command line that speaks MCP to the server, so what you test is what agents get.

  • decidectl manages it: tokens, the backend key, Claude Code registration, a live self-test, and a weekly self-update that is tested and rolled back on failure.

  • Runs as a launchd user agent from its own pinned environment inside this folder.

Contents

Related MCP server: laya-mcp

What a decision model is

A chat model writes text. A decision model reads a state (a message, a ticket, a log line, a JSON object) and a set of questions, and returns, for each question, a probability distribution or a score: no generated text at all (output_tokens is 0). Because it only reads, it is fast (a few hundred milliseconds on a laptop once loaded), cheap, repeatable, and its confidence is a number you can act on.

A request has a state and one or more questions, each with an id you choose:

{
  "model": "clef-flash",
  "state": "Bonjour, j'ai été débité deux fois pour ma commande. Pouvez-vous me rembourser ?",
  "questions": {
    "route": {
      "type": "choice",
      "instructions": "Route this customer message to the team that should handle it.",
      "criteria": {
        "billing": "payments, invoices, refunds, double or wrong charges",
        "technical": "bugs, errors, outages",
        "sales": "pricing, plans, quotes"
      }
    }
  }
}

Question types:

type

asks

criteria

choice

which one label applies

an object: label → when it applies (two or more)

score

where the state falls on an ordered scale

an array of levels, lowest first

noul

a yes/no judgement described only by the instructions, as a number from 0 to 1

none

instructions is required on every question: one or two plain sentences saying what is being decided. On the reference model (Clef-Flash in LM Studio, about 250 ms once loaded) the example above answers:

{
  "answers": {
    "route": {
      "type": "choice",
      "choice": "billing",
      "probabilities": {"billing": 0.985, "technical": 0.005, "sales": 0.005},
      "confidence": 0.980
    }
  },
  "usage": {"input_tokens": 218, "output_tokens": 0}
}

A score answer gives the expected level as a decimal (0 = lowest), the probability of each level and a legend: {"type": "score", "score": 1.47, "legend": {"0": "can wait a week", "1": "answer today", ...}, "probabilities": {"0": 0.06, "1": 0.56, "2": 0.24, "3": 0.14}, "confidence": 0.41}. A noul answer is one number from 0 (no) to 1 (yes): {"type": "noul", "noul": 0.91}. These shapes are what LM Studio returns today; the server passes the backend's answer through as is.

Use it where you would otherwise ask an LLM to "pick the best category" or "rate from 1 to 5": routing and triage, intent detection, guardrails ("does this reply promise a refund?"), prioritising a queue, or choosing which tool an automation should run next.

Requirements

  • macOS (the service runs as a launchd agent; the Python code itself is portable).

  • A decision backend with a decision model loaded or loadable:

    • LM Studio 0.4.26 or later with a decision model such as Clef-Flash (see Model compatibility), its local server on, or

    • any other server implementing POST /v1/systemone (see Ollama).

  • Nothing else: scripts/install.sh sets up its own copy of uv and Python inside this folder.

Install

git clone https://github.com/orionplaybook/decision-mcp-server.git
cd decision-mcp-server
scripts/install.sh

The installer resolves the Python packages (only releases at least 7 days old), installs them into .venv, writes ~/Library/LaunchAgents/local.decision-mcp-server.plist, starts the service and waits for GET /health. It is safe to re-run. Then:

./decidectl backend-key                     # paste the backend's API key (hidden prompt), if it needs one
./decidectl tokens add cli --save-client    # a token for the `decide` command line
./decidectl selftest                        # live round trip through MCP

decidectl selftest sends a French double-charge complaint and expects billing above 0.9. The first call after a restart can take longer while the backend loads the model.

To put the two commands on your PATH:

ln -s "$PWD/decide" "$PWD/decidectl" ~/.local/bin/

Configure the backend

config.toml holds the defaults; put your own values in config.local.toml next to it (same keys, merged on top, not tracked by the public repository). Settings are type-checked, an unknown key or table is an error, and a relative path is relative to the file that sets it. Restart after editing: ./decidectl restart (after changing log_dir: ./decidectl install).

[backend]
url = "http://127.0.0.1:1234"       # LM Studio's default
decide_path = "/v1/systemone"
default_model = "clef-flash"

Environment variables override single values: DECISION_BACKEND_URL, DECISION_MODEL, and DECISION_BACKEND_API_KEY (the key itself, instead of the key file). They apply to the process they are set for: the launchd service does not see them, so for the service put these settings in config.local.toml (install.sh warns if they are set).

LM Studio

  1. Download a decision model (for example the Clef-Flash GGUF) in LM Studio.

  2. Developer tab: start the server. If Require authentication is on, create an API token for this server alone and store it with ./decidectl backend-key. It lands in [backend] api_key_file with mode 600 and is read on every request, so no restart is needed. backend-key never replaces a stored key: to change it, empty or delete that file yourself first.

  3. Leave Just-in-time model loading on: the first decision loads the model by itself. If it is off, the server asks LM Studio to load the model ([backend] load_path) when LM Studio reports it is not loaded, then retries once. Or load it by hand: lms load clef-flash.

Ollama

Any server that implements the Jev decision API works. For an Ollama build that serves /v1/systemone:

[backend]
url = "http://127.0.0.1:11434"
models_path = "/v1/models"
load_path = ""                      # Ollama loads models on demand
default_model = "clef-flash"        # the name you gave the model in Ollama

Ollama needs no key by default: leave the key file absent. Check that your Ollama version answers POST /v1/systemone before relying on it; a server without the endpoint gives [endpoint_not_found].

Tokens

Every MCP request needs Authorization: Bearer <token>. One token per consumer, so you can see who called and revoke one without touching the others:

./decidectl tokens add my-agent                      # prints the token once
./decidectl tokens add workflows --save-to wf.token  # or writes it to a file (mode 600)
./decidectl tokens list                              # names and dates, never tokens
./decidectl tokens revoke my-agent                   # stops working at once, no restart

Tokens are 32 random bytes, stored as SHA-256 hashes in [server] tokens_file (mode 600). Keep that file, the backend key and the client config outside any repository.

Connect Claude Code

./decidectl connect claude-code

This creates a token named claude-code and runs claude mcp add --scope user --transport http decision http://127.0.0.1:8110/mcp --header "Authorization: Bearer <token>", so every Claude Code session on this machine gets the tools. Check with claude mcp get decision (it should say Connected), then in a session ask something like "use the decision tools to route this message: …".

If Claude Code already has a server of that name, or the token name exists, nothing is changed unless you add --replace-token. That flag first removes the user-scope registration (and stops if a local- or project-scope one remains), then issues a new token and registers again. Other options: --server-name, --token-name.

Other MCP clients

Any client that supports Streamable HTTP with a custom header:

  • URL: http://127.0.0.1:8110/mcp

  • Header: Authorization: Bearer <token>

A typical JSON configuration (Cursor, Claude Desktop through a bridge, and others):

{
  "mcpServers": {
    "decision": {
      "type": "http",
      "url": "http://127.0.0.1:8110/mcp",
      "headers": { "Authorization": "Bearer <token>" }
    }
  }
}

Clients in Docker (workflow tools, agent frameworks): Docker Desktop forwards host.docker.internal to the host's loopback address, and the server accepts that host name, so use http://host.docker.internal:8110/mcp. Some clients treat .internal names as keyless local servers and drop the token; give those a stable plain name instead, for example a relay container on their network:

services:
  decision:
    image: alpine/socat:latest
    command: tcp-listen:8110,fork,reuseaddr tcp-connect:host.docker.internal:8110
    extra_hosts: ["host.docker.internal:host-gateway"]
    read_only: true
    cap_drop: [ALL]

point the client at http://decision:8110/mcp, and add the relay's name to the host names the server accepts (every request's Host header is checked, /health included, against DNS rebinding), in config.local.toml:

[server]
allowed_hosts = ["127.0.0.1", "localhost", "[::1]", "host.docker.internal", "decision"]

The server never listens on another address. To reach it from another machine, put a TLS reverse proxy in front of 127.0.0.1:8110.

The tools

tool

use it to

arguments

decide_choice

pick one label

state, instructions, criteria {label: description}, model?, id?

decide_score

place on a scale

state, instructions, criteria [lowest … highest], model?, id?

decide_noul

one open judgement

state, instructions, model?, id?

decide

several questions about one state in one call

state, questions {id: question}, model?

models

list the backend's models and the default

none

state is a string, or a JSON object or array. Every decision tool returns:

{ "model": "clef-flash", "latency_ms": 221.4, "response": { "...": "the backend's answer, unchanged" } }

loaded_model: true is added when the server had to ask the backend to load the model first. Errors are MCP tool errors whose text starts with a code an agent can branch on:

code

meaning

what to do

invalid_request

the request is malformed (missing instructions, one choice option...)

fix the arguments; nothing was sent

backend_unreachable

the backend is not running

start it (LM Studio: open it, or lms server start)

backend_timeout

no answer in time (model still loading, machine busy)

retry; raise timeout_s / load_timeout_s

backend_auth

the backend refused this server's key

decidectl backend-key

model_not_loaded

the model is not loaded and could not be loaded

lms load <model>, or turn on just-in-time loading

model_load_failed

loading was attempted and failed

check memory and the model name

model_not_found

the backend has no such model

call models; it must be a decision model

endpoint_not_found

the backend has no /v1/systemone

use a Jev-compatible backend

bad_request, backend_error

the backend rejected or failed the request

read the message

decide, the command line

decide choice "J'ai été débité deux fois" -i "Route this message to the right team" \
  -c billing="payments, refunds, double charges" -c technical="bugs, errors" -c sales="pricing"
decide score "Checkout has been down for an hour" -i "How urgent is this ticket?" \
  -l "can wait a week" -l "today" -l "within the hour" -l "right now: money is being lost"
decide noul "Hi, it's Anna again about order 1234" -i "How likely is it that the sender is an existing customer?"
decide raw request.json             # {"state": ..., "questions": {...}, "model": optional}
cat email.txt | decide choice -i "Is this a support request?" -c yes="asks for help" -c no="anything else"
decide models
decide tools

Add --json for the tool's full result, -m MODEL to use another model, --id NAME to name the question. The state is the positional argument, - or stdin, or --state-file FILE.

decide reads the server URL and its token from a client config file (TOML, mode 600):

url = "http://127.0.0.1:8110/mcp"
token = "dm-..."

decidectl tokens add cli --save-client writes it to [client] config_file. To use another file: --client-config FILE or $DECISION_CLIENT_CONFIG.

decidectl

decidectl status                         is it running, can it reach the backend
decidectl tokens add|list|revoke NAME    consumer tokens
decidectl backend-key                    store the backend's API key (hidden prompt or stdin; never replaces one)
decidectl connect claude-code            register with Claude Code at user scope (--replace-token to redo)
decidectl selftest                       live MCP round trip (French double charge -> billing)
decidectl config                         effective configuration
decidectl update [--check]               update packages: cooling-off, tests, self-test, rollback
decidectl autoupdate enable|disable|status   weekly automatic update
decidectl start|stop|restart|logs|check|install|upgrade|uninstall [script options]

The last line runs the matching script with the options given, for example decidectl install --no-start or decidectl uninstall --purge.

decidectl check is a health and auth check suitable for a nightly job (exit 0 = healthy, backend key accepted, /mcp refuses requests without a token). Logs: ~/Library/Logs/decision-mcp-server/decision-mcp-server.log (rotated, 10 MB × 5).

Model compatibility

Only decision models work: GGUFs built and published for the Jev decision API, which LM Studio lists under DECISION in lms ls (for example Clef-Flash). A plain chat or instruct GGUF will not score: the backend either refuses it on /v1/systemone or has no decision head to read the answer from. If decide returns [model_not_found] or [bad_request] for a model you know is downloaded, check which section lms ls puts it in.

Answer shapes come from the backend and are passed through unchanged; the ones shown in What a decision model is are LM Studio's.

Updates

./decidectl update --check                   # what would change (changes nothing)
./decidectl update                           # apply settled updates, test, roll back on failure
./decidectl autoupdate enable --weekday sun --time 03:00
./decidectl autoupdate status                # schedule and last result

An update moves each package to its newest release published at least 7 days ago (--cooldown-days), with uv's --exclude-newer. It refuses the whole update when:

  • any package would move to an older version;

  • a file that is new to uv.lock was uploaded after the cutoff, which includes a wheel added later to a version that is already locked.

The build tools uv fetches while installing obey the same cutoff, and uv itself is installed pinned by hash (scripts/uv-requirements.txt).

Before anything changes, the service must pass its self-test, so a backend that is down skips the update instead of failing it. Only one update runs at a time.

The update then backs up uv.lock (pyproject.toml is never changed, so never restored), installs, runs the unit tests, restarts the service and runs decidectl selftest. Any failure, Ctrl-C or stop restores the backup, reinstalls and restarts. An interrupted run is restored by the next one.

Each run writes update-status.json and appends to update.log in the log folder. Its result is one of:

  • updated

  • up-to-date

  • held: refused; nothing changed

  • skipped: the service was unhealthy beforehand

  • busy: another update was running

  • rolled-back

  • recovered: an interrupted run was restored

  • interrupted: stopped before anything changed

  • failed

uv.lock is local to each machine and never committed; copy one from a machine you trust to reproduce its exact versions.

scripts/upgrade.sh applies the current uv.lock by hand (after git pull), restarts and checks health. If pyproject.toml changed in the pull (a new dependency), it first updates uv.lock to match: every existing pin is kept, and new packages come from releases older than the cooling-off. install.sh does the same. Neither runs while an update is running. scripts/uninstall.sh removes the agents; --purge also removes the environment and the token store of the installed service. It deletes the log folder if it is this service's own (named decision-mcp-server); in a shared folder it deletes only decision-mcp-server.log* and lists the rest for you to check. Neither removes the Claude Code registration: claude mcp remove --scope user decision.

Configuration reference

Settings come in layers, each one overriding the one before:

  1. config.toml in the project: every setting, with its default.

  2. Another base file, when one is chosen. It is the first of these that is set:

    • --config FILE;

    • $DECISION_MCP_CONFIG;

    • the file the installed service was given. scripts/install.sh and decidectl autoupdate enable record the chosen file, as an absolute path, in their launchd jobs, so later decidectl and decide commands use it too, and a plain re-run of install.sh keeps it.

  3. config.local.toml next to the base file in use.

key

default

server.host

127.0.0.1

loopback only (a loopback address or localhost); anything else is refused. IPv6: ::1, no brackets

server.port

8110

server.tokens_file

~/.config/decision-mcp-server/tokens.json

hashed consumer tokens

server.log_dir

~/Library/Logs/decision-mcp-server

server.log_content

false

true logs states, questions and answers: debugging only

server.max_request_kb

256

largest MCP request body

server.allowed_hosts

127.0.0.1, localhost, [::1], host.docker.internal

accepted Host and Origin names (no port; any port and any case are accepted)

backend.url

http://127.0.0.1:1234

$DECISION_BACKEND_URL

backend.decide_path

/v1/systemone

backend.models_path

/v1/models

used by models and /health

backend.load_path

/api/v1/models/load

empty: never ask the backend to load

backend.default_model

clef-flash

$DECISION_MODEL

backend.api_key_file

~/.config/decision-mcp-server/backend.key

$DECISION_BACKEND_API_KEY wins

backend.connect_timeout_s

3

backend.timeout_s

60

one decision with a model that has already answered since the server started

backend.load_timeout_s

300

the first decision per model (it may wait for a just-in-time load), and the load request

client.config_file

~/.config/decision-mcp-server/client.toml

for decide and selftest

GET /health needs no token and reports {"status", "version", "default_model", "backend": {"reachable", "authorized"}}.

Troubleshooting

  • [backend_auth]: the backend wants a key, or refused this one. To replace a wrong key, delete the key file ([backend] api_key_file) yourself, then decidectl backend-key, then decidectl status.

  • [backend_unreachable]: LM Studio's server is off. lms server start, or open LM Studio.

  • The first call is slow or times out: the model is loading. Retry, or load it ahead with lms load clef-flash.

  • decide: "refused the token": the client config's token was revoked or mistyped; decidectl tokens revoke cli && decidectl tokens add cli --save-client.

  • Claude Code does not list the tools: claude mcp get decision should say Connected; start a new session after registering.

  • 421 Misdirected Request: the client sent a host name the server does not accept (see Other MCP clients). 403 forbidden_origin: a browser page on a site whose name is not in allowed_hosts tried to call the server.

Development

.tools/bin/uv sync --all-groups
.venv/bin/python -m pytest -m "not live"        # unit tests: real HTTP server, mocked backend
DECISION_LIVE=1 .venv/bin/python -m pytest -m live -v -s   # against the running service and model
scripts/check-repo.sh                            # no tokens, keys, venvs or locks in git

Layout: src/decisionserver/ holds server.py (MCP tools, auth, health), backend.py (Jev client, validation, error mapping), cli.py (decide), ctl.py (decidectl), mcpclient.py, tokens.py, config.py and updater.py; scripts/ holds the install, operate, health, upgrade and uninstall scripts.

Licences

The code in this repository: MIT, see LICENSE. Libraries: the MCP Python SDK (MIT), httpx (BSD), uvicorn (BSD), Starlette (BSD). Models are not part of this repository and keep their own licences.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      B
      maintenance
      Enables AI coding agents to make fast, zero-output-token decisions by evaluating context, diffs, logs, or options through the OpenRouter Decisions API using TypeSafe Jev, returning calibrated probabilities for binary, categorical, or scoring questions.
      1
      23 npm
      4
      MIT
    • A
      license
      A
      quality
      C
      maintenance
      Enables local, LLM-free probabilistic decisions (choice, classification, scoring, yes/no) with real probabilities in 100+ languages, as a drop-in replacement for jev-local tools.
      4
      MIT
    • A
      license
      A
      quality
      B
      maintenance
      Judgment calls on small, fast, cheap models: yes/no, pick-one and rating questions about any text, answered YES, NO or UNSURE. Four tools (likely, classify, rate, each) for TypeSafe's Jev, open models on Ollaya, Ollama or a local NLI model.
      4
      49 PyPI
      7
      Apache 2.0
    • A
      license
      Not graded
      quality
      C
      maintenance
      Exposes four System 1 decision tools — categorical choice, rubric scoring, binary probability assertions, and a pre-execution guardrail — over stdio JSON-RPC. This enables agents to make sub-second routing, triage, and safety decisions without slow generative calls.
      MIT