Skip to content

fix(client): guard notification wiring against non-function prototype props#19

Merged
kauandotnet merged 1 commit intomainfrom
fix/client-bootstrap-non-function-prototype
Apr 23, 2026
Merged

fix(client): guard notification wiring against non-function prototype props#19
kauandotnet merged 1 commit intomainfrom
fix/client-bootstrap-non-function-prototype

Conversation

@kauandotnet
Copy link
Copy Markdown
Collaborator

Summary

  • Fixes McpClientBootstrap.wireNotificationHandlers trips on non-function own properties of provider prototypes #18McpClientBootstrap.wireNotificationHandlers throwing TypeError when any provider in the DI graph has a prototype whose getOwnPropertyNames list includes a non-function value (e.g. useValue: {} providers, whose prototype is Object.prototype and Object.prototype.__proto__ resolves to null).
  • Adds a typeof method !== 'function' guard before the Reflect.getMetadata call, hoisting prototype[methodName] into a local.
  • Adds a regression test that seeds a plain-object provider alongside a handler whose prototype carries both a getter returning null and a primitive data property, asserting bootstrap resolves and the real handler still wires.

Test plan

  • cd packages/client && pnpm test — 202/202 pass (new test + 201 existing)
  • New test fails with the exact TypeError at Reflect.js:367 from wireNotificationHandlers before the guard is applied

… props

McpClientBootstrap.wireNotificationHandlers iterates each provider's
prototype own-property names and calls Reflect.getMetadata with the
value at each key. When any provider in the DI graph has a prototype
whose own-property list includes a non-function (e.g. plain-object
providers registered via useValue where the prototype is
Object.prototype and Object.prototype.__proto__ resolves to null, or
library classes with accessor properties returning primitives),
Reflect.getMetadata throws TypeError because its target must be an
object. This blocked any app combining McpClientModule with common
useValue: {} config providers.

Skip prototype entries whose value is not a function before looking up
metadata.

Fixes #18
@docs-page
Copy link
Copy Markdown

docs-page Bot commented Apr 23, 2026

To view this pull requests documentation preview, visit the following URL:

docs.page/btwld/nest-mcp~19

Documentation is deployed and generated using docs.page.

@kauandotnet kauandotnet self-assigned this Apr 23, 2026
@kauandotnet kauandotnet merged commit 160885a into main Apr 23, 2026
2 checks passed
@kauandotnet kauandotnet deleted the fix/client-bootstrap-non-function-prototype branch April 23, 2026 21:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

McpClientBootstrap.wireNotificationHandlers trips on non-function own properties of provider prototypes

1 participant