6ba593de00583dfbfb2d2afa2fca8d1ee02c6e4a
7
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
7bc602236b |
library: the MCP hub is called the MCP router
The owner asked why it was a "hub". Composio calls the same thing a Tool Router; "router" says what it does (one server that routes each call to the right one), and "gateway" is taken by magpie's LLM gateway. Only the words change: MCP router / MCP 路由 / MCP 路由 / MCP ルーター / MCP-Router, "Router address", and the CLI's `magpie library mcp router on|off`, where `hub` still works. The URL /mcp/magpie/hub, the mcpHub setting, the servers/hub API and the Go names stay, so nothing a user or an agent config holds changes. docs/subsystems/mcp-hub.md moves to mcp-router.md and the pages that link it follow. #4382's new words follow too: "Through the MCP router", "Not through the router" and their hints in every language, and the CLI's `magpie library mcp router <name> shared|direct` (`hub` works there too; library_hub_test.go says router for direct, hub for shared). Run at e2583df31 (this stack on |
||
|
|
2f65a33aaf |
library: a tools plugin is a Library server of its own, in the MCP hub (Search1API)
chenxiang0010 (Discord #general) asked for a tools plugin's tools, Search1API's (@magpie-community/tools-search1api), to be in magpie's aggregated MCP server. Until now plugin tools were served only at /mcp/magpie/tools, wired by hand; the hub listed Library servers only. Now each plugin that is on and gives tools becomes a Library server once the plugin host has noted its tools (plugin-tools.json, new plugin.ToolsNoted): - named by the plugin's short name (search1api, search1api-plugin beside a user's server of that name), `plugin` set, `local`, its URL the new /mcp/magpie/tools/<short> (gateway ToolsMCPOne), which serves that plugin's tools alone by their own names; - added with the hub on, it is on for the agents given the hub's entry, so their hub lists search1api__search etc. at once; with the hub off it is on for none until switched on. Per agent and per tool it is switched like any server; - the hub lists and runs its tools in process (gateway.PluginToolsOf, RunPluginToolOf, under the Plugin tools gate); with the hub off an agent is given the per-plugin URL at the address it reaches the gateway (through), with a key from another machine; - offered once (pluginsOffered): removed by the user, it comes back only when the plugin is removed and added again. The plugin removed takes the server out; turned off it stays and lists nothing; an unreadable plugins.json changes nothing (plugin.ReadList). Edited in the Library's editor, which doesn't send `plugin`, it stays the plugin's. Docs: docs/subsystems/plugin-tools.md, mcp-hub.md, site docs plugins (en, zh, ja). Run (mote; full suite at this change on origin/main |
||
|
|
e0ea15b8e8 |
library: an MCP hub, one magpie server in place of every library server (#2679)
With Library → MCP → "MCP hub" on (off by default), each agent that takes an MCP server over HTTP is given one entry, magpie, at /mcp/magpie/hub/<agent>, in place of the library servers ticked for it. magpie runs those servers itself, once for every agent: a command starts on its first call and ends after 10 idle minutes, a URL server is reached with its headers and MCP sign-in. Tools are <server>__<tool>; a tool off in the library is neither listed nor run. Any other app connects at /mcp/magpie/hub, which serves every library server. Both are guarded as /mcp/magpie/tools is (local or a gateway key, no foreign page, 4 MiB, the key's limit per call). An agent that reaches no server over HTTP (Claude Desktop), has a magpie entry of its own, or sits beside a library server called magpie keeps each server's own entry, and the page says why. Off gives every agent its servers back and ends every process the hub started. GUI: a switch under the MCP list, a line of what it serves, the address, and a Connect… sheet. The sheet lists every agent magpie detects that takes MCP (not a fixed four), each with where it stands; one given none of the hub's servers has a Connect that ticks it for every server it can reach (servers/agents-all), so it gets the entry, and the sheet stays open. Then any other app: Cursor (when it isn't a detected agent), VS Code, Other, with the JSON and, in the app, "Add to …" through the app's own install link built in Go (servers/hub-open; the page never sends a link). CLI: magpie library mcp hub on|off. Design: docs/subsystems/mcp-hub.md. With #3885 ( |
||
|
|
db8b791797 |
plugin: tools-, page- and agent- packages take their short name without the prefix
@magpie-community/tools-calc served its tools as tools-calc_eval and its
page under "tools-calc" because ShortName only dropped middleware- and
opencode-. It now drops tools-, page- and agent- too, so the calc example
serves calc_eval/calc_convert/calc_date as its README and the docs say.
`magpie plugin options` / SetOptions find a plugin by its short name or by
its bare package name (plugin.Called), so "agent-aider" keeps working
beside "aider".
Run at
|
||
|
|
b6533893a7 |
plugins: Discover lists tools and page plugins, and the intro links to the plugin docs
Every kind of plugin magpie runs now has its place on the Plugins page, so
someone looking to extend magpie finds what exists and how to write one:
- Discover has "Tools for agents" (market kind "tools") and "Pages" (kind
"page") sections beside Subscriptions, Gateway middleware and Agents,
each card with its own chip (a new Tools chip, the Page chip). Before,
both kinds fell under Subscriptions as Providers.
- A GitHub repository tagged magpie-plugin whose package.json has
magpie.page.file is a Page, and that file must be committed, as a
provider's entry must (TaggedRepos).
- An installed plugin that only gives tools wears the Tools chip.
- The intro says what a plugin can be (provider, gateway middleware,
routing strategy, tools, an agent, a page) and its "Write a plugin" link
opens usemagpie.ai/docs/plugins in the window's language (zh and zh-TW
to zh/, ja to ja/), outside the window.
- The docs' Publishing section lists the "tools", "page" and "agent"
registry kinds and the community package names for each, in en, zh, ja.
Run at the reviewed head (on origin/main
|
||
|
|
e679f1106f |
cli: magpie plugin lists a plugin's tools and its page
The list said a gateway module's hooks, routings and onUsage, but nothing
for a plugin that gives tools (P4b) or a page (P4c), so such a plugin had
nothing under its row. Found in the combined P4 real-use run.
Tools are listed by their names on the plugin tools MCP server
(gateway.ToolNames), a page by its title and what it may read.
Run: TestPluginListSaysToolsAndPage, and internal/cli whole (ok). gofmt
clean; vet darwin, linux -tags nogui and windows = 0. Broken by hand:
without the tools line the test goes red ("aren't listed"), and without
the page line too ("isn't listed"). A `!e.Off` guard on the tools line
didn't change the test, since the host loads no plugin that is off, so
it was dropped.
|
||
|
|
6ac7032b4b |
plugins: a community plugin's tools reach every agent through magpie's MCP server /mcp/magpie/tools (P4 tool point)
A plugin's OpenCode `tool` hook ({tool: {name: tool({description, args,
execute})}}) used to reach no agent. Now the plugin host collects each
loaded plugin's tools, turns their zod args (v3/v4 shape or object; a
raw JSON Schema is kept) into JSON Schema, and runs one on a `tool`
call: arguments checked against the tool's own zod first (defaults
filled, a wrong one named), execute raced against ToolTimeout (55s,
ctx.abort fires), the answer as text.
The gateway serves them as an MCP server at /mcp/magpie/tools
(tools_mcp.go, guarded by serveMCP as the search one, 4 MiB body):
tools/list names each <plugin short name>_<tool>, at most 64 chars,
a shared name numbered _2; tools/call holds the call to the calling
key's limit through reserveFor and runs it with the calling agent.
The built-in plugin `tools` ("Plugin tools", Essential) serves
gwtool.PluginTools; off, nothing is listed, a call says the plugin is
off and the host isn't asked. InUse counts plugins that are on and
gave tools, from plugin-tools.json, which the host writes after each
load (whole, only on change), so it never starts Bun; the gateway's
KeepFresh watches that note too. Tool answers go to the calling
agent only, so masking doesn't apply (said in the docs).
The Plugins page lists an on plugin's tools by their MCP names, with
descriptions on hover and a button copying the server's address; a
plugin of tools alone has no Provider chip and isn't said to sign in
to nothing. Not done: a Library featured opt-in entry; wiring is the
copied address.
Docs: docs/subsystems/plugin-tools.md (new), plugin-runtime.md's new
"P4: community plugins at every point" section with the tool row, the
README index, usemagpie.ai/docs/plugins#tools in en, zh, ja with an
example. Strings in zh, zh-TW, ja, de. Example plugin:
internal/plugin/testdata/tools.
Run at this commit's tree (base 4df1ba0c6), each package alone, -p 2:
- gofmt -l clean; go vet darwin, GOOS=linux -tags nogui, GOOS=windows
over internal/plugin, gwtool, gateway, plugins/..., gui, pluginrt: ok
- go test ./internal/plugin -run Tool; ./plugins/...; ./internal/pluginrt;
./internal/gui -run 'Builtin|Plugins'; ./internal/gateway -timeout 45m
-run 'ToolsMCP|ServingGates|OwnMCPRejects|SearchOnAndOff|KeyLimitsOnAndOff':
all ok
- GUI, Chromium and WebKit: every plugin-*.test.cjs, i18n-keys,
builtins: 461/461 pass; plugin-tools.test.cjs (new) covers en, zh,
zh-TW, ja, de at 980 and 420 px
Broken by hand, each red, then restored:
- tools/list ignoring the gwtool gate -> TestToolsMCPOff
- tools/call ignoring the gate -> TestToolsMCPOff
- reserveFor removed -> TestToolsMCPHeldToKeyLimit (tool ran)
- collision suffix dropped -> TestToolsMCPServesPluginTools
- ToolsOn ignoring Off -> TestPluginTools
- host arg check removed -> TestPluginTools
- host timeout race not listening -> TestPluginTools (answered at
5.3s by Go's backstop; the test now bounds it at 4s, and the first
try at this break was a syntax error that proved nothing)
- GUI listing an off plugin's tools -> plugin-tools.test.cjs
Real use: a built magpie in a sandbox HOME (MAGPIE_ADDR 127.0.0.1:3491,
real Bun), the example plugin added with `magpie plugin add`. curl over
MCP: initialize, tools/list (4 tools, schemas), shout "HI HI (for
curl)", a missing argument as isError naming it, add {"sum":6.5}, fail
"it broke", a foreign Origin 403; plugin-tools.json written. Claude
Code (sandbox CLAUDE_CONFIG_DIR) `claude mcp add --transport http` +
`mcp list`: Connected. Not tried: a model calling a tool through a
real agent turn (no model in the sandbox). Binary and HOME removed.
|