What goes to Cursor named magpie in four places: the dynamic tool catalog
in the system prompt ('The MCP namespace "magpie" has the tools below' and
each <call> entry's "namespace":"magpie"), every CallDynamicTool call in
the history (args.namespace), each McpToolDefinition's provider_identifier
(field 4), and the server answered for mcp_state_exec_args (name and
identifier). magpie's LESSONS.md rule: text added to a vendor's prompt
names neither magpie nor the vendor's limits, with the care a header
change gets (5d33f060b / 3c4f8f9ae).
cursor-agent names a user's MCP server by its mcp.json label
(providerIdentifier = serverName) and a call by "<label>-<tool>"; read in
cursor-agent 2026.10.01-e373342. The plugin now does the same with the
generic label "tools" (NS), in all four places. Calls are read back under
NAMESPACES = ["tools", "magpie"]: a "<ns>-<tool>" name without field 5 is
stripped of either prefix, and a native exec's provider/server is accepted
as either, so a native session begun on 0.2.19 still has its calls served.
The non-native history is rebuilt from the caller's messages each request,
so it carries the new name at once.
Siblings in other packages that still name magpie upstream, filed, not
changed here: commandcode User-Agent and x-project-slug (#352), kimi-work
User-Agent (#353), qoder business.name (#354), autoclaw device_id (#355),
kimi-desktop's instructions tag (#356), opendesign's host fallback (#357),
layerfs tool descriptions (#358). Left alone as not upstream: X-Magpie-*
response headers, the x-magpie-cursor-session hook header (never sent to
Cursor), magpie_native/magpie_deferred usage fields, sign-in messages.
Test: upstream-words.test.mjs builds a Run (buildRun) from a conversation
with tools and a tool call, and checks that the catalog, every transcript
blob, the request bytes and the mcp_state answer contain no /magpie/i, and
that a call is read back as both "tools-read" and "magpie-read". Red on
the old index.mjs (2 of 3 fail: catalog, mcp_state); green now.
conversation, reasoning and native-test-wire expectations moved to
"tools"; native-e2e still sends provider "magpie", so the old name is
covered on the native path.
Run at this tree:
- bun test in packages/cursor: 279 pass, 0 fail (17 files).
- bun scripts/check.mjs: every package ok.
- Live, owner's Cursor account, sandbox HOME (scratchpad), the plugin's
loader.fetch with one read_file tool, http2 writes scanned for "magpie":
auto: turn 1 called read_file {"path":"notes.txt"}, turn 2 with the
result answered "Pelican"; 0 chunks named magpie (the old index.mjs
under the same scan: 2). grok-4.7-fast: the same two turns, 0 chunks.
claude-4.6-sonnet: 429, not in this plan's weekly usage.
Not tried: a native session resumed across the upgrade against real Cursor
(covered by native-e2e's "magpie" provider against the fake server only).
72 lines
3.5 KiB
JavaScript
72 lines
3.5 KiB
JavaScript
// Nothing this plugin writes into what goes to Cursor names magpie: the
|
|
// prompt, the dynamic tool catalog in it, the calls in the history, the
|
|
// tool definitions and the MCP server it answers Cursor's mcp_state with.
|
|
// Text added to a vendor's prompt is a ban risk, as a header is (magpie's
|
|
// LESSONS.md, 5d33f060b / 3c4f8f9ae). A session begun before 0.2.20, when
|
|
// the server was named "magpie", still has its calls read back.
|
|
import "./nonet.mjs" // first: no request leaves this machine
|
|
import { expect, test } from "bun:test"
|
|
import { _internal } from "./index.mjs"
|
|
|
|
const { conversation, toolsOf, buildRun, catalog, exec, pb } = _internal
|
|
|
|
const chat = {
|
|
model: "claude-4.6-sonnet",
|
|
messages: [
|
|
{ role: "system", content: "You are a coding agent." },
|
|
{ role: "user", content: "read a" },
|
|
{ role: "assistant", content: "Reading.", tool_calls: [{ id: "call_1", type: "function", function: { name: "read", arguments: '{"path":"a"}' } }] },
|
|
{ role: "tool", tool_call_id: "call_1", content: "A" },
|
|
{ role: "user", content: "and b" },
|
|
],
|
|
tools: [
|
|
{ type: "function", function: { name: "read", description: "Read a file", parameters: { type: "object", properties: { path: { type: "string" } } } } },
|
|
{ type: "function", function: { name: "bash", description: "Run a command", parameters: { type: "object", properties: { cmd: { type: "string" } } } } },
|
|
],
|
|
}
|
|
|
|
const named = (bytes) => /magpie/i.test(Buffer.from(bytes).toString("latin1"))
|
|
|
|
test("the prompt, the tool catalog, the calls and the tool definitions sent to Cursor never name magpie", () => {
|
|
const tools = toolsOf(chat)
|
|
expect(catalog(tools)).toContain("CallDynamicTool")
|
|
expect(catalog(tools)).not.toMatch(/magpie/i)
|
|
const conv = conversation(chat, tools)
|
|
for (const m of conv.msgs) expect(m.toString()).not.toMatch(/magpie/i)
|
|
const run = buildRun(conv.msgs, conv.last, tools, chat.model, "conv-1")
|
|
expect(named(run.first)).toBe(false)
|
|
for (const b of run.blobs.values()) expect(named(b)).toBe(false)
|
|
// what the catalog promises is what the definitions and calls say
|
|
const sys = JSON.parse(conv.msgs[0].toString()).content
|
|
const ns = /The MCP namespace "([^"]+)"/.exec(sys)[1]
|
|
expect(sys).toContain(`{"namespace":"${ns}","toolName":"read"`)
|
|
const call = conv.msgs.map((b) => JSON.parse(b.toString())).find((m) => m.role === "assistant").content.find((p) => p.type === "tool-call")
|
|
expect(call.args.namespace).toBe(ns)
|
|
expect(Buffer.from(run.first).toString("latin1")).toContain(ns)
|
|
})
|
|
|
|
test("the MCP server Cursor is told of never names magpie", () => {
|
|
const tools = toolsOf(chat)
|
|
const sent = []
|
|
const msg = pb().varint(1, 3).str(15, "x3").bytes(36, pb().done()).done()
|
|
expect(exec(msg, tools, (b) => sent.push(b), () => {})).toBe(null)
|
|
expect(sent.length).toBe(1)
|
|
expect(named(sent[0])).toBe(false)
|
|
})
|
|
|
|
// a call Cursor returns, by the server name now and by the old one
|
|
const callOf = (full, bare) => {
|
|
const a = pb().str(1, full).str(3, "call_9")
|
|
if (bare) a.str(5, bare)
|
|
return pb().varint(1, 7).str(15, "x1").bytes(11, a.done()).done()
|
|
}
|
|
|
|
test("a call is read back under the new server name and under magpie, from a session begun before", () => {
|
|
const tools = toolsOf(chat)
|
|
const ns = JSON.parse(conversation(chat, tools).msgs[0].toString()).content.match(/The MCP namespace "([^"]+)"/)[1]
|
|
for (const full of [ns + "-read", "magpie-read"]) {
|
|
expect(exec(callOf(full, "read"), tools, () => {}, () => {}).name).toBe("read")
|
|
expect(exec(callOf(full), tools, () => {}, () => {}).name).toBe("read")
|
|
}
|
|
})
|