Skip to content

Commit a51f129

Browse files
committed
test(connector-mcp): a credential written into transport.headers keeps the declaration fault
Pins the boundary the plain branch's comment now states: only the instance's auth takes the credential path; a header credential is part of the declaration and is fixed by editing it. Claude-Session: https://claude.ai/code/session_017xRBcVBKAFk1ntXSjvPt7U Co-authored-by: Claude <noreply@anthropic.com>
1 parent c762819 commit a51f129

2 files changed

Lines changed: 24 additions & 3 deletions

File tree

‎packages/connectors/connector-mcp/src/mcp-include-credential-scope.test.ts‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,25 @@ describe('mcp provider: an include the server does not list for the credential i
135135
expect(server.state.closed).toBe(1);
136136
});
137137

138+
it('control: a credential written into transport.headers is part of the declaration — the plain fault, even when it filtered the list', async () => {
139+
const server = scopedServer({ [NARROW_TOKEN]: ['whoami'] });
140+
const factory = createMcpProviderFactory({ clientFactory: server.clientFactory });
141+
const err = await thrownBy(() =>
142+
factory(ctx({
143+
providerConfig: {
144+
transport: { kind: 'http', url: URL, headers: { Authorization: `Bearer ${NARROW_TOKEN}` } },
145+
include: INCLUDE,
146+
},
147+
})),
148+
);
149+
expect(isConnectorCredentialRejected(err)).toBe(false);
150+
expect(isConnectorUpstreamUnavailable(err)).toBe(false);
151+
expect((err as Error).message).toContain(
152+
"providerConfig.include names 'search_invoices', 'read_invoice', which the MCP server does not list. Each entry",
153+
);
154+
expect((err as Error).message).toContain("the server lists 1 tool(s): 'whoami'.");
155+
});
156+
138157
it('control: a stdio instance with resolved auth keeps the plain fault — auth is not sent to a stdio server', async () => {
139158
const server = scopedServer({});
140159
const factory = createMcpProviderFactory({ clientFactory: server.clientFactory, declarativeStdio: true });

‎packages/connectors/connector-mcp/src/mcp-provider.ts‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -353,9 +353,11 @@ export function createMcpProviderFactory(deps: McpProviderDeps = {}): ConnectorP
353353
403,
354354
);
355355
}
356-
// No instance credential reached the server, so its list is not one
357-
// filtered for a credential: a configuration fault, thrown plain —
358-
// fatal at boot, a skipped entry on reload.
356+
// The instance's `auth` did not reach the server, so its list was not
357+
// filtered for a credential the administrator supplies; one written
358+
// into `providerConfig.transport.headers` is part of the declaration,
359+
// fixed by editing it. A configuration fault, thrown plain — fatal at
360+
// boot, a skipped entry on reload.
359361
throw new Error(
360362
`connector-mcp provider: connector '${ctx.name}' providerConfig.include names ` +
361363
`${named}, which the MCP server does not list. ` +

0 commit comments

Comments
 (0)