fix(mcp): invalidate replaced prompt catalogs
This commit is contained in:
parent
594eddb288
commit
f77f037225
2 changed files with 35 additions and 1 deletions
|
|
@ -555,7 +555,7 @@ export const layer = Layer.effect(
|
|||
s.defs[name] = listed
|
||||
watch(s, name, client, bridge, timeout)
|
||||
if (previous) yield* Effect.tryPromise(() => previous.close()).pipe(Effect.ignore)
|
||||
if (client.getServerCapabilities()?.prompts) {
|
||||
if (previous || client.getServerCapabilities()?.prompts) {
|
||||
yield* events.publish(CatalogChanged, { server: name, kinds: ["prompts"] }).pipe(Effect.ignore)
|
||||
}
|
||||
return s.status[name]
|
||||
|
|
|
|||
|
|
@ -458,6 +458,40 @@ it.instance(
|
|||
{ config: { mcp: {} } },
|
||||
)
|
||||
|
||||
it.instance(
|
||||
"replacing a prompt-capable server publishes catalog invalidation",
|
||||
() =>
|
||||
Effect.gen(function* () {
|
||||
const mcp = yield* MCP.Service
|
||||
lastCreatedClientName = "prompt-replace-server"
|
||||
const serverState = getOrCreateClientState("prompt-replace-server")
|
||||
serverState.prompts = [{ name: "original" }]
|
||||
|
||||
yield* mcp.add("prompt-replace-server", {
|
||||
type: "local",
|
||||
command: ["echo", "test"],
|
||||
})
|
||||
|
||||
serverState.capabilities = { tools: {} }
|
||||
|
||||
let changed = 0
|
||||
const listener = (event: GlobalEvent) => {
|
||||
if (event.payload.type !== MCP.CatalogChanged.type) return
|
||||
changed += 1
|
||||
}
|
||||
GlobalBus.on("event", listener)
|
||||
|
||||
yield* mcp.add("prompt-replace-server", {
|
||||
type: "local",
|
||||
command: ["echo", "test"],
|
||||
})
|
||||
GlobalBus.off("event", listener)
|
||||
|
||||
expect(changed).toBe(1)
|
||||
}),
|
||||
{ config: { mcp: {} } },
|
||||
)
|
||||
|
||||
// ========================================================================
|
||||
// Test: connect() / disconnect() lifecycle
|
||||
// ========================================================================
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue