Title: mcpx: one plugin contract -- a plugin is an MCP server, not a dlopen'd .so · Issue #1870 · developing-today/code · GitHub
Open Graph Title: mcpx: one plugin contract -- a plugin is an MCP server, not a dlopen'd .so · Issue #1870 · developing-today/code
X Title: mcpx: one plugin contract -- a plugin is an MCP server, not a dlopen'd .so · Issue #1870 · developing-today/code
Description: Relocated from dezren39/darwin-nix#80 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...
Open Graph Description: Relocated from dezren39/darwin-nix#80 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 reference...
X Description: Relocated from dezren39/darwin-nix#80 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 refer...
Opengraph URL: https://github.com/developing-today/code/issues/1870
X: @github
Domain: github.com
IPv4 address: 140.82.112.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"mcpx: one plugin contract -- a plugin is an MCP server, not a dlopen'd .so","articleBody":"Relocated from dezren39/nix#80 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: #173\n\n## Summary\n\nDefine one plugin contract for mcpx, so that \"a Go plugin\", \"a binary plugin\", \"a TypeScript or Python plugin\", \"a shebangable script plugin\" and \"a remote plugin over a socket\" are all the *same* thing addressed five ways, rather than five loaders.\n\nThe contract that already exists and already works in both directions is MCP. mcpx speaks MCP as a client (`internal/mcpclient`, `internal/pool`) and as a server (`internal/mcpserver`, `mcpx serve --transport stdio`, the daemon's `/mcp`). A plugin that is an MCP server needs no new transport, no new schema language, no new process supervisor, and no new discovery — it is a `servers` entry with a different label. Everything a plugin additionally needs beyond \"expose tools\" (hooks, variables, privileged calls) is a *second, optional* channel back into `/v1`, which is the subject of the sibling issues.\n\nThis issue is the loader and the manifest. It deliberately does not decide privileges.\n\n## Original notes\n\n> - plugins\n> - go plugin\n> - binary plugin\n> - typescript/python plugin\n> - script/shebangable plugin\n> - remote socket/v1/mcp/otherPlugin plugin\n> - go/ts(/py) can directly interact with app set own hooks, get/set vars, trigger any external command internally which can be triggered outside the app or in a script, call public and private functions of app, fork configure socket shutdown and independently interact (maybe this mode also supports still get/set vars transport types rpc anything they could do inside.\n\n(The last bullet is quoted again in the privileged-surface issue, where it is actually answered.)\n\n## Current state (what mcpx does today, with file refs)\n\nThere is no plugin concept in the daemon at all. The word \"plugin\" in this repository means one specific thing: `plugin/opencode/`, a TypeScript module loaded by opencode that talks to the daemon over its unix socket (`plugin/opencode/mcpx/daemon.ts`, `docs/opencode-plugin.md`, `docs/plugin-discovery.md`). That is a *consumer* of mcpx, not an extension of it. #48 generalises it to a harness-free core; it does not make mcpx extensible.\n\nWhat exists that a plugin system would otherwise have to invent:\n\n| need | already in mcpx | file |\n| --- | --- | --- |\n| spawn and supervise a child process that speaks a protocol | the pool: lazy start, idle reap, sharing/scope, `max` | `internal/pool/pool.go` |\n| declare one in config, or add one live | `servers` entries; `POST /v1/servers` writes the entry and reloads | `internal/api/ops_settings.go:82` |\n| typed tool surface, generated client | JSON Schema → TypeScript codegen | `internal/codegen` |\n| remote plugin | `url` + `transport: http\\|sse` server entries | `internal/api/ops_settings.go:82` |\n| a non-MCP program presented as tools | adapter declarations on `paths.adapters` | `internal/adapter/adapter.go`, `internal/settings/registry.go:292` |\n| an HTTP API presented as tools | `paths.apis`, `mcpx api --spec` | `internal/cli/openapi_tools.go` |\n| lifecycle events an extension could react to | the bus, 17 kinds (16 in `events.go:30-51` plus `catalog.changed`), replayable by `seq` | `internal/events/events.go` |\n| discovery of the daemon without a binary | the ladder | `docs/plugin-discovery.md` |\n\nTwo things worth knowing before designing anything:\n\n- **Adapter and OpenAPI tools are not namespaces.** They are attached as `mcpserver.Extra` when the MCP server is built (`internal/cli/serve.go:328-346` at 05c78b2: adapters `:332-336`, OpenAPI `:340`, `/v1` op tools `:344`, `WithExtras` `:346`), so they appear in `tools/list` over `/mcp` and stdio, but they are not in the pool, not in `mcpx ls`, and not in the generated TypeScript a script uses. `docs/story.md:1619-1620` says an adapted program \"is callable from a script\"; in the code as it stands, it is callable as an MCP tool, not as `gitx.log()` from `mcpx exec`. That defect is #102 (in flight). Any plugin design that goes through the Extra path inherits that limitation. Going through `servers` does not.\n- **Go's toolchain here is 1.26.7** (`go.mod:3`, `go version` → `go1.26.7 darwin/arm64`), which matters for the options below.\n\n## Approaches\n\n### Approach A — least recommended: in-process Go plugins (`-buildmode=plugin`, `plugin.Open`)\n\nThe literal reading of \"go plugin\". The daemon `dlopen`s a `.so`, looks up an exported symbol, and calls Go functions directly with no serialisation.\n\nIt is a trap, and the standard library says so in its own documentation. From `go doc plugin` on the installed toolchain, verbatim:\n\n- \"Plugins are currently supported only on Linux, FreeBSD, and macOS, making them unsuitable for applications intended to be portable.\"\n- \"A plugin is only initialized once, and cannot be closed.\" — so no unload, no reload, no `POST /v1/servers`-style live removal, and a leaked plugin for the daemon's whole lifetime.\n- \"Runtime crashes are likely to occur unless all parts of the program (the application and all its plugins) are compiled using exactly the same version of the toolchain, the same build tags, and the same values of certain flags and environment variables.\"\n- \"Similar crashing problems are likely to arise unless all common dependencies of the application and its plugins are built from exactly the same source code.\"\n- \"Plugins are poorly supported by the Go race detector.\"\n- And the conclusion: \"in practice, the application and its plugins must all be built together by a single person or component of a system. In that case, it may be simpler for that person or component to generate Go source files that blank-import the desired set of plugins and then compile a static executable in the usual way. ... many users decide that traditional interprocess communication (IPC) mechanisms such as sockets, pipes, remote procedure call (RPC), shared memory mappings, or file system operations may be more suitable despite the performance overheads.\"\n\nConcretely for mcpx: a plugin built against mcpx v0.9.1 would refuse to load into v0.9.2, because the dependency trees differ. A plugin built with a different `github.com/...` version of any shared module crashes at call time rather than at load. `-buildmode=plugin` requires cgo and external linking, so the host could never again be a static `CGO_ENABLED=0` binary. mcpx can be one today — #182 verified a static linux/arm64 build — even though the nix package and the Containerfile currently build with cgo by choice (#136 owns that policy); a plugin loader would turn that choice into a requirement. A panicking plugin takes the daemon down with it, killing every other server's pooled instances. None of this buys anything the daemon needs: plugin calls are not on a hot path — they sit behind a tool call that already spawns or round-trips to a subprocess.\n\nThe only honest case for it is \"the plugin must share a data structure with the daemon at nanosecond cost\", and mcpx has no such case. Not recommended, and the \"blank-import and recompile\" alternative the stdlib suggests is strictly better if someone genuinely wants compiled-in Go extensions — that is a build-tag registry, not a plugin system.\n\n### Approach B — middle: a bespoke plugin RPC, hashicorp/go-plugin style\n\nOut-of-process, which fixes every crash and version problem in A, but with mcpx's own protocol rather than MCP. `hashicorp/go-plugin` is the reference design and the one Terraform, Vault, Nomad and Packer all run on: the host spawns the plugin binary, the plugin prints a handshake line on stdout (`CORE-PROTOCOL-VERSION|APP-PROTOCOL-VERSION|network|addr|protocol`), the host dials that address, and they speak gRPC (or net/rpc) over it. The plugin is killed by the host; a plugin crash is a returned error, not a dead host; the protocol version in the handshake makes incompatibility a clean message instead of a segfault. Bidirectional calls work — Terraform providers call back into the host — which is exactly what \"set own hooks, get/set vars\" needs.\n\nWhat it buys over MCP: a typed, non-JSON-Schema interface, so a plugin can expose things that are not tools — a config-chain contributor, a transport, a ranking function for `mcpx search`, a credential provider. MCP has no vocabulary for \"supply a ranking function\"; a bespoke RPC does.\n\nWhat it costs: a `.proto` file, protoc in the build, a gRPC dependency (mcpx currently has no gRPC anywhere), a second plugin ABI to version alongside `/v1` and MCP, and a plugin ecosystem of exactly one member. It also means a plugin author has to learn a protocol that exists nowhere else, and cannot test their plugin with any MCP inspector. The handshake-on-stdout convention also collides with the stdio-MCP rule mcpx already enforces (`internal/cli/serve.go:378`: nothing may write to stdout but protocol frames).\n\nWorth keeping on the table specifically for the non-tool extension points, which C genuinely cannot express. But do not build it to get tools, and do not build it first.\n\n### Approach C — recommended: a plugin is an MCP server, plus an optional `/v1` back-channel\n\nDeclare that the plugin interface *is* the MCP server interface, and that every one of the user's five plugin kinds is a spawn recipe for one:\n\n| the user's bullet | how it is served | new code |\n| --- | --- | --- |\n| `go plugin` | a Go binary built with `-buildmode=exe` that speaks MCP over stdio. `mcpx` ships a tiny Go SDK package so this is ~20 lines. | an SDK package, no daemon change |\n| `binary plugin` | any executable that speaks MCP on stdio — the existing `command`/`args` server entry | none |\n| `typescript/python plugin` | `command: \"bun\"` / `uvx` / `deno run`, or a manifest that picks the runtime | manifest + runtime resolution |\n| `script/shebangable plugin` | a file with `#!/usr/bin/env -S mcpx plugin-run` (or its own shebang) that mcpx execs directly | exec-bit + shebang handling |\n| `remote socket/v1/mcp/otherPlugin plugin` | `url` + `transport: http\\|sse`; unix socket needs a `unix://` transport addition | a unix transport |\n\nThe value added over \"just write a `servers` entry\" is the part that makes it a *plugin system* rather than a naming convention:\n\n1. **A manifest and a search path.** `paths.plugins` (a `KindPathList` repeatable setting, exactly like `paths.adapters`/`paths.apis`/`paths.placeholders` — `internal/settings/registry.go:282-312`) names directories. A directory containing `mcpx-plugin.json` is a plugin: name, description, namespace, the spawn recipe, the mcpx API version it needs, the capabilities it asks for, and optionally the hooks it subscribes to. This is a setting, not an endpoint, per the repo's own preference.\n2. **Zero-manifest plugins.** An executable named `mcpx-plugin-\u003cname>` on `PATH`, or any executable in a plugin directory, is a plugin with the obvious defaults — the git/kubectl subcommand convention. This is what makes \"shebangable\" real: `chmod +x ./plugins/weather.ts` with a shebang and it is loaded.\n3. **The plugin's tools are a namespace, not extras.** Route plugins through the pool and the `servers` path, so they get pooling, `sharing`/`scope`, idle reaping, the schema cache, `mcpx ls`, `mcpx catalog`, generated TypeScript, and `POST /v1/servers`-equivalent live add/remove for free — and so they do *not* inherit the Extra limitation described in Current State.\n4. **A back-channel, by construction.** The plugin process is given `MCPX_SOCKET` (or `MCPX_DAEMON_ENDPOINT`) and a session id in its environment (which variable wins when both are present is #88's decision, #181 collision 8; any new variable must be declared in `internal/settings/`, #172), so it can call `/v1` the same way `plugin/opencode` does and the same way an exec'd script does. That single fact turns a plugin into a full participant — it can subscribe to `/v1/events`, read and write settings, add servers, run `mcpx_exec` — without inventing one line of protocol. The discovery ladder in `docs/plugin-discovery.md` already handles the case where a plugin is started out-of-band and has to find the daemon itself.\n5. **A Go SDK, a TS SDK, and a Python SDK are thin.** Each is \"here is how to write an MCP server and read `MCPX_SOCKET`\". Python needs no Go involvement at all; it needs a documented convention and a `uvx`-shaped launcher. Note the JS runtime resolver only knows deno/bun/node (`internal/runner/runner.go:73`) — plugin runtimes are a *separate* resolution problem from `script.runtime` and should not be jammed into that setting.\n\nRecommended because it is the only option where the plugin ecosystem is not size one on day one: every existing MCP server is already a plugin, every MCP SDK in every language is already a plugin SDK, and every MCP debugging tool already debugs mcpx plugins. It also composes with the sibling issues — \"turn any script or binary into an MCP server\" and \"a plugin can be added dynamically\" become the same mechanism rather than two.\n\nThe honest cost: MCP's vocabulary is tools, resources and prompts. A plugin that wants to be a *ranking function* or a *config source* cannot say so in MCP. Mark that as the boundary, and if such a plugin is ever actually wanted, add Approach B alongside rather than instead — a plugin manifest can name its protocol, and `mcp` being the default does not forbid a second value later.\n\n## Open questions\n\n- Is a plugin a distinct concept in config at all, or literally a `servers` entry with `mcpx.kind: \"plugin\"`? Distinct-with-a-search-path is better for discovery and worse for \"one list of things that provide tools\". Probably: separate declaration, one internal representation.\n- `unix://` transport for the \"remote socket\" bullet: is that a new transport in `internal/mcpclient`, or is a socket-path plugin just a `command` that is `socat`? The former is a small, honest addition; the latter is a joke that will be pasted into someone's config.\n- What does \"otherPlugin plugin\" mean — a plugin whose upstream is another mcpx's plugin? If so it is the self-composition case (see the embedding issue) and needs a loop guard.\n- Shebang mechanics: does `mcpx` exec the file directly and rely on the kernel, or does it read the `#!` line itself? The kernel route is simpler and breaks on Windows and on filesystems mounted `noexec`.\n- Versioning: what does a plugin declare it needs — the mcpx version, the `/v1` version, or a capability list? A capability list ages best and is the most work.\n- Should a plugin be able to fail *soft*? A server that will not start today is a loud error; a plugin that will not start should probably be a warning and a missing namespace, since it was additive by definition.\n\n## Ease · Impact · Related\n\n**Ease:** M for the manifest + search path + pool routing; L including SDKs and the shebang/runtime resolution. **Impact:** high — this is the shape every other item in this theme hangs off.\n\n**Depends on / related:** #83 (its tool-source interface must land first, and owns namespaces and collision rules, #181 collision 4 — a plugin is a namespace under those rules), #81 (hooks; a plugin tool is a hook target), #82 (privileged surface; meaningless without this loader), #84 (shares the `unix://` transport), #102 (in flight: the `Extra` defect above), #48 (harness-free plugin core — the consumer-side sibling of this; the same `/v1` client is what a plugin uses as a back-channel), #47, #44 (closed, fixed in #53), #7 (placeholders are the precedent for a declaration-plus-search-path feature), #5 (paths.config governs the config chain, and a plugin search path has to obey it; still unread at 05c78b2), #6 (event store), #76, #88 (socket-variable precedence), #136 (static-build policy).\n\nSecurity/auth deferred; see tracker.\n\n","author":{"url":"https://github.com/dezren39","@type":"Person","name":"dezren39"},"datePublished":"2026-10-28T22:10:06Z","url":"https://github.com/developing-today/code/issues/1870"}
| 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:68d3716c-ad2e-bd58-388a-6fe15b8b8db3 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CA72:B03C5:29B7C7:382C46:6B0616E7 |
| html-safe-nonce | 2c251828c62878c7797ac3cbbbe01a3dfb6091530bb1352a8c77ccb7fe02f5a3 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDQTcyOkIwM0M1OjI5QjdDNzozODJDNDY6NkIwNjE2RTciLCJ2aXNpdG9yX2lkIjoiNjkxMDg2ODk0ODIwNDc4NzQzMSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 0d56575e8c225cb04709a75adacf11f336033d84eda8b65a6d37405daac6b875 |
| hovercard-subject-tag | issue:6088413160 |
| 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/1870/issue_layout |
| twitter:image | https://opengraph.githubassets.com/a332362bb0611f6108586c4126a92b6308a26c70175377565924fa5521d7677d/developing-today/code/issues/1870 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/a332362bb0611f6108586c4126a92b6308a26c70175377565924fa5521d7677d/developing-today/code/issues/1870 |
| og:image:alt | Relocated from dezren39/darwin-nix#80 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 reference... |
| 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