Skip to content

Commit 9ba0c56

Browse files
committed
test(mcp): a refused by-name agent read travels naming every holder
Claude-Session: https://claude.ai/code/session_01ADHkmTH1oAwgDMigQ9pj37 Co-authored-by: Claude <noreply@anthropic.com>
1 parent 5915671 commit 9ba0c56

2 files changed

Lines changed: 29 additions & 1 deletion

File tree

‎.changeset/31680-presentation-ai-reads-by-package.md‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,8 @@ Metadata-protocol: none
1818
2. A package caller reads a name that only the environment's own item holds.
1919
3. A package caller reads a name whose one holder is a package it does not declare as a dependency.
2020

21-
The fix is one line. For 1 and 3, declare the holding package in the reading package's `dependencies`, or name the package the read means with `?package=`. For 2, ship the item in the reading package or in a package it depends on. None of the four example apps in this repository hits any of the three.
21+
The fix is one line, and none of the four example apps in this repository needs it:
22+
23+
- FROM a bare read of a name two packages ship TO the read that names the package it means (`?package=<id>`).
24+
- FROM a package caller reading the environment's own item TO the item shipped in the reading package, or in a package it depends on.
25+
- FROM a package caller reading a package it does not depend on TO that package declared in the reader's `dependencies`.

‎packages/mcp/src/mcp-server-runtime.agent-prompt-advertised.test.ts‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,30 @@ describe('agent_prompt — one reader with GET /meta/agent/NAME (the protocol)',
409409
}
410410
});
411411

412+
it('[#31680, ADR-0150 D3] a by-name read the package-scoped resolver refuses (409 RESOURCE_CONFLICT) travels naming every holder: never "not found", never the outage text', async () => {
413+
// The protocol's package-less by-name read refuses a name more than one
414+
// package holds, naming each (child E8). Read here as a miss it would tell
415+
// the client the agent does not exist; read as the #6055 outage it would
416+
// say nothing is known. It is neither: it travels as the refusal it is.
417+
const refusal = Object.assign(
418+
new Error('agent "pkg_helper" is held by com.acme.alpha and com.acme.beta: qualify the name with its package'),
419+
{ code: 'RESOURCE_CONFLICT', status: 409, httpStatus: 409 },
420+
);
421+
const session = await connectWith(
422+
metadataService({ agents: [] }),
423+
protocol({ byName: async () => { throw refusal; } }),
424+
);
425+
try {
426+
const got = session.client.getPrompt({ name: 'agent_prompt', arguments: { agentName: 'pkg_helper' } });
427+
await expect(got).rejects.toThrow(/com\.acme\.alpha and com\.acme\.beta/);
428+
await expect(got).rejects.not.toThrow(/not found|SERVICE_UNAVAILABLE/);
429+
await expect(got).rejects.not.toThrow(PACKAGE_AGENT.instructions);
430+
expect(session.log.warn).not.toHaveBeenCalledWith(expect.stringContaining('agent prompt refused'), expect.anything());
431+
} finally {
432+
await session.close();
433+
}
434+
});
435+
412436
it('a degraded roster verdict with the protocol present and no agent named keeps the prompt listed, naming no agent', async () => {
413437
const session = await connectWith(
414438
metadataService({

0 commit comments

Comments
 (0)