Title: mcpx: where the model comes from — a provider layer mcpx owns, model profiles, and life after MCP Sampling's deprecation · Issue #1925 · developing-today/code · GitHub
Open Graph Title: mcpx: where the model comes from — a provider layer mcpx owns, model profiles, and life after MCP Sampling's deprecation · Issue #1925 · developing-today/code
X Title: mcpx: where the model comes from — a provider layer mcpx owns, model profiles, and life after MCP Sampling's deprecation · Issue #1925 · developing-today/code
Description: Relocated from dezren39/darwin-nix#110 on 2026-10-28 (placement audit): mcpx's single source lives in developing-today/code (pkgs/mcpx); re-home tracked at #309. Original body below; issue references inside it are historical (dezren39/ni...
Open Graph Description: Relocated from dezren39/darwin-nix#110 on 2026-10-28 (placement audit): mcpx's single source lives in developing-today/code (pkgs/mcpx); re-home tracked at #309. Original body below; issue referenc...
X Description: Relocated from dezren39/darwin-nix#110 on 2026-10-28 (placement audit): mcpx's single source lives in developing-today/code (pkgs/mcpx); re-home tracked at #309. Original body below; issue refe...
Opengraph URL: https://github.com/developing-today/code/issues/1925
X: @github
Domain: github.com
IPv4 address: 140.82.112.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"mcpx: where the model comes from — a provider layer mcpx owns, model profiles, and life after MCP Sampling's deprecation","articleBody":"Relocated from dezren39/nix#110 on 2026-10-28 (placement audit): mcpx's single source lives in developing-today/code (pkgs/mcpx); re-home tracked at #309. Original body below; issue references inside it are historical (dezren39/nix numbering).\n\nParent: #176\n\n## Summary\n\nmcpx has no model and deliberately never had one: `docs/consumer.md` records that \"a configured provider with an API key, was not built and should not be. It is the one that makes mcpx an agent.\" Everything model-shaped in mcpx today borrows the caller's model through MCP sampling.\n\nTwo facts have changed since that was written, and together they invert the conclusion:\n\n1. **MCP deprecated Sampling in `2026-07-28.**` The spec changelog's Deprecated section, item 1 (SEP-2577) deprecates Roots, Sampling and Logging, and names the migration explicitly: *\"integrate directly with LLM provider APIs instead of Sampling.\"* Sampling is not the long-term channel; the spec says so.\n2. **Nothing in the opencode line will ever send mcpx a sampling request.** `docs/opencode-plugin.md` §2.6: neither v1 nor v2 declares the `sampling` capability. v1 comments it out with issue links; v2 declares `roots` + `elicitation` only. The primary consumer of mcpx cannot answer the channel mcpx's only model path depends on.\n\nSo the question this issue settles is not \"should mcpx sample?\" — it is \"where does mcpx's AI layer get a model, what does it expose, and how does it stay from becoming a second agent harness?\"\n\n## Original notes\n\n> - mcp-owned opencode api support\n> - support multiple providers/models\n> - name priority sets of models as an 'agent'\n> - ? just embed opencode and call it? is there a golang or rust opencode? \n> - proxy\n> - respond to elicit/prompt\n\n## Current state (what mcpx does today, with file refs)\n\n| capability | where | state |\n| --- | --- | --- |\n| sampling passthrough (upstream server → mcpx → caller) | `internal/elicit`, `docs/protocol.md` §4.1 | works; a decline becomes an error, since the spec has no decline result for sampling |\n| sampling declared upstream | `docs/protocol.md:271`; `internal/mcpclient/modern.go:46-57` | `sampling` declared to servers only when a handler is installed — and the daemon always installs one (`internal/daemon/hooks.go:69` → `internal/pool/pool.go:393-397`), so in practice **every upstream server is told sampling works**, whether or not any caller can answer. `roots` is declared unconditionally (`modern.go:52`) and is deprecated by the same SEP. |\n| sampling raised by mcpx itself | `/v1/intent`, `prompt.sample` (`internal/settings/consumer.go:105`) | exists, **off by default** (`never`) |\n| the catalogue slice sent with a generation request | `prompt.catalogBudget` (`:119`), `prompt.maxTokens` (`:134`), `prompt.sampleTimeout` (`:127`) | bounded; sends the ranked slice and nothing else |\n| generated script is validated before running | `internal/diagnose` preflight, `prompt.mode` (`:97`) default `script` | returns the script; runs only on explicit request |\n| answering an elicitation as a client | `mcpx elicit`, `GET/POST /v1/elicit*`, the plugin | works; the broker is the store and the fallback |\n| a model of mcpx's own | — | **none** |\n| `logging` declared as a server | `internal/mcpserver/server.go:566` | **no longer declared** since #171 (mcpx sends no `notifications/message`); `logging/setLevel` still answers. `docs/protocol.md` §2.2 still shows it declared for three revisions — stale. |\n\n`Server.execScript` running a recipe from the daemon is marked in `docs/consumer.md` as \"a seam, not a design\", pending `POST /v1/exec` — which now exists (`internal/api/ops_exec.go:12`). That seam should close as part of any work here; at 05c78b2 it still calls `internal/runner` directly (`internal/daemon/consumer.go:509-517`).\n\n`docs/consumer.md:192-198` still says a configured provider \"was not built and should not be. It is the one that makes mcpx an agent.\" SEP-2577 names exactly that as the migration from Sampling, so that sentence must change in the same change that lands whatever this issue decides — otherwise it is another #159-class contradiction.\n\n(Checked at 05c78b2. The PROTOCOL work in flight — conformance against the official schemas and a modern-first era probe — touches `internal/mcpclient`, `internal/pool` and `docs/protocol.md`; the capability rows above may change when it lands. Nothing in the recommendation depends on them.)\n\n## What \"is there a golang or rust opencode\" actually resolves to\n\nChecked, because it decides the whole shape:\n\n| candidate | language | what it is | usable as a library inside mcpx? |\n| --- | --- | --- | --- |\n| **sst/opencode** | TypeScript/Bun | the opencode mcpx already plugs into | No. It is an application, and embedding it means shipping Bun. |\n| **charmbracelet/crush** | **Go**, ~28k stars | *literally the original Go opencode codebase*, renamed after the 2025 split (maintainers' own words in charmbracelet/crush#1097: \"Crush is the continuation of the original OpenCode project… sst/opencode is a fork of that repo\") | Practically no. It is a TUI application, not a library; its packages are internal-shaped; and the repo is **source-available, not OSI** (GitHub reports the licence as `NOASSERTION`), which is a distribution problem for a Nix-packaged binary. |\n| **Google ADK for Go** | Go | `go get google.golang.org/adk` — first-party, model-agnostic, MCP + tool-calling + multi-agent | Yes, technically. Heavy. |\n| **Microsoft Agent Framework for Go** | Go | first-party, public preview since July 2026 | Yes. Preview-grade; missing RAG/CodeAct/declarative agents. |\n| **cloudwego/eino** | Go, ~12k stars | LangGraph-like graphs, typed `ChatModel`/`Tool`/`Retriever`, ReAct + DeepAgent, Apache-2.0 | Yes. The most capable OSS Go option. |\n| **tmc/langchaingo** | Go, ~9k stars | broadest provider/vector-store surface, pre-1.0 (v0.1.14) | Yes, with API churn. |\n| **firebase/genkit** (Go) | Go | 1.0 GA, flows + dev UI + built-in OpenTelemetry | Yes. |\n| **openai/openai-go**, **anthropics/anthropic-sdk-go**, **googleapis/go-genai** | Go | plain provider clients, no agent loop | Yes, and this is the low-dependency option. |\n| Rust | — | `rmcp` (official MCP SDK), `rig`; OpenAI's Codex CLI is Rust. No Rust opencode. | irrelevant — mcpx is Go |\n\nTwo conclusions worth stating plainly:\n\n- **The answer to \"is there a golang opencode\" is yes, and it is Crush** — but it is an app under a source-available licence, not a library, so \"just embed opencode and call it\" is not available in the form the note imagines.\n- **OpenAI and Anthropic still ship no first-party Go *agent* SDK** (Python/TS only, as of mid-2026). Their plain Go clients exist and are fine. So an mcpx AI layer built on provider clients plus a hand-written loop is not a second-class choice in Go; for a single model with a handful of tools, the loop is ~40 lines and owning it beats adopting a framework.\n\n## Approaches\n\n### Approach A — least recommended: embed or shell out to an agent application\n\nShip Crush (or opencode, or `claude -p`) as a subprocess and hand it the prompt. Superficially the cheapest thing: no provider plumbing, no loop, someone else's model config.\n\nWhy not:\n\n- **Licence and packaging.** Crush is source-available (`NOASSERTION`); opencode means shipping Bun. mcpx's whole distribution story is one Go binary plus a Nix derivation, and #44 (closed, fixed in #53) spent real effort making the *plugin* binary-free. Adding a mandatory agent binary reverses that.\n- **It is the harness, twice.** The agent app has its own config, its own model list, its own MCP client, its own permission model, its own sessions. mcpx would then have two of each, disagreeing. `docs/consumer.md`'s scope concern — \"anything that makes mcpx call a model has to justify that it isn't rebuilding the harness\" — is violated maximally here: you have not avoided rebuilding the harness, you have adopted a whole second one.\n- **No structured control.** You cannot bound the token budget, pin a model per operation, or get a typed result. You get whatever the app printed.\n- It does, however, have one genuine merit worth preserving as a *fallback*: for a user who already runs opencode, \"use the model opencode is already configured with\" is exactly right — which is what the v2 plugin's `ctx.generate.text` gives, without the subprocess. See C.\n\n### Approach B — middle: a Go agent framework (eino / ADK-Go / Genkit) as mcpx's AI layer\n\nAdopt one framework, get the ReAct loop, tool-calling, streaming, interrupt/resume and multi-agent orchestration for free, and map \"an agent\" (the note's named priority set of models) onto the framework's agent type.\n\nFacts and opinions:\n\n- **eino** is the strongest OSS option: Apache-2.0, typed components, real graph orchestration with branching and human-in-the-loop interrupt/resume — and interrupt/resume maps *exactly* onto mcpx's existing elicitation broker and `2026-07-28` MRTR input-required flow, which is a genuine architectural fit rather than a coincidence. **ADK-Go** and **Microsoft Agent Framework for Go** are first-party and better-supported bets but Gemini-first / Azure-first respectively, and the Go builds trail their Python siblings. **Genkit Go** is 1.0 GA and brings OpenTelemetry tracing — which mcpx would otherwise hand-roll onto `/v1/log` and `/v1/stats`.\n- The real cost is **dependency weight and gravity**. A framework brings a provider registry, a message type, a streaming abstraction and a state model, and every one of them competes with something mcpx already has: `internal/tasks`, `internal/elicit`, `internal/logstore`, `internal/execsvc`'s `Frame` stream. The seams between \"mcpx's stream\" and \"the framework's stream\" are where this gets expensive.\n- It also over-buys. mcpx's model jobs are all *small and one-shot*: expand a search query, generate a script from an intent, explain an error, propose a repair, draft an adapter spec. None of them is an agent loop. A graph framework for five one-shot completions is the wrong ratio.\n- Worth revisiting if mcpx ever wants a genuinely agentic operation (the \"install any language/tool/framework/library\" case in #113 is the one candidate).\n\n### Approach C — recommended: a thin provider interface mcpx owns, with sampling and the plugin as two of several backends\n\nOne internal package — call it `internal/model` — with one small interface, roughly:\n\n```go\ntype Provider interface {\n Name() string\n Generate(ctx context.Context, req Request) (Response, error) // messages, maxTokens, stop, optional JSON schema\n}\n```\n\nand several implementations, chosen by configuration:\n\n| backend | when it is right | notes |\n| --- | --- | --- |\n| **sampling through the broker** (today's path) | an MCP client that declared `sampling` is driving | keep it; it is correct per the legacy spec and costs nothing. But it is **deprecated in 2026-07-28** and no opencode declares it, so it cannot be the only path. |\n| **the opencode plugin answering sampling via `ctx.generate.text`** (opencode v2) | an opencode user, no API key configured | `docs/opencode-plugin.md` §2.5 — v2 plugins get one-shot completion; v1 has no route short of a full agent turn. This makes \"use the model my harness already has\" real, with no subprocess and no key. Depends on #47. |\n| **a configured provider** (`openai-go`, `anthropic-sdk-go`, `go-genai`, or any OpenAI-compatible base URL) | CI, headless, a daemon on another machine, or anyone who just wants it to work | the thing `docs/consumer.md` refused. The 2026-07-28 changelog now names this as *the* migration from Sampling. Reading an existing `OPENAI_API_KEY`/`ANTHROPIC_API_KEY`/`OPENAI_BASE_URL` from the environment means most users configure nothing. |\n| **an OpenAI-compatible proxy endpoint** | a company gateway, LiteLLM, Ollama, LM Studio, opencode-zen | falls out of the previous row for free — it is a base URL — and is the honest reading of the note's `proxy` bullet, see below. |\n\n**Everything goes through the settings registry, not new endpoints.** `internal/settings` already gives every setting a config key, an `MCPX_*` env var, a CLI flag, `/v1/settings` and an MCP tool, and `prompt.*` is already the precedent. Proposed:\n\n| setting | meaning |\n| --- | --- |\n| `model.provider` | `auto \\| sampling \\| plugin \\| openai \\| anthropic \\| google \\| none`; `auto` prefers a live sampling-capable client, then the plugin, then a configured key, then fails cleanly |\n| `model.baseURL`, `model.apiKeyEnv` | the proxy/compatible-endpoint case |\n| `model.default` | the model id used when an operation names none |\n| `model.agents.\u003cname>` | **the \"agent\" concept: a named ordered list of models, tried in order** |\n| `model.budget`, `model.timeout` | hard bounds, per the existing `prompt.maxTokens`/`prompt.sampleTimeout` shape |\n| `\u003coperation>.model` | per-operation override: `prompt.model`, `search.model`, `repair.model` — each can name a model id *or an agent name* |\n\n**\"Name priority sets of models as an 'agent'\" is the best idea in this note and should be built literally.** It is a fallback chain plus a policy, and it solves four problems at once that are otherwise solved four times: rate-limit failover, cost tiering (try the cheap local model, escalate on refusal or low confidence), capability routing (this operation needs tool-calling/JSON mode, that one does not), and offline degradation. Define it as:\n\n```jsonc\n\"model\": {\n \"agents\": {\n \"cheap\": { \"models\": [\"ollama/qwen3:8b\", \"openai/gpt-5-mini\"], \"maxTokens\": 2000 },\n \"careful\": { \"models\": [\"anthropic/claude-opus-5\", \"openai/gpt-5\"], \"temperature\": 0 }\n }\n}\n```\n\nand let every operation take `model: \"careful\"` or `model: \"openai/gpt-5\"` interchangeably. Do **not** call it \"agent\" in the config schema — the word already means something else in every harness mcpx sits under, and mcpx is explicitly not one. `model.profiles` or `model.sets` says the same thing without the collision; keep \"agent\" as documentation prose if the user prefers it.\n\n**On `proxy`**, the note's bullet has three plausible readings and they should not be conflated:\n\n1. *mcpx points at an OpenAI-compatible proxy* — free, it is `model.baseURL`. Do this.\n2. *mcpx **is** an OpenAI-compatible proxy* — it serves `/v1/chat/completions`, forwards to a real provider, and injects mcpx's tools. This is genuinely interesting: it would let any OpenAI-compatible client get mcpx's whole catalogue with no MCP support at all, reusing exactly the pattern `GET /v1/openapi.json` already establishes (one declaration, many surfaces). It is also the single largest scope increase in this issue and should be its own issue if wanted. Note the collision: mcpx's API prefix is already `/v1`, and `POST /v1/chat/completions` would sit inside the ops table's namespace.\n3. *mcpx proxies model calls on behalf of scripts* — `await mcpx.model.generate(...)` inside an exec script, so a script can use a model without its own key. This is small, falls out of the `Provider` interface for nearly nothing, and is probably wanted. Put it behind the same off-by-default posture.\n\n**On `respond to elicit/prompt`**, keep the existing direction rules from `docs/protocol.md` §3 and add exactly one thing: when an upstream server sends `sampling/createMessage` and *no* caller can answer, mcpx currently returns an error. With a configured provider it can answer itself — `sampling.answerLocally` (default off), bounded by `model.budget`. That is the case where mcpx-as-a-model genuinely earns its place: the alternative is a failed call. Symmetrically, mcpx may answer an upstream `elicitation/create` from a model only when the question is not a consent question; `internal/elicit/policy.go`'s existing routing rule — a lone boolean `confirm` goes to a **human**, because consent is not the agent's to give — must hold, and a model is even less entitled to give consent than an agent is.\n\nRecommended because it is the smallest thing that removes the hard dependency on a deprecated protocol feature that mcpx's main consumer does not implement; because every existing path (sampling, the plugin) survives as a backend rather than being replaced; because it is all settings, so a user who wants none of it configures nothing and nothing changes; and because it does not make mcpx an agent — it gives mcpx one function, `Generate`, which is what all five of its model-shaped jobs actually need.\n\n### The scope guard, restated\n\n`docs/consumer.md`'s rule should be kept and made checkable: **no mcpx operation may call a model on a path where a deterministic answer exists.** Diagnostics before repair, recipe matching before generation, lexical search before query expansion. The provider layer is a capability, not a strategy; every caller of it should be reviewable as \"what happens when this returns an error\", and the answer should always be \"the deterministic result, plus a sentence saying the model was unavailable.\"\n\n## Open questions\n\n- Is `model.provider: auto` too clever? An explicit default of `none` (nothing calls a model until you say so) matches `prompt.sample: never` and is more predictable; `auto` is friendlier. Probably `none` for the daemon default and `auto` documented as the recommended setting.\n- Should the provider be resolved in the daemon or the CLI? `docs/consumer.md` records that the daemon had no access to settings until #41 folded `settings.Resolve` in; the provider must live daemon-side since `/v1/intent` and the exec service are the callers.\n- Does a per-session model override make sense (`_meta[\"ai.opencode/sessionID\"]` from #47 gives session attribution for free)?\n- What is the model id namespace? `provider/model` (crush/opencode convention) is the obvious one and makes `model.profiles` entries self-describing.\n- Should the seam (`Server.execScript` calling `internal/runner` directly) close onto `POST /v1/exec` as part of this, or separately? It is one function and it is marked.\n- Reading `OPENAI_API_KEY` from the ambient environment by default: convenient, or a surprise? Probably opt-in via `model.apiKeyEnv` naming the variable rather than scanning for known ones.\n\n## Ease · Impact · Related\n\n**Ease** L (M for the `Provider` interface + one provider + settings; L including profiles, plugin backend and local sampling answers; XL if mcpx-as-an-OpenAI-proxy is in scope — it should not be, split it) · **Impact** high — every other issue in this theme depends on where the model comes from.\n\n**Depends on / related**: #41 (closed, fixed in #58 and #61: sampling passthrough, `prompt.sample`, `/v1/intent` — this generalises them), #47 (opencode v2 plugin, `ctx.generate.text` backend), #40 (closed, fixed in #57: ExecOptions, the shape settings-not-endpoints follows), #77 (protocol follow-ups — Sampling's deprecation belongs there too), #5 (config chain), #159 (the `docs/consumer.md` provider sentence is an instance), #172 (every `model.*` setting goes through the one registry). Callers of this layer: #109 (query expansion), #111 (rungs 2–6), #112 (prompt hooks), #113 (operation routing), #114 (spec generation).\n\nSecurity/auth deferred; see tracker.\n\n","author":{"url":"https://github.com/dezren39","@type":"Person","name":"dezren39"},"datePublished":"2026-10-28T22:32:37Z","url":"https://github.com/developing-today/code/issues/1925"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:a53c7275-d05c-09b0-354a-a8aba53ab134 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8AF2:36611F:292A8C:35A8FA:6B061455 |
| html-safe-nonce | 6a2ff04f98b600b05b2dfbc8a5be690c7549a8cb4ceb51509cd57abe1a385ad8 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4QUYyOjM2NjExRjoyOTJBOEM6MzVBOEZBOjZCMDYxNDU1IiwidmlzaXRvcl9pZCI6IjYxOTQyMjQwMTQyNzgwNTI2OSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | bf53d866648f51a985a537887192aa265dde9cb7ee304b45cc95905eb098d3ef |
| hovercard-subject-tag | issue:6088722730 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/developing-today/code/1925/issue_layout |
| twitter:image | https://opengraph.githubassets.com/28e159d2df3584e58eb9f5078bc6e44adff809de86c232aed650a3ac9b524d23/developing-today/code/issues/1925 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/28e159d2df3584e58eb9f5078bc6e44adff809de86c232aed650a3ac9b524d23/developing-today/code/issues/1925 |
| og:image:alt | Relocated from dezren39/darwin-nix#110 on 2026-10-28 (placement audit): mcpx's single source lives in developing-today/code (pkgs/mcpx); re-home tracked at #309. Original body below; issue referenc... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | dezren39 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 97d4714e567728e1f85f88b0cf68c89f0f8a3dc41e8869af7aeb8195ad990374 |
| turbo-cache-control | no-preview |
| go-import | github.com/developing-today/code git https://github.com/developing-today/code.git |
| octolytics-dimension-user_id | 26439447 |
| octolytics-dimension-user_login | developing-today |
| octolytics-dimension-repository_id | 627308783 |
| octolytics-dimension-repository_nwo | developing-today/code |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 627308783 |
| octolytics-dimension-repository_network_root_nwo | developing-today/code |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 866f202ebf7ac5aff8f633417d9fd8a53818a977 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width