@tambo-ai/react 1.1.0 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/context-helpers/current-interactables-context-helper.d.ts +16 -2
- package/dist/context-helpers/current-interactables-context-helper.d.ts.map +1 -1
- package/dist/context-helpers/current-interactables-context-helper.js.map +1 -1
- package/dist/context-helpers/current-interactables-context-helper.test.d.ts +2 -0
- package/dist/context-helpers/current-interactables-context-helper.test.d.ts.map +1 -0
- package/dist/context-helpers/current-interactables-context-helper.test.js +70 -0
- package/dist/context-helpers/current-interactables-context-helper.test.js.map +1 -0
- package/dist/hoc/with-tambo-interactable.d.ts.map +1 -1
- package/dist/hoc/with-tambo-interactable.js +11 -2
- package/dist/hoc/with-tambo-interactable.js.map +1 -1
- package/dist/hoc/with-tambo-interactable.test.js +14 -0
- package/dist/hoc/with-tambo-interactable.test.js.map +1 -1
- package/dist/mcp/elicitation.d.ts +3 -37
- package/dist/mcp/elicitation.d.ts.map +1 -1
- package/dist/mcp/elicitation.js +7 -24
- package/dist/mcp/elicitation.js.map +1 -1
- package/dist/mcp/index.d.ts +4 -4
- package/dist/mcp/index.d.ts.map +1 -1
- package/dist/mcp/index.js +2 -2
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/mcp-client.test.js +17 -17
- package/dist/mcp/mcp-client.test.js.map +1 -1
- package/dist/mcp/mcp-hooks.d.ts.map +1 -1
- package/dist/mcp/mcp-hooks.js +8 -5
- package/dist/mcp/mcp-hooks.js.map +1 -1
- package/dist/mcp/mcp-hooks.test.js +30 -29
- package/dist/mcp/mcp-hooks.test.js.map +1 -1
- package/dist/mcp/tambo-mcp-provider.d.ts +6 -9
- package/dist/mcp/tambo-mcp-provider.d.ts.map +1 -1
- package/dist/mcp/tambo-mcp-provider.js +9 -13
- package/dist/mcp/tambo-mcp-provider.js.map +1 -1
- package/dist/mcp/tambo-mcp-provider.test.js +26 -25
- package/dist/mcp/tambo-mcp-provider.test.js.map +1 -1
- package/dist/mcp/use-mcp-servers.test.js +2 -1
- package/dist/mcp/use-mcp-servers.test.js.map +1 -1
- package/dist/model/component-metadata.d.ts +7 -372
- package/dist/model/component-metadata.d.ts.map +1 -1
- package/dist/model/component-metadata.js.map +1 -1
- package/dist/model/validate-input.test.d.ts +2 -0
- package/dist/model/validate-input.test.d.ts.map +1 -0
- package/dist/model/validate-input.test.js +38 -0
- package/dist/model/validate-input.test.js.map +1 -0
- package/dist/providers/tambo-interactable-provider-partial-updates.test.js +2 -0
- package/dist/providers/tambo-interactable-provider-partial-updates.test.js.map +1 -1
- package/dist/providers/tambo-interactable-provider.d.ts +7 -7
- package/dist/providers/tambo-interactable-provider.d.ts.map +1 -1
- package/dist/providers/tambo-interactable-provider.js +26 -4
- package/dist/providers/tambo-interactable-provider.js.map +1 -1
- package/dist/providers/tambo-interactable-provider.test.js +78 -0
- package/dist/providers/tambo-interactable-provider.test.js.map +1 -1
- package/dist/providers/tambo-registry-provider.d.ts +2 -1
- package/dist/providers/tambo-registry-provider.d.ts.map +1 -1
- package/dist/providers/tambo-registry-provider.js +19 -0
- package/dist/providers/tambo-registry-provider.js.map +1 -1
- package/dist/providers/tambo-registry-provider.test.js +36 -0
- package/dist/providers/tambo-registry-provider.test.js.map +1 -1
- package/dist/providers/tambo-registry-schema-compat.test.js +4 -4
- package/dist/providers/tambo-registry-schema-compat.test.js.map +1 -1
- package/dist/schema/index.d.ts +2 -4
- package/dist/schema/index.d.ts.map +1 -1
- package/dist/schema/index.js +9 -11
- package/dist/schema/index.js.map +1 -1
- package/dist/schema/json-schema.d.ts +1 -17
- package/dist/schema/json-schema.d.ts.map +1 -1
- package/dist/schema/json-schema.js +5 -69
- package/dist/schema/json-schema.js.map +1 -1
- package/dist/schema/schema.test.js +24 -25
- package/dist/schema/schema.test.js.map +1 -1
- package/dist/schema/standard-schema.test.js +25 -25
- package/dist/schema/standard-schema.test.js.map +1 -1
- package/dist/schema/validate.test.js +33 -33
- package/dist/schema/validate.test.js.map +1 -1
- package/dist/testing/tools.d.ts +4 -4
- package/dist/testing/tools.test.d.ts +2 -0
- package/dist/testing/tools.test.d.ts.map +1 -0
- package/dist/testing/tools.test.js +60 -0
- package/dist/testing/tools.test.js.map +1 -0
- package/dist/util/mcp-server-utils.d.ts +1 -1
- package/dist/util/mcp-server-utils.d.ts.map +1 -1
- package/dist/util/mcp-server-utils.js +4 -4
- package/dist/util/mcp-server-utils.js.map +1 -1
- package/dist/util/mcp-server-utils.test.js +27 -27
- package/dist/util/mcp-server-utils.test.js.map +1 -1
- package/dist/util/registry.js +1 -1
- package/dist/util/registry.js.map +1 -1
- package/dist/util/resource-content-resolver.js +5 -5
- package/dist/util/resource-content-resolver.js.map +1 -1
- package/dist/util/resource-content-resolver.test.js +6 -6
- package/dist/util/resource-content-resolver.test.js.map +1 -1
- package/dist/util/tool-caller.test.d.ts +2 -0
- package/dist/util/tool-caller.test.d.ts.map +1 -0
- package/dist/util/tool-caller.test.js +71 -0
- package/dist/util/tool-caller.test.js.map +1 -0
- package/dist/v1/__tests__/v1-interactables.test.js +6 -0
- package/dist/v1/__tests__/v1-interactables.test.js.map +1 -1
- package/dist/v1/components/v1-component-renderer.test.js +1 -0
- package/dist/v1/components/v1-component-renderer.test.js.map +1 -1
- package/dist/v1/hooks/use-tambo-v1-auth-state.d.ts +1 -1
- package/dist/v1/hooks/use-tambo-v1-auth-state.d.ts.map +1 -1
- package/dist/v1/hooks/use-tambo-v1-auth-state.js.map +1 -1
- package/dist/v1/hooks/use-tambo-v1-component-state.js +2 -2
- package/dist/v1/hooks/use-tambo-v1-component-state.js.map +1 -1
- package/dist/v1/hooks/use-tambo-v1-component-state.test.js +1 -1
- package/dist/v1/hooks/use-tambo-v1-component-state.test.js.map +1 -1
- package/dist/v1/hooks/use-tambo-v1-send-message.d.ts +1 -1
- package/dist/v1/hooks/use-tambo-v1-send-message.d.ts.map +1 -1
- package/dist/v1/hooks/use-tambo-v1-send-message.js +17 -17
- package/dist/v1/hooks/use-tambo-v1-send-message.js.map +1 -1
- package/dist/v1/hooks/use-tambo-v1-send-message.test.js +1 -1
- package/dist/v1/hooks/use-tambo-v1-send-message.test.js.map +1 -1
- package/dist/v1/hooks/use-tambo-v1-stream-status.js +2 -2
- package/dist/v1/hooks/use-tambo-v1-stream-status.js.map +1 -1
- package/dist/v1/hooks/use-tambo-v1-stream-status.test.js +9 -5
- package/dist/v1/hooks/use-tambo-v1-stream-status.test.js.map +1 -1
- package/dist/v1/hooks/use-tambo-v1-suggestions.js +2 -2
- package/dist/v1/hooks/use-tambo-v1-suggestions.js.map +1 -1
- package/dist/v1/hooks/use-tambo-v1-thread-input.test.js +1 -0
- package/dist/v1/hooks/use-tambo-v1-thread-input.test.js.map +1 -1
- package/dist/v1/hooks/use-tambo-v1.d.ts +7 -6
- package/dist/v1/hooks/use-tambo-v1.d.ts.map +1 -1
- package/dist/v1/hooks/use-tambo-v1.js +2 -2
- package/dist/v1/hooks/use-tambo-v1.js.map +1 -1
- package/dist/v1/hooks/use-tambo-v1.test.js +24 -23
- package/dist/v1/hooks/use-tambo-v1.test.js.map +1 -1
- package/dist/v1/index.d.ts +6 -6
- package/dist/v1/index.d.ts.map +1 -1
- package/dist/v1/index.js +2 -2
- package/dist/v1/index.js.map +1 -1
- package/dist/v1/providers/tambo-v1-provider.d.ts +2 -1
- package/dist/v1/providers/tambo-v1-provider.d.ts.map +1 -1
- package/dist/v1/providers/tambo-v1-provider.js +2 -0
- package/dist/v1/providers/tambo-v1-provider.js.map +1 -1
- package/dist/v1/providers/tambo-v1-stream-context.d.ts +2 -2
- package/dist/v1/providers/tambo-v1-stream-context.d.ts.map +1 -1
- package/dist/v1/providers/tambo-v1-stream-context.js +9 -9
- package/dist/v1/providers/tambo-v1-stream-context.js.map +1 -1
- package/dist/v1/providers/tambo-v1-stream-context.test.js +35 -0
- package/dist/v1/providers/tambo-v1-stream-context.test.js.map +1 -1
- package/dist/v1/providers/tambo-v1-stub-provider.d.ts +1 -1
- package/dist/v1/providers/tambo-v1-stub-provider.d.ts.map +1 -1
- package/dist/v1/providers/tambo-v1-stub-provider.js +2 -1
- package/dist/v1/providers/tambo-v1-stub-provider.js.map +1 -1
- package/dist/v1/providers/tambo-v1-stub-provider.test.js.map +1 -1
- package/dist/v1/providers/tambo-v1-thread-input-provider.d.ts +1 -1
- package/dist/v1/providers/tambo-v1-thread-input-provider.d.ts.map +1 -1
- package/dist/v1/providers/tambo-v1-thread-input-provider.js +2 -2
- package/dist/v1/providers/tambo-v1-thread-input-provider.js.map +1 -1
- package/dist/v1/types/event.test.js +13 -13
- package/dist/v1/types/event.test.js.map +1 -1
- package/dist/v1/types/message.d.ts +12 -109
- package/dist/v1/types/message.d.ts.map +1 -1
- package/dist/v1/types/message.js +0 -7
- package/dist/v1/types/message.js.map +1 -1
- package/dist/v1/utils/event-accumulator.test.js +183 -184
- package/dist/v1/utils/event-accumulator.test.js.map +1 -1
- package/dist/v1/utils/json-patch.test.js +4 -4
- package/dist/v1/utils/json-patch.test.js.map +1 -1
- package/dist/v1/utils/keyed-throttle.test.js +12 -12
- package/dist/v1/utils/keyed-throttle.test.js.map +1 -1
- package/dist/v1/utils/registry-conversion.test.js +13 -13
- package/dist/v1/utils/registry-conversion.test.js.map +1 -1
- package/dist/v1/utils/stream-handler.test.js +5 -5
- package/dist/v1/utils/stream-handler.test.js.map +1 -1
- package/dist/v1/utils/tool-call-tracker.test.js +15 -9
- package/dist/v1/utils/tool-call-tracker.test.js.map +1 -1
- package/dist/v1/utils/tool-executor.test.js +25 -26
- package/dist/v1/utils/tool-executor.test.js.map +1 -1
- package/dist/v1/utils/unstrictify.test.js +16 -16
- package/dist/v1/utils/unstrictify.test.js.map +1 -1
- package/esm/context-helpers/current-interactables-context-helper.d.ts +16 -2
- package/esm/context-helpers/current-interactables-context-helper.d.ts.map +1 -1
- package/esm/context-helpers/current-interactables-context-helper.js.map +1 -1
- package/esm/context-helpers/current-interactables-context-helper.test.d.ts +2 -0
- package/esm/context-helpers/current-interactables-context-helper.test.d.ts.map +1 -0
- package/esm/context-helpers/current-interactables-context-helper.test.js +68 -0
- package/esm/context-helpers/current-interactables-context-helper.test.js.map +1 -0
- package/esm/hoc/with-tambo-interactable.d.ts.map +1 -1
- package/esm/hoc/with-tambo-interactable.js +11 -2
- package/esm/hoc/with-tambo-interactable.js.map +1 -1
- package/esm/hoc/with-tambo-interactable.test.js +14 -0
- package/esm/hoc/with-tambo-interactable.test.js.map +1 -1
- package/esm/mcp/elicitation.d.ts +3 -37
- package/esm/mcp/elicitation.d.ts.map +1 -1
- package/esm/mcp/elicitation.js +4 -24
- package/esm/mcp/elicitation.js.map +1 -1
- package/esm/mcp/index.d.ts +4 -4
- package/esm/mcp/index.d.ts.map +1 -1
- package/esm/mcp/index.js +1 -1
- package/esm/mcp/index.js.map +1 -1
- package/esm/mcp/mcp-client.test.js +1 -1
- package/esm/mcp/mcp-client.test.js.map +1 -1
- package/esm/mcp/mcp-hooks.d.ts.map +1 -1
- package/esm/mcp/mcp-hooks.js +4 -1
- package/esm/mcp/mcp-hooks.js.map +1 -1
- package/esm/mcp/mcp-hooks.test.js +3 -2
- package/esm/mcp/mcp-hooks.test.js.map +1 -1
- package/esm/mcp/tambo-mcp-provider.d.ts +6 -9
- package/esm/mcp/tambo-mcp-provider.d.ts.map +1 -1
- package/esm/mcp/tambo-mcp-provider.js +4 -8
- package/esm/mcp/tambo-mcp-provider.js.map +1 -1
- package/esm/mcp/tambo-mcp-provider.test.js +3 -2
- package/esm/mcp/tambo-mcp-provider.test.js.map +1 -1
- package/esm/mcp/use-mcp-servers.test.js +2 -1
- package/esm/mcp/use-mcp-servers.test.js.map +1 -1
- package/esm/model/component-metadata.d.ts +7 -372
- package/esm/model/component-metadata.d.ts.map +1 -1
- package/esm/model/component-metadata.js.map +1 -1
- package/esm/model/validate-input.test.d.ts +2 -0
- package/esm/model/validate-input.test.d.ts.map +1 -0
- package/esm/model/validate-input.test.js +36 -0
- package/esm/model/validate-input.test.js.map +1 -0
- package/esm/providers/tambo-interactable-provider-partial-updates.test.js +2 -0
- package/esm/providers/tambo-interactable-provider-partial-updates.test.js.map +1 -1
- package/esm/providers/tambo-interactable-provider.d.ts +7 -7
- package/esm/providers/tambo-interactable-provider.d.ts.map +1 -1
- package/esm/providers/tambo-interactable-provider.js +26 -4
- package/esm/providers/tambo-interactable-provider.js.map +1 -1
- package/esm/providers/tambo-interactable-provider.test.js +78 -0
- package/esm/providers/tambo-interactable-provider.test.js.map +1 -1
- package/esm/providers/tambo-registry-provider.d.ts +2 -1
- package/esm/providers/tambo-registry-provider.d.ts.map +1 -1
- package/esm/providers/tambo-registry-provider.js +19 -0
- package/esm/providers/tambo-registry-provider.js.map +1 -1
- package/esm/providers/tambo-registry-provider.test.js +36 -0
- package/esm/providers/tambo-registry-provider.test.js.map +1 -1
- package/esm/providers/tambo-registry-schema-compat.test.js +4 -4
- package/esm/providers/tambo-registry-schema-compat.test.js.map +1 -1
- package/esm/schema/index.d.ts +2 -4
- package/esm/schema/index.d.ts.map +1 -1
- package/esm/schema/index.js +2 -4
- package/esm/schema/index.js.map +1 -1
- package/esm/schema/json-schema.d.ts +1 -17
- package/esm/schema/json-schema.d.ts.map +1 -1
- package/esm/schema/json-schema.js +2 -67
- package/esm/schema/json-schema.js.map +1 -1
- package/esm/schema/schema.test.js +1 -2
- package/esm/schema/schema.test.js.map +1 -1
- package/esm/schema/standard-schema.test.js +1 -1
- package/esm/schema/standard-schema.test.js.map +1 -1
- package/esm/schema/validate.test.js +1 -1
- package/esm/schema/validate.test.js.map +1 -1
- package/esm/testing/tools.d.ts +4 -4
- package/esm/testing/tools.test.d.ts +2 -0
- package/esm/testing/tools.test.d.ts.map +1 -0
- package/esm/testing/tools.test.js +58 -0
- package/esm/testing/tools.test.js.map +1 -0
- package/esm/util/mcp-server-utils.d.ts +1 -1
- package/esm/util/mcp-server-utils.d.ts.map +1 -1
- package/esm/util/mcp-server-utils.js +1 -1
- package/esm/util/mcp-server-utils.js.map +1 -1
- package/esm/util/mcp-server-utils.test.js +1 -1
- package/esm/util/mcp-server-utils.test.js.map +1 -1
- package/esm/util/registry.js +1 -1
- package/esm/util/registry.js.map +1 -1
- package/esm/util/resource-content-resolver.js +1 -1
- package/esm/util/resource-content-resolver.js.map +1 -1
- package/esm/util/resource-content-resolver.test.js +2 -2
- package/esm/util/resource-content-resolver.test.js.map +1 -1
- package/esm/util/tool-caller.test.d.ts +2 -0
- package/esm/util/tool-caller.test.d.ts.map +1 -0
- package/esm/util/tool-caller.test.js +69 -0
- package/esm/util/tool-caller.test.js.map +1 -0
- package/esm/v1/__tests__/v1-interactables.test.js +6 -0
- package/esm/v1/__tests__/v1-interactables.test.js.map +1 -1
- package/esm/v1/components/v1-component-renderer.test.js +1 -0
- package/esm/v1/components/v1-component-renderer.test.js.map +1 -1
- package/esm/v1/hooks/use-tambo-v1-auth-state.d.ts +1 -1
- package/esm/v1/hooks/use-tambo-v1-auth-state.d.ts.map +1 -1
- package/esm/v1/hooks/use-tambo-v1-auth-state.js.map +1 -1
- package/esm/v1/hooks/use-tambo-v1-component-state.js +1 -1
- package/esm/v1/hooks/use-tambo-v1-component-state.js.map +1 -1
- package/esm/v1/hooks/use-tambo-v1-component-state.test.js +1 -1
- package/esm/v1/hooks/use-tambo-v1-component-state.test.js.map +1 -1
- package/esm/v1/hooks/use-tambo-v1-send-message.d.ts +1 -1
- package/esm/v1/hooks/use-tambo-v1-send-message.d.ts.map +1 -1
- package/esm/v1/hooks/use-tambo-v1-send-message.js +6 -6
- package/esm/v1/hooks/use-tambo-v1-send-message.js.map +1 -1
- package/esm/v1/hooks/use-tambo-v1-send-message.test.js +1 -1
- package/esm/v1/hooks/use-tambo-v1-send-message.test.js.map +1 -1
- package/esm/v1/hooks/use-tambo-v1-stream-status.js +1 -1
- package/esm/v1/hooks/use-tambo-v1-stream-status.js.map +1 -1
- package/esm/v1/hooks/use-tambo-v1-stream-status.test.js +9 -5
- package/esm/v1/hooks/use-tambo-v1-stream-status.test.js.map +1 -1
- package/esm/v1/hooks/use-tambo-v1-suggestions.js +1 -1
- package/esm/v1/hooks/use-tambo-v1-suggestions.js.map +1 -1
- package/esm/v1/hooks/use-tambo-v1-thread-input.test.js +1 -0
- package/esm/v1/hooks/use-tambo-v1-thread-input.test.js.map +1 -1
- package/esm/v1/hooks/use-tambo-v1.d.ts +7 -6
- package/esm/v1/hooks/use-tambo-v1.d.ts.map +1 -1
- package/esm/v1/hooks/use-tambo-v1.js +1 -1
- package/esm/v1/hooks/use-tambo-v1.js.map +1 -1
- package/esm/v1/hooks/use-tambo-v1.test.js +23 -22
- package/esm/v1/hooks/use-tambo-v1.test.js.map +1 -1
- package/esm/v1/index.d.ts +6 -6
- package/esm/v1/index.d.ts.map +1 -1
- package/esm/v1/index.js +1 -1
- package/esm/v1/index.js.map +1 -1
- package/esm/v1/providers/tambo-v1-provider.d.ts +2 -1
- package/esm/v1/providers/tambo-v1-provider.d.ts.map +1 -1
- package/esm/v1/providers/tambo-v1-provider.js +2 -0
- package/esm/v1/providers/tambo-v1-provider.js.map +1 -1
- package/esm/v1/providers/tambo-v1-stream-context.d.ts +2 -2
- package/esm/v1/providers/tambo-v1-stream-context.d.ts.map +1 -1
- package/esm/v1/providers/tambo-v1-stream-context.js +1 -1
- package/esm/v1/providers/tambo-v1-stream-context.js.map +1 -1
- package/esm/v1/providers/tambo-v1-stream-context.test.js +35 -0
- package/esm/v1/providers/tambo-v1-stream-context.test.js.map +1 -1
- package/esm/v1/providers/tambo-v1-stub-provider.d.ts +1 -1
- package/esm/v1/providers/tambo-v1-stub-provider.d.ts.map +1 -1
- package/esm/v1/providers/tambo-v1-stub-provider.js +2 -1
- package/esm/v1/providers/tambo-v1-stub-provider.js.map +1 -1
- package/esm/v1/providers/tambo-v1-stub-provider.test.js.map +1 -1
- package/esm/v1/providers/tambo-v1-thread-input-provider.d.ts +1 -1
- package/esm/v1/providers/tambo-v1-thread-input-provider.d.ts.map +1 -1
- package/esm/v1/providers/tambo-v1-thread-input-provider.js +1 -1
- package/esm/v1/providers/tambo-v1-thread-input-provider.js.map +1 -1
- package/esm/v1/types/event.test.js +1 -1
- package/esm/v1/types/event.test.js.map +1 -1
- package/esm/v1/types/message.d.ts +12 -109
- package/esm/v1/types/message.d.ts.map +1 -1
- package/esm/v1/types/message.js +0 -7
- package/esm/v1/types/message.js.map +1 -1
- package/esm/v1/utils/event-accumulator.test.js +2 -3
- package/esm/v1/utils/event-accumulator.test.js.map +1 -1
- package/esm/v1/utils/json-patch.test.js +1 -1
- package/esm/v1/utils/json-patch.test.js.map +1 -1
- package/esm/v1/utils/keyed-throttle.test.js +1 -1
- package/esm/v1/utils/keyed-throttle.test.js.map +1 -1
- package/esm/v1/utils/registry-conversion.test.js +1 -1
- package/esm/v1/utils/registry-conversion.test.js.map +1 -1
- package/esm/v1/utils/stream-handler.test.js +1 -1
- package/esm/v1/utils/stream-handler.test.js.map +1 -1
- package/esm/v1/utils/tool-call-tracker.test.js +9 -3
- package/esm/v1/utils/tool-call-tracker.test.js.map +1 -1
- package/esm/v1/utils/tool-executor.test.js +1 -2
- package/esm/v1/utils/tool-executor.test.js.map +1 -1
- package/esm/v1/utils/unstrictify.test.js +1 -1
- package/esm/v1/utils/unstrictify.test.js.map +1 -1
- package/package.json +10 -11
- package/dist/mcp/mcp-client.d.ts +0 -185
- package/dist/mcp/mcp-client.d.ts.map +0 -1
- package/dist/mcp/mcp-client.js +0 -219
- package/dist/mcp/mcp-client.js.map +0 -1
- package/dist/mcp/mcp-constants.d.ts +0 -19
- package/dist/mcp/mcp-constants.d.ts.map +0 -1
- package/dist/mcp/mcp-constants.js +0 -21
- package/dist/mcp/mcp-constants.js.map +0 -1
- package/dist/model/mcp-server-info.d.ts +0 -76
- package/dist/model/mcp-server-info.d.ts.map +0 -1
- package/dist/model/mcp-server-info.js +0 -29
- package/dist/model/mcp-server-info.js.map +0 -1
- package/dist/schema/schema.d.ts +0 -49
- package/dist/schema/schema.d.ts.map +0 -1
- package/dist/schema/schema.js +0 -129
- package/dist/schema/schema.js.map +0 -1
- package/dist/schema/standard-schema.d.ts +0 -22
- package/dist/schema/standard-schema.d.ts.map +0 -1
- package/dist/schema/standard-schema.js +0 -42
- package/dist/schema/standard-schema.js.map +0 -1
- package/dist/schema/validate.d.ts +0 -14
- package/dist/schema/validate.d.ts.map +0 -1
- package/dist/schema/validate.js +0 -148
- package/dist/schema/validate.js.map +0 -1
- package/dist/v1/types/auth.d.ts +0 -24
- package/dist/v1/types/auth.d.ts.map +0 -1
- package/dist/v1/types/auth.js +0 -3
- package/dist/v1/types/auth.js.map +0 -1
- package/dist/v1/types/event.d.ts +0 -89
- package/dist/v1/types/event.d.ts.map +0 -1
- package/dist/v1/types/event.js +0 -57
- package/dist/v1/types/event.js.map +0 -1
- package/dist/v1/types/thread.d.ts +0 -58
- package/dist/v1/types/thread.d.ts.map +0 -1
- package/dist/v1/types/thread.js +0 -9
- package/dist/v1/types/thread.js.map +0 -1
- package/dist/v1/types/tool-choice.d.ts +0 -8
- package/dist/v1/types/tool-choice.d.ts.map +0 -1
- package/dist/v1/types/tool-choice.js +0 -3
- package/dist/v1/types/tool-choice.js.map +0 -1
- package/dist/v1/utils/event-accumulator.d.ts +0 -165
- package/dist/v1/utils/event-accumulator.d.ts.map +0 -1
- package/dist/v1/utils/event-accumulator.js +0 -1277
- package/dist/v1/utils/event-accumulator.js.map +0 -1
- package/dist/v1/utils/json-patch.d.ts +0 -18
- package/dist/v1/utils/json-patch.d.ts.map +0 -1
- package/dist/v1/utils/json-patch.js +0 -35
- package/dist/v1/utils/json-patch.js.map +0 -1
- package/dist/v1/utils/keyed-throttle.d.ts +0 -42
- package/dist/v1/utils/keyed-throttle.d.ts.map +0 -1
- package/dist/v1/utils/keyed-throttle.js +0 -86
- package/dist/v1/utils/keyed-throttle.js.map +0 -1
- package/dist/v1/utils/registry-conversion.d.ts +0 -53
- package/dist/v1/utils/registry-conversion.d.ts.map +0 -1
- package/dist/v1/utils/registry-conversion.js +0 -115
- package/dist/v1/utils/registry-conversion.js.map +0 -1
- package/dist/v1/utils/stream-handler.d.ts +0 -45
- package/dist/v1/utils/stream-handler.d.ts.map +0 -1
- package/dist/v1/utils/stream-handler.js +0 -47
- package/dist/v1/utils/stream-handler.js.map +0 -1
- package/dist/v1/utils/thread-utils.d.ts +0 -16
- package/dist/v1/utils/thread-utils.d.ts.map +0 -1
- package/dist/v1/utils/thread-utils.js +0 -34
- package/dist/v1/utils/thread-utils.js.map +0 -1
- package/dist/v1/utils/tool-call-tracker.d.ts +0 -73
- package/dist/v1/utils/tool-call-tracker.d.ts.map +0 -1
- package/dist/v1/utils/tool-call-tracker.js +0 -180
- package/dist/v1/utils/tool-call-tracker.js.map +0 -1
- package/dist/v1/utils/tool-executor.d.ts +0 -67
- package/dist/v1/utils/tool-executor.d.ts.map +0 -1
- package/dist/v1/utils/tool-executor.js +0 -160
- package/dist/v1/utils/tool-executor.js.map +0 -1
- package/dist/v1/utils/unstrictify.d.ts +0 -32
- package/dist/v1/utils/unstrictify.d.ts.map +0 -1
- package/dist/v1/utils/unstrictify.js +0 -159
- package/dist/v1/utils/unstrictify.js.map +0 -1
- package/esm/mcp/mcp-client.d.ts +0 -185
- package/esm/mcp/mcp-client.d.ts.map +0 -1
- package/esm/mcp/mcp-client.js +0 -216
- package/esm/mcp/mcp-client.js.map +0 -1
- package/esm/mcp/mcp-constants.d.ts +0 -19
- package/esm/mcp/mcp-constants.d.ts.map +0 -1
- package/esm/mcp/mcp-constants.js +0 -18
- package/esm/mcp/mcp-constants.js.map +0 -1
- package/esm/model/mcp-server-info.d.ts +0 -76
- package/esm/model/mcp-server-info.d.ts.map +0 -1
- package/esm/model/mcp-server-info.js +0 -25
- package/esm/model/mcp-server-info.js.map +0 -1
- package/esm/schema/schema.d.ts +0 -49
- package/esm/schema/schema.d.ts.map +0 -1
- package/esm/schema/schema.js +0 -124
- package/esm/schema/schema.js.map +0 -1
- package/esm/schema/standard-schema.d.ts +0 -22
- package/esm/schema/standard-schema.d.ts.map +0 -1
- package/esm/schema/standard-schema.js +0 -39
- package/esm/schema/standard-schema.js.map +0 -1
- package/esm/schema/validate.d.ts +0 -14
- package/esm/schema/validate.d.ts.map +0 -1
- package/esm/schema/validate.js +0 -145
- package/esm/schema/validate.js.map +0 -1
- package/esm/v1/types/auth.d.ts +0 -24
- package/esm/v1/types/auth.d.ts.map +0 -1
- package/esm/v1/types/auth.js +0 -2
- package/esm/v1/types/auth.js.map +0 -1
- package/esm/v1/types/event.d.ts +0 -89
- package/esm/v1/types/event.d.ts.map +0 -1
- package/esm/v1/types/event.js +0 -53
- package/esm/v1/types/event.js.map +0 -1
- package/esm/v1/types/thread.d.ts +0 -58
- package/esm/v1/types/thread.d.ts.map +0 -1
- package/esm/v1/types/thread.js +0 -8
- package/esm/v1/types/thread.js.map +0 -1
- package/esm/v1/types/tool-choice.d.ts +0 -8
- package/esm/v1/types/tool-choice.d.ts.map +0 -1
- package/esm/v1/types/tool-choice.js +0 -2
- package/esm/v1/types/tool-choice.js.map +0 -1
- package/esm/v1/utils/event-accumulator.d.ts +0 -165
- package/esm/v1/utils/event-accumulator.d.ts.map +0 -1
- package/esm/v1/utils/event-accumulator.js +0 -1268
- package/esm/v1/utils/event-accumulator.js.map +0 -1
- package/esm/v1/utils/json-patch.d.ts +0 -18
- package/esm/v1/utils/json-patch.d.ts.map +0 -1
- package/esm/v1/utils/json-patch.js +0 -32
- package/esm/v1/utils/json-patch.js.map +0 -1
- package/esm/v1/utils/keyed-throttle.d.ts +0 -42
- package/esm/v1/utils/keyed-throttle.d.ts.map +0 -1
- package/esm/v1/utils/keyed-throttle.js +0 -83
- package/esm/v1/utils/keyed-throttle.js.map +0 -1
- package/esm/v1/utils/registry-conversion.d.ts +0 -53
- package/esm/v1/utils/registry-conversion.d.ts.map +0 -1
- package/esm/v1/utils/registry-conversion.js +0 -109
- package/esm/v1/utils/registry-conversion.js.map +0 -1
- package/esm/v1/utils/stream-handler.d.ts +0 -45
- package/esm/v1/utils/stream-handler.d.ts.map +0 -1
- package/esm/v1/utils/stream-handler.js +0 -44
- package/esm/v1/utils/stream-handler.js.map +0 -1
- package/esm/v1/utils/thread-utils.d.ts +0 -16
- package/esm/v1/utils/thread-utils.d.ts.map +0 -1
- package/esm/v1/utils/thread-utils.js +0 -31
- package/esm/v1/utils/thread-utils.js.map +0 -1
- package/esm/v1/utils/tool-call-tracker.d.ts +0 -73
- package/esm/v1/utils/tool-call-tracker.d.ts.map +0 -1
- package/esm/v1/utils/tool-call-tracker.js +0 -176
- package/esm/v1/utils/tool-call-tracker.js.map +0 -1
- package/esm/v1/utils/tool-executor.d.ts +0 -67
- package/esm/v1/utils/tool-executor.d.ts.map +0 -1
- package/esm/v1/utils/tool-executor.js +0 -154
- package/esm/v1/utils/tool-executor.js.map +0 -1
- package/esm/v1/utils/unstrictify.d.ts +0 -32
- package/esm/v1/utils/unstrictify.d.ts.map +0 -1
- package/esm/v1/utils/unstrictify.js +0 -155
- package/esm/v1/utils/unstrictify.js.map +0 -1
package/esm/mcp/mcp-client.js
DELETED
|
@@ -1,216 +0,0 @@
|
|
|
1
|
-
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
2
|
-
import { SSEClientTransport } from "@modelcontextprotocol/sdk/client/sse.js";
|
|
3
|
-
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
|
|
4
|
-
import { CreateMessageRequestSchema, ElicitRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
|
|
5
|
-
import { MCPTransport } from "../model/mcp-server-info.js";
|
|
6
|
-
// Re-export for backwards compatibility
|
|
7
|
-
export { MCPTransport };
|
|
8
|
-
/**
|
|
9
|
-
* A client for interacting with MCP (Model Context Protocol) servers.
|
|
10
|
-
* Provides a simple interface for listing and calling tools exposed by the server.
|
|
11
|
-
* @example
|
|
12
|
-
* ```typescript
|
|
13
|
-
* const mcp = await MCPClient.create('https://api.example.com/mcp');
|
|
14
|
-
* const tools = await mcp.listTools();
|
|
15
|
-
* const result = await mcp.callTool('toolName', { arg1: 'value1' });
|
|
16
|
-
* ```
|
|
17
|
-
*/
|
|
18
|
-
export class MCPClient {
|
|
19
|
-
/**
|
|
20
|
-
* The underlying MCP client
|
|
21
|
-
*
|
|
22
|
-
* Be careful not to mutate the client directly, use the methods provided instead.
|
|
23
|
-
*/
|
|
24
|
-
client;
|
|
25
|
-
transport;
|
|
26
|
-
transportType;
|
|
27
|
-
sessionId;
|
|
28
|
-
endpoint;
|
|
29
|
-
headers;
|
|
30
|
-
authProvider;
|
|
31
|
-
handlers;
|
|
32
|
-
/**
|
|
33
|
-
* Private constructor to enforce using the static create method.
|
|
34
|
-
* @param endpoint - The URL of the MCP server to connect to
|
|
35
|
-
* @param transportType - The transport to use for the MCP client
|
|
36
|
-
* @param headers - Optional custom headers to include in requests
|
|
37
|
-
*/
|
|
38
|
-
constructor(endpoint, transportType, headers, authProvider, sessionId, handlers = {}) {
|
|
39
|
-
this.endpoint = endpoint;
|
|
40
|
-
this.headers = headers ?? {};
|
|
41
|
-
this.authProvider = authProvider;
|
|
42
|
-
this.transportType = transportType;
|
|
43
|
-
this.handlers = handlers;
|
|
44
|
-
this.transport = this.initializeTransport(sessionId);
|
|
45
|
-
this.client = this.initializeClient();
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Creates and initializes a new MCPClient instance. This is the recommended
|
|
49
|
-
* way to create an MCPClient as it handles both instantiation and connection
|
|
50
|
-
* setup.
|
|
51
|
-
* @param endpoint - The URL of the MCP server to connect to
|
|
52
|
-
* @param transportType - The transport type to use for the MCP client. Defaults to HTTP.
|
|
53
|
-
* @param headers - Optional custom headers to include in requests
|
|
54
|
-
* @param authProvider - Optional auth provider to use for authentication
|
|
55
|
-
* @param sessionId - Optional session id to use for the MCP client - if not
|
|
56
|
-
* provided, a new session will be created
|
|
57
|
-
* @returns A connected MCPClient instance ready for use
|
|
58
|
-
* @throws {Error} Will throw an error if connection fails
|
|
59
|
-
*/
|
|
60
|
-
static async create(endpoint, transportType = MCPTransport.HTTP, headers, authProvider, sessionId, handlers = {}) {
|
|
61
|
-
const mcpClient = new MCPClient(endpoint, transportType, headers, authProvider, sessionId, handlers);
|
|
62
|
-
await mcpClient.client.connect(mcpClient.transport);
|
|
63
|
-
if ("sessionId" in mcpClient.transport) {
|
|
64
|
-
mcpClient.sessionId = mcpClient.transport.sessionId;
|
|
65
|
-
}
|
|
66
|
-
return mcpClient;
|
|
67
|
-
}
|
|
68
|
-
initializeTransport(sessionId) {
|
|
69
|
-
if (this.transportType === MCPTransport.SSE) {
|
|
70
|
-
return new SSEClientTransport(new URL(this.endpoint), {
|
|
71
|
-
authProvider: this.authProvider,
|
|
72
|
-
requestInit: { headers: this.headers },
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
else {
|
|
76
|
-
return new StreamableHTTPClientTransport(new URL(this.endpoint), {
|
|
77
|
-
authProvider: this.authProvider,
|
|
78
|
-
requestInit: { headers: this.headers },
|
|
79
|
-
sessionId,
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Initializes the MCP client with the appropriate capabilities and handlers
|
|
85
|
-
* @returns The initialized MCP client
|
|
86
|
-
*/
|
|
87
|
-
initializeClient() {
|
|
88
|
-
const elicitationCapability = this.handlers.elicitation
|
|
89
|
-
? { elicitation: {} }
|
|
90
|
-
: {};
|
|
91
|
-
const samplingCapability = this.handlers.sampling ? { sampling: {} } : {};
|
|
92
|
-
const client = new Client({
|
|
93
|
-
name: "tambo-mcp-client",
|
|
94
|
-
version: "1.0.0",
|
|
95
|
-
}, {
|
|
96
|
-
capabilities: {
|
|
97
|
-
...elicitationCapability,
|
|
98
|
-
...samplingCapability,
|
|
99
|
-
},
|
|
100
|
-
});
|
|
101
|
-
if (this.handlers.elicitation) {
|
|
102
|
-
client.setRequestHandler(ElicitRequestSchema, this.handlers.elicitation);
|
|
103
|
-
}
|
|
104
|
-
if (this.handlers.sampling) {
|
|
105
|
-
client.setRequestHandler(CreateMessageRequestSchema, this.handlers.sampling);
|
|
106
|
-
}
|
|
107
|
-
return client;
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* Retrieves a complete list of all available tools from the MCP server.
|
|
111
|
-
* Handles pagination automatically by following cursors until all tools are fetched.
|
|
112
|
-
* @returns A complete list of all available tools and their descriptions
|
|
113
|
-
* @throws {Error} Will throw an error if any server request fails during pagination
|
|
114
|
-
*/
|
|
115
|
-
async listTools() {
|
|
116
|
-
const allTools = [];
|
|
117
|
-
let hasMore = true;
|
|
118
|
-
let cursor = undefined;
|
|
119
|
-
while (hasMore) {
|
|
120
|
-
const response = await this.client.listTools({ cursor }, {});
|
|
121
|
-
allTools.push(...response.tools.map((tool) => {
|
|
122
|
-
// make sure the right type is used
|
|
123
|
-
const inputSchemaType = tool.inputSchema.type;
|
|
124
|
-
if (inputSchemaType !== "object") {
|
|
125
|
-
throw new Error(`Input schema for tool ${tool.name} is not an object`);
|
|
126
|
-
}
|
|
127
|
-
return {
|
|
128
|
-
name: tool.name,
|
|
129
|
-
description: tool.description,
|
|
130
|
-
inputSchema: tool.inputSchema,
|
|
131
|
-
};
|
|
132
|
-
}));
|
|
133
|
-
if (response.nextCursor) {
|
|
134
|
-
cursor = response.nextCursor;
|
|
135
|
-
}
|
|
136
|
-
else {
|
|
137
|
-
hasMore = false;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
return allTools;
|
|
141
|
-
}
|
|
142
|
-
getServerCapabilities() {
|
|
143
|
-
return this.client.getServerCapabilities();
|
|
144
|
-
}
|
|
145
|
-
getServerVersion() {
|
|
146
|
-
return this.client.getServerVersion();
|
|
147
|
-
}
|
|
148
|
-
getInstructions() {
|
|
149
|
-
return this.client.getInstructions();
|
|
150
|
-
}
|
|
151
|
-
/**
|
|
152
|
-
* Calls a specific tool on the MCP server with the provided arguments.
|
|
153
|
-
* @param name - The name of the tool to call
|
|
154
|
-
* @param args - Arguments to pass to the tool, must match the tool's expected schema
|
|
155
|
-
* @returns The result from the tool execution
|
|
156
|
-
* @throws {Error} Will throw an error if the tool call fails or if arguments are invalid
|
|
157
|
-
*/
|
|
158
|
-
async callTool(name, args, _meta) {
|
|
159
|
-
const result = await this.client.callTool({
|
|
160
|
-
name,
|
|
161
|
-
arguments: args,
|
|
162
|
-
_meta,
|
|
163
|
-
});
|
|
164
|
-
return result;
|
|
165
|
-
}
|
|
166
|
-
updateElicitationHandler(handler) {
|
|
167
|
-
// Skip if handler hasn't changed
|
|
168
|
-
if (handler === this.handlers.elicitation) {
|
|
169
|
-
return;
|
|
170
|
-
}
|
|
171
|
-
// Because we advertise the elicitation capability on initial connection, we can only update
|
|
172
|
-
// an existing handler, not add it if we haven't set it yet.
|
|
173
|
-
if (handler && !this.handlers.elicitation) {
|
|
174
|
-
throw new Error("Elicitation handler must be set on create");
|
|
175
|
-
}
|
|
176
|
-
this.handlers = {
|
|
177
|
-
...this.handlers,
|
|
178
|
-
elicitation: handler,
|
|
179
|
-
};
|
|
180
|
-
if (!handler) {
|
|
181
|
-
const method = ElicitRequestSchema.shape.method.value;
|
|
182
|
-
this.client.removeRequestHandler(method);
|
|
183
|
-
return;
|
|
184
|
-
}
|
|
185
|
-
this.client.setRequestHandler(ElicitRequestSchema, handler);
|
|
186
|
-
}
|
|
187
|
-
updateSamplingHandler(handler) {
|
|
188
|
-
// Skip if handler hasn't changed
|
|
189
|
-
if (handler === this.handlers.sampling) {
|
|
190
|
-
return;
|
|
191
|
-
}
|
|
192
|
-
// Because we advertise the sampling capability on initial connection, we can only update
|
|
193
|
-
// an existing handler, not add it if we haven't set it yet.
|
|
194
|
-
if (handler && !this.handlers.sampling) {
|
|
195
|
-
throw new Error("Sampling handler must be set on create");
|
|
196
|
-
}
|
|
197
|
-
this.handlers = {
|
|
198
|
-
...this.handlers,
|
|
199
|
-
sampling: handler,
|
|
200
|
-
};
|
|
201
|
-
if (!handler) {
|
|
202
|
-
const method = CreateMessageRequestSchema.shape.method.value;
|
|
203
|
-
this.client.removeRequestHandler(method);
|
|
204
|
-
return;
|
|
205
|
-
}
|
|
206
|
-
this.client.setRequestHandler(CreateMessageRequestSchema, handler);
|
|
207
|
-
}
|
|
208
|
-
async close() {
|
|
209
|
-
// Not really sure which one of these to close first, but we'll close the
|
|
210
|
-
// transport first so that no requests can come in and hit closing/closed
|
|
211
|
-
// clients
|
|
212
|
-
await this.transport.close();
|
|
213
|
-
await this.client.close();
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
//# sourceMappingURL=mcp-client.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mcp-client.js","sourceRoot":"","sources":["../../src/mcp/mcp-client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAC;AAC7E,OAAO,EAAE,6BAA6B,EAAE,MAAM,oDAAoD,CAAC;AAEnG,OAAO,EAIL,0BAA0B,EAG1B,mBAAmB,GAEpB,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAExD,wCAAwC;AACxC,OAAO,EAAE,YAAY,EAAE,CAAC;AAgExB;;;;;;;;;GASG;AACH,MAAM,OAAO,SAAS;IACpB;;;;OAIG;IACH,MAAM,CAAS;IACP,SAAS,CAAqD;IAC9D,aAAa,CAAe;IAC7B,SAAS,CAAU;IAClB,QAAQ,CAAS;IACjB,OAAO,CAAyB;IAChC,YAAY,CAAuB;IACnC,QAAQ,CAAuB;IAEvC;;;;;OAKG;IACH,YACE,QAAgB,EAChB,aAA2B,EAC3B,OAAgC,EAChC,YAAkC,EAClC,SAAkB,EAClB,WAAiC,EAAE;QAEnC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,OAAO,GAAG,OAAO,IAAI,EAAE,CAAC;QAC7B,IAAI,CAAC,YAAY,GAAG,YA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,iBAAiB,CAAC,0BAA0B,EAAE,OAAO,CAAC,CAAC;IACrE,CAAC;IAED,KAAK,CAAC,KAAK;QACT,yEAAyE;QACzE,yEAAyE;QACzE,UAAU;QACV,MAAM,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;QAC7B,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;IAC5B,CAAC;CACF","sourcesContent":["import { type OAuthClientProvider } from \"@modelcontextprotocol/sdk/client/auth.js\";\nimport { Client } from \"@modelcontextprotocol/sdk/client/index.js\";\nimport { SSEClientTransport } from \"@modelcontextprotocol/sdk/client/sse.js\";\nimport { StreamableHTTPClientTransport } from \"@modelcontextprotocol/sdk/client/streamableHttp.js\";\nimport type { RequestHandlerExtra } from \"@modelcontextprotocol/sdk/shared/protocol.js\";\nimport {\n ClientNotification,\n ClientRequest,\n CreateMessageRequest,\n CreateMessageRequestSchema,\n CreateMessageResult,\n ElicitRequest,\n ElicitRequestSchema,\n ElicitResult,\n} from \"@modelcontextprotocol/sdk/types.js\";\nimport { JSONSchema7 } from \"json-schema\";\nimport { MCPTransport } from \"../model/mcp-server-info\";\n\n// Re-export for backwards compatibility\nexport { MCPTransport };\n\n/**\n * Handler for MCP elicitation requests.\n * Receives the elicit request and a RequestHandlerExtra containing an AbortSignal that fires when the request is cancelled.\n * @param request - The elicitation request from the server\n * @param extra - Additional context including AbortSignal for cancellation\n * @returns Promise resolving to the elicitation result\n * @example\n * ```typescript\n * const handler: MCPElicitationHandler = async (request, extra) => {\n * // Listen for cancellation\n * extra.signal.addEventListener('abort', () => {\n * console.log('Request cancelled');\n * });\n *\n * // Return user's response\n * return {\n * action: 'accept',\n * content: { name: 'John' }\n * };\n * };\n * ```\n */\nexport type MCPElicitationHandler = (\n e: ElicitRequest,\n extra: RequestHandlerExtra<ClientRequest, ClientNotification>,\n) => Promise<ElicitResult>;\n\n/**\n * Handler for MCP sampling requests (create_message).\n * Receives the sampling request and a RequestHandlerExtra containing an AbortSignal that fires when the request is cancelled.\n * @param request - The sampling/create_message request from the server\n * @param extra - Additional context including AbortSignal for cancellation\n * @returns Promise resolving to the sampling result\n */\nexport type MCPSamplingHandler = (\n e: CreateMessageRequest,\n extra: RequestHandlerExtra<ClientRequest, ClientNotification>,\n) => Promise<CreateMessageResult>;\n\n/**\n * Handlers for MCP requests - these are only used if the server supports the corresponding capabilities\n * @param elicitation - Handler for elicitation requests (receives request and RequestHandlerExtra with AbortSignal)\n * @param sampling - Handler for sampling requests (receives request and RequestHandlerExtra with AbortSignal)\n * @example\n * ```typescript\n * const mcp = await MCPClient.create(\n * 'https://api.example.com/mcp',\n * MCPTransport.HTTP,\n * {},\n * undefined,\n * undefined,\n * {\n * elicitation: (e, extra) => Promise.resolve({...}),\n * },\n * );\n * ```\n */\nexport interface MCPHandlers {\n elicitation: MCPElicitationHandler;\n sampling: MCPSamplingHandler;\n}\n\n/**\n * A client for interacting with MCP (Model Context Protocol) servers.\n * Provides a simple interface for listing and calling tools exposed by the server.\n * @example\n * ```typescript\n * const mcp = await MCPClient.create('https://api.example.com/mcp');\n * const tools = await mcp.listTools();\n * const result = await mcp.callTool('toolName', { arg1: 'value1' });\n * ```\n */\nexport class MCPClient {\n /**\n * The underlying MCP client\n *\n * Be careful not to mutate the client directly, use the methods provided instead.\n */\n client: Client;\n private transport: SSEClientTransport | StreamableHTTPClientTransport;\n private transportType: MCPTransport;\n public sessionId?: string;\n private endpoint: string;\n private headers: Record<string, string>;\n private authProvider?: OAuthClientProvider;\n private handlers: Partial<MCPHandlers>;\n\n /**\n * Private constructor to enforce using the static create method.\n * @param endpoint - The URL of the MCP server to connect to\n * @param transportType - The transport to use for the MCP client\n * @param headers - Optional custom headers to include in requests\n */\n private constructor(\n endpoint: string,\n transportType: MCPTransport,\n headers?: Record<string, string>,\n authProvider?: OAuthClientProvider,\n sessionId?: string,\n handlers: Partial<MCPHandlers> = {},\n ) {\n this.endpoint = endpoint;\n this.headers = headers ?? {};\n this.authProvider = authProvider;\n this.transportType = transportType;\n this.handlers = handlers;\n this.transport = this.initializeTransport(sessionId);\n this.client = this.initializeClient();\n }\n\n /**\n * Creates and initializes a new MCPClient instance. This is the recommended\n * way to create an MCPClient as it handles both instantiation and connection\n * setup.\n * @param endpoint - The URL of the MCP server to connect to\n * @param transportType - The transport type to use for the MCP client. Defaults to HTTP.\n * @param headers - Optional custom headers to include in requests\n * @param authProvider - Optional auth provider to use for authentication\n * @param sessionId - Optional session id to use for the MCP client - if not\n * provided, a new session will be created\n * @returns A connected MCPClient instance ready for use\n * @throws {Error} Will throw an error if connection fails\n */\n static async create(\n endpoint: string,\n transportType: MCPTransport = MCPTransport.HTTP,\n headers: Record<string, string> | undefined,\n authProvider: OAuthClientProvider | undefined,\n sessionId: string | undefined,\n handlers: Partial<MCPHandlers> = {},\n ): Promise<MCPClient> {\n const mcpClient = new MCPClient(\n endpoint,\n transportType,\n headers,\n authProvider,\n sessionId,\n handlers,\n );\n await mcpClient.client.connect(mcpClient.transport);\n if (\"sessionId\" in mcpClient.transport) {\n mcpClient.sessionId = mcpClient.transport.sessionId;\n }\n return mcpClient;\n }\n\n private initializeTransport(sessionId: string | undefined) {\n if (this.transportType === MCPTransport.SSE) {\n return new SSEClientTransport(new URL(this.endpoint), {\n authProvider: this.authProvider,\n requestInit: { headers: this.headers },\n });\n } else {\n return new StreamableHTTPClientTransport(new URL(this.endpoint), {\n authProvider: this.authProvider,\n requestInit: { headers: this.headers },\n sessionId,\n });\n }\n }\n\n /**\n * Initializes the MCP client with the appropriate capabilities and handlers\n * @returns The initialized MCP client\n */\n private initializeClient() {\n const elicitationCapability = this.handlers.elicitation\n ? { elicitation: {} }\n : {};\n const samplingCapability = this.handlers.sampling ? { sampling: {} } : {};\n const client = new Client(\n {\n name: \"tambo-mcp-client\",\n version: \"1.0.0\",\n },\n {\n capabilities: {\n ...elicitationCapability,\n ...samplingCapability,\n },\n },\n );\n\n if (this.handlers.elicitation) {\n client.setRequestHandler(ElicitRequestSchema, this.handlers.elicitation);\n }\n if (this.handlers.sampling) {\n client.setRequestHandler(\n CreateMessageRequestSchema,\n this.handlers.sampling,\n );\n }\n return client;\n }\n\n /**\n * Retrieves a complete list of all available tools from the MCP server.\n * Handles pagination automatically by following cursors until all tools are fetched.\n * @returns A complete list of all available tools and their descriptions\n * @throws {Error} Will throw an error if any server request fails during pagination\n */\n async listTools(): Promise<MCPToolSpec[]> {\n const allTools: MCPToolSpec[] = [];\n let hasMore = true;\n let cursor: string | undefined = undefined;\n\n while (hasMore) {\n const response = await this.client.listTools({ cursor }, {});\n allTools.push(\n ...response.tools.map((tool): MCPToolSpec => {\n // make sure the right type is used\n const inputSchemaType: string = tool.inputSchema.type;\n if (inputSchemaType !== \"object\") {\n throw new Error(\n `Input schema for tool ${tool.name} is not an object`,\n );\n }\n\n return {\n name: tool.name,\n description: tool.description,\n inputSchema: tool.inputSchema as JSONSchema7,\n };\n }),\n );\n\n if (response.nextCursor) {\n cursor = response.nextCursor;\n } else {\n hasMore = false;\n }\n }\n\n return allTools;\n }\n\n getServerCapabilities() {\n return this.client.getServerCapabilities();\n }\n\n getServerVersion() {\n return this.client.getServerVersion();\n }\n\n getInstructions() {\n return this.client.getInstructions();\n }\n\n /**\n * Calls a specific tool on the MCP server with the provided arguments.\n * @param name - The name of the tool to call\n * @param args - Arguments to pass to the tool, must match the tool's expected schema\n * @returns The result from the tool execution\n * @throws {Error} Will throw an error if the tool call fails or if arguments are invalid\n */\n async callTool(\n name: string,\n args: Record<string, unknown>,\n _meta?: Record<string, unknown>,\n ): Promise<MCPToolCallResult> {\n const result = await this.client.callTool({\n name,\n arguments: args,\n _meta,\n });\n return result;\n }\n\n updateElicitationHandler(handler: MCPElicitationHandler | undefined) {\n // Skip if handler hasn't changed\n if (handler === this.handlers.elicitation) {\n return;\n }\n\n // Because we advertise the elicitation capability on initial connection, we can only update\n // an existing handler, not add it if we haven't set it yet.\n if (handler && !this.handlers.elicitation) {\n throw new Error(\"Elicitation handler must be set on create\");\n }\n this.handlers = {\n ...this.handlers,\n elicitation: handler,\n };\n if (!handler) {\n const method = ElicitRequestSchema.shape.method.value;\n this.client.removeRequestHandler(method);\n return;\n }\n this.client.setRequestHandler(ElicitRequestSchema, handler);\n }\n\n updateSamplingHandler(handler: MCPSamplingHandler | undefined) {\n // Skip if handler hasn't changed\n if (handler === this.handlers.sampling) {\n return;\n }\n\n // Because we advertise the sampling capability on initial connection, we can only update\n // an existing handler, not add it if we haven't set it yet.\n if (handler && !this.handlers.sampling) {\n throw new Error(\"Sampling handler must be set on create\");\n }\n this.handlers = {\n ...this.handlers,\n sampling: handler,\n };\n if (!handler) {\n const method = CreateMessageRequestSchema.shape.method.value;\n this.client.removeRequestHandler(method);\n return;\n }\n this.client.setRequestHandler(CreateMessageRequestSchema, handler);\n }\n\n async close() {\n // Not really sure which one of these to close first, but we'll close the\n // transport first so that no requests can come in and hit closing/closed\n // clients\n await this.transport.close();\n await this.client.close();\n }\n}\n\n/**\n * The result of a tool call.\n * This is the same as the result of a tool call in the OpenAI SDK, but is reified here\n */\nexport type MCPToolCallResult = Awaited<\n ReturnType<typeof Client.prototype.callTool>\n>;\n\n// Example usage:\n/*\nconst mcp = await MCPClient.create('https://api.example.com/mcp', MCPTransport.HTTP);\nconst tools = await mcp.listTools();\nconst result = await mcp.callTool('toolName', { arg1: 'value1' });\n*/\n\nexport interface MCPToolSpec {\n name: string;\n description?: string;\n inputSchema?: JSONSchema7;\n maxCalls?: number;\n}\n"]}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Server type enum for distinguishing different kinds of MCP servers.
|
|
3
|
-
* Used to determine how resources should be resolved.
|
|
4
|
-
*/
|
|
5
|
-
export declare const ServerType: {
|
|
6
|
-
/** Client-side MCP server passed via mcpServers prop */
|
|
7
|
-
readonly BROWSER_SIDE: "browser-side";
|
|
8
|
-
/** Internal Tambo MCP server at /mcp endpoint (server-side MCP) */
|
|
9
|
-
readonly TAMBO_INTERNAL: "tambo-internal";
|
|
10
|
-
/** Virtual server representing browser-only registry resources */
|
|
11
|
-
readonly TAMBO_REGISTRY: "tambo-registry";
|
|
12
|
-
};
|
|
13
|
-
export type ServerType = (typeof ServerType)[keyof typeof ServerType];
|
|
14
|
-
/**
|
|
15
|
-
* Synthetic server key for local registry resources.
|
|
16
|
-
* Used to give registry resources the same `@serverKey:uri` format as MCP resources.
|
|
17
|
-
*/
|
|
18
|
-
export declare const REGISTRY_SERVER_KEY = "registry";
|
|
19
|
-
//# sourceMappingURL=mcp-constants.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mcp-constants.d.ts","sourceRoot":"","sources":["../../src/mcp/mcp-constants.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,UAAU;IACrB,wDAAwD;;IAExD,mEAAmE;;IAEnE,kEAAkE;;CAE1D,CAAC;AAEX,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,UAAU,CAAC,CAAC,MAAM,OAAO,UAAU,CAAC,CAAC;AAEtE;;;GAGG;AACH,eAAO,MAAM,mBAAmB,aAAa,CAAC"}
|
package/esm/mcp/mcp-constants.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Server type enum for distinguishing different kinds of MCP servers.
|
|
3
|
-
* Used to determine how resources should be resolved.
|
|
4
|
-
*/
|
|
5
|
-
export const ServerType = {
|
|
6
|
-
/** Client-side MCP server passed via mcpServers prop */
|
|
7
|
-
BROWSER_SIDE: "browser-side",
|
|
8
|
-
/** Internal Tambo MCP server at /mcp endpoint (server-side MCP) */
|
|
9
|
-
TAMBO_INTERNAL: "tambo-internal",
|
|
10
|
-
/** Virtual server representing browser-only registry resources */
|
|
11
|
-
TAMBO_REGISTRY: "tambo-registry",
|
|
12
|
-
};
|
|
13
|
-
/**
|
|
14
|
-
* Synthetic server key for local registry resources.
|
|
15
|
-
* Used to give registry resources the same `@serverKey:uri` format as MCP resources.
|
|
16
|
-
*/
|
|
17
|
-
export const REGISTRY_SERVER_KEY = "registry";
|
|
18
|
-
//# sourceMappingURL=mcp-constants.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mcp-constants.js","sourceRoot":"","sources":["../../src/mcp/mcp-constants.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,wDAAwD;IACxD,YAAY,EAAE,cAAc;IAC5B,mEAAmE;IACnE,cAAc,EAAE,gBAAgB;IAChC,kEAAkE;IAClE,cAAc,EAAE,gBAAgB;CACxB,CAAC;AAIX;;;GAGG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,UAAU,CAAC","sourcesContent":["/**\n * Server type enum for distinguishing different kinds of MCP servers.\n * Used to determine how resources should be resolved.\n */\nexport const ServerType = {\n /** Client-side MCP server passed via mcpServers prop */\n BROWSER_SIDE: \"browser-side\",\n /** Internal Tambo MCP server at /mcp endpoint (server-side MCP) */\n TAMBO_INTERNAL: \"tambo-internal\",\n /** Virtual server representing browser-only registry resources */\n TAMBO_REGISTRY: \"tambo-registry\",\n} as const;\n\nexport type ServerType = (typeof ServerType)[keyof typeof ServerType];\n\n/**\n * Synthetic server key for local registry resources.\n * Used to give registry resources the same `@serverKey:uri` format as MCP resources.\n */\nexport const REGISTRY_SERVER_KEY = \"registry\";\n"]}
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The transport protocol to use for MCP connections.
|
|
3
|
-
*/
|
|
4
|
-
export declare enum MCPTransport {
|
|
5
|
-
SSE = "sse",
|
|
6
|
-
HTTP = "http"
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* User-provided configuration for an MCP server.
|
|
10
|
-
*
|
|
11
|
-
* This is the type accepted by `TamboProvider` / `TamboRegistryProvider` in
|
|
12
|
-
* the `mcpServers` prop.
|
|
13
|
-
*
|
|
14
|
-
* The `handlers` field is intentionally typed as `unknown` here so the core
|
|
15
|
-
* SDK does not depend on the MCP subpackage. In the `@tambo-ai/react/mcp`
|
|
16
|
-
* subpackage this is treated as `Partial<MCPHandlers>` (with
|
|
17
|
-
* `elicitation` / `sampling` callbacks). The `@modelcontextprotocol/sdk` is
|
|
18
|
-
* included automatically with `@tambo-ai/react`. See the React SDK README for
|
|
19
|
-
* any additional optional peer dependencies needed for MCP features.
|
|
20
|
-
*/
|
|
21
|
-
export interface McpServerInfo {
|
|
22
|
-
/** Optional name for the MCP server */
|
|
23
|
-
name?: string;
|
|
24
|
-
/** The URL of the MCP server to connect to */
|
|
25
|
-
url: string;
|
|
26
|
-
/** Optional description of the MCP server */
|
|
27
|
-
description?: string;
|
|
28
|
-
/** The transport type to use (SSE or HTTP). Defaults to HTTP for string URLs */
|
|
29
|
-
transport?: MCPTransport;
|
|
30
|
-
/** Optional custom headers to include in requests */
|
|
31
|
-
customHeaders?: Record<string, string>;
|
|
32
|
-
/**
|
|
33
|
-
* Optional short name for namespacing MCP resources, prompts, and tools.
|
|
34
|
-
* When multiple MCP servers are configured, this key is used to prefix:
|
|
35
|
-
* - prompts: `<serverKey>:<promptName>`
|
|
36
|
-
* - resources: `<serverKey>:<resourceUrl>`
|
|
37
|
-
* - tools: `<serverKey>__<toolName>`
|
|
38
|
-
*
|
|
39
|
-
* If not provided, a key will be derived from the URL hostname.
|
|
40
|
-
* For example, "https://mcp.linear.app/mcp" becomes "linear".
|
|
41
|
-
*/
|
|
42
|
-
serverKey?: string;
|
|
43
|
-
/**
|
|
44
|
-
* Optional handlers for elicitation and sampling requests from the server.
|
|
45
|
-
*
|
|
46
|
-
* In the MCP subpackage this is interpreted as `Partial<MCPHandlers>`,
|
|
47
|
-
* i.e. `{ elicitation?: MCPElicitationHandler; sampling?: MCPSamplingHandler }`.
|
|
48
|
-
*
|
|
49
|
-
* Note: These callbacks should be stable (e.g., wrapped in useCallback or
|
|
50
|
-
* defined outside the component) to avoid constant re-registration of the
|
|
51
|
-
* MCP server on every render.
|
|
52
|
-
*/
|
|
53
|
-
handlers?: unknown;
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Normalized MCP server metadata used internally by the registry and MCP
|
|
57
|
-
* provider.
|
|
58
|
-
*
|
|
59
|
-
* This is equivalent to `McpServerInfo` except that:
|
|
60
|
-
* - `serverKey` is guaranteed to be present
|
|
61
|
-
* - `transport` is resolved to a concrete value (defaults to HTTP)
|
|
62
|
-
*/
|
|
63
|
-
export interface NormalizedMcpServerInfo extends McpServerInfo {
|
|
64
|
-
transport: MCPTransport;
|
|
65
|
-
serverKey: string;
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Creates a stable identifier for an MCP server based on its connection properties.
|
|
69
|
-
* Two servers with the same URL, transport, and headers will have the same key.
|
|
70
|
-
*
|
|
71
|
-
* This is used by both the registry and MCP provider to deduplicate servers,
|
|
72
|
-
* so it lives alongside the shared server metadata type.
|
|
73
|
-
* @returns A stable string key identifying the server
|
|
74
|
-
*/
|
|
75
|
-
export declare function getMcpServerUniqueKey(serverInfo: Pick<McpServerInfo, "url" | "transport" | "customHeaders">): string;
|
|
76
|
-
//# sourceMappingURL=mcp-server-info.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mcp-server-info.d.ts","sourceRoot":"","sources":["../../src/model/mcp-server-info.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,oBAAY,YAAY;IACtB,GAAG,QAAQ;IACX,IAAI,SAAS;CACd;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,aAAa;IAC5B,uCAAuC;IACvC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,8CAA8C;IAC9C,GAAG,EAAE,MAAM,CAAC;IACZ,6CAA6C;IAC7C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gFAAgF;IAChF,SAAS,CAAC,EAAE,YAAY,CAAC;IACzB,qDAAqD;IACrD,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACvC;;;;;;;;;OASG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;;;;;;OASG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,uBAAwB,SAAQ,aAAa;IAC5D,SAAS,EAAE,YAAY,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CACnC,UAAU,EAAE,IAAI,CAAC,aAAa,EAAE,KAAK,GAAG,WAAW,GAAG,eAAe,CAAC,GACrE,MAAM,CAUR"}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The transport protocol to use for MCP connections.
|
|
3
|
-
*/
|
|
4
|
-
export var MCPTransport;
|
|
5
|
-
(function (MCPTransport) {
|
|
6
|
-
MCPTransport["SSE"] = "sse";
|
|
7
|
-
MCPTransport["HTTP"] = "http";
|
|
8
|
-
})(MCPTransport || (MCPTransport = {}));
|
|
9
|
-
/**
|
|
10
|
-
* Creates a stable identifier for an MCP server based on its connection properties.
|
|
11
|
-
* Two servers with the same URL, transport, and headers will have the same key.
|
|
12
|
-
*
|
|
13
|
-
* This is used by both the registry and MCP provider to deduplicate servers,
|
|
14
|
-
* so it lives alongside the shared server metadata type.
|
|
15
|
-
* @returns A stable string key identifying the server
|
|
16
|
-
*/
|
|
17
|
-
export function getMcpServerUniqueKey(serverInfo) {
|
|
18
|
-
const headerStr = serverInfo.customHeaders
|
|
19
|
-
? JSON.stringify(Object.entries(serverInfo.customHeaders)
|
|
20
|
-
.map(([k, v]) => [k.toLowerCase(), v])
|
|
21
|
-
.sort(([a], [b]) => a.localeCompare(b)))
|
|
22
|
-
: "";
|
|
23
|
-
return `${serverInfo.url}|${serverInfo.transport ?? MCPTransport.HTTP}|${headerStr}`;
|
|
24
|
-
}
|
|
25
|
-
//# sourceMappingURL=mcp-server-info.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mcp-server-info.js","sourceRoot":"","sources":["../../src/model/mcp-server-info.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAN,IAAY,YAGX;AAHD,WAAY,YAAY;IACtB,2BAAW,CAAA;IACX,6BAAa,CAAA;AACf,CAAC,EAHW,YAAY,KAAZ,YAAY,QAGvB;AA+DD;;;;;;;GAOG;AACH,MAAM,UAAU,qBAAqB,CACnC,UAAsE;IAEtE,MAAM,SAAS,GAAG,UAAU,CAAC,aAAa;QACxC,CAAC,CAAC,IAAI,CAAC,SAAS,CACZ,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,aAAa,CAAC;aACrC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,CAAU,CAAC;aAC9C,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAC1C;QACH,CAAC,CAAC,EAAE,CAAC;IAEP,OAAO,GAAG,UAAU,CAAC,GAAG,IAAI,UAAU,CAAC,SAAS,IAAI,YAAY,CAAC,IAAI,IAAI,SAAS,EAAE,CAAC;AACvF,CAAC","sourcesContent":["/**\n * The transport protocol to use for MCP connections.\n */\nexport enum MCPTransport {\n SSE = \"sse\",\n HTTP = \"http\",\n}\n\n/**\n * User-provided configuration for an MCP server.\n *\n * This is the type accepted by `TamboProvider` / `TamboRegistryProvider` in\n * the `mcpServers` prop.\n *\n * The `handlers` field is intentionally typed as `unknown` here so the core\n * SDK does not depend on the MCP subpackage. In the `@tambo-ai/react/mcp`\n * subpackage this is treated as `Partial<MCPHandlers>` (with\n * `elicitation` / `sampling` callbacks). The `@modelcontextprotocol/sdk` is\n * included automatically with `@tambo-ai/react`. See the React SDK README for\n * any additional optional peer dependencies needed for MCP features.\n */\nexport interface McpServerInfo {\n /** Optional name for the MCP server */\n name?: string;\n /** The URL of the MCP server to connect to */\n url: string;\n /** Optional description of the MCP server */\n description?: string;\n /** The transport type to use (SSE or HTTP). Defaults to HTTP for string URLs */\n transport?: MCPTransport;\n /** Optional custom headers to include in requests */\n customHeaders?: Record<string, string>;\n /**\n * Optional short name for namespacing MCP resources, prompts, and tools.\n * When multiple MCP servers are configured, this key is used to prefix:\n * - prompts: `<serverKey>:<promptName>`\n * - resources: `<serverKey>:<resourceUrl>`\n * - tools: `<serverKey>__<toolName>`\n *\n * If not provided, a key will be derived from the URL hostname.\n * For example, \"https://mcp.linear.app/mcp\" becomes \"linear\".\n */\n serverKey?: string;\n /**\n * Optional handlers for elicitation and sampling requests from the server.\n *\n * In the MCP subpackage this is interpreted as `Partial<MCPHandlers>`,\n * i.e. `{ elicitation?: MCPElicitationHandler; sampling?: MCPSamplingHandler }`.\n *\n * Note: These callbacks should be stable (e.g., wrapped in useCallback or\n * defined outside the component) to avoid constant re-registration of the\n * MCP server on every render.\n */\n handlers?: unknown;\n}\n\n/**\n * Normalized MCP server metadata used internally by the registry and MCP\n * provider.\n *\n * This is equivalent to `McpServerInfo` except that:\n * - `serverKey` is guaranteed to be present\n * - `transport` is resolved to a concrete value (defaults to HTTP)\n */\nexport interface NormalizedMcpServerInfo extends McpServerInfo {\n transport: MCPTransport;\n serverKey: string;\n}\n\n/**\n * Creates a stable identifier for an MCP server based on its connection properties.\n * Two servers with the same URL, transport, and headers will have the same key.\n *\n * This is used by both the registry and MCP provider to deduplicate servers,\n * so it lives alongside the shared server metadata type.\n * @returns A stable string key identifying the server\n */\nexport function getMcpServerUniqueKey(\n serverInfo: Pick<McpServerInfo, \"url\" | \"transport\" | \"customHeaders\">,\n): string {\n const headerStr = serverInfo.customHeaders\n ? JSON.stringify(\n Object.entries(serverInfo.customHeaders)\n .map(([k, v]) => [k.toLowerCase(), v] as const)\n .sort(([a], [b]) => a.localeCompare(b)),\n )\n : \"\";\n\n return `${serverInfo.url}|${serverInfo.transport ?? MCPTransport.HTTP}|${headerStr}`;\n}\n"]}
|
package/esm/schema/schema.d.ts
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Schema utilities for working with Standard Schema and JSON Schema.
|
|
3
|
-
*
|
|
4
|
-
* This module provides a unified interface for handling different schema types
|
|
5
|
-
* used in Tambo components and tools. It uses Standard Schema (https://standardschema.dev/)
|
|
6
|
-
* as the primary interface, which is implemented by Zod 3.24+ and other validation libraries.
|
|
7
|
-
*
|
|
8
|
-
* JSON Schema conversion is handled by `@standard-community/standard-json`.
|
|
9
|
-
* @module schema
|
|
10
|
-
*/
|
|
11
|
-
import type { JSONSchema7 } from "json-schema";
|
|
12
|
-
import { ParameterSpec, SupportedSchema, TamboTool } from "../model/component-metadata.js";
|
|
13
|
-
/**
|
|
14
|
-
* Converts a schema (Standard Schema or JSON Schema) to a JSON Schema object.
|
|
15
|
-
*
|
|
16
|
-
* If the schema is already a JSON Schema, it is returned as-is.
|
|
17
|
-
* For Standard Schema validators (Zod 3.24+, etc.), uses
|
|
18
|
-
* `@standard-community/standard-json` for conversion.
|
|
19
|
-
* @param schema - The schema to convert
|
|
20
|
-
* @returns The JSON Schema representation
|
|
21
|
-
* @example
|
|
22
|
-
* ```typescript
|
|
23
|
-
* import { z } from "zod/v4";
|
|
24
|
-
*
|
|
25
|
-
* // Convert a Zod schema
|
|
26
|
-
* const zodSchema = z.object({ name: z.string() });
|
|
27
|
-
* const jsonSchema = schemaToJsonSchema(zodSchema);
|
|
28
|
-
*
|
|
29
|
-
* // Pass through a JSON Schema
|
|
30
|
-
* const existingJsonSchema = { type: "object", properties: { name: { type: "string" } } };
|
|
31
|
-
* schemaToJsonSchema(existingJsonSchema); // returns the same object
|
|
32
|
-
* ```
|
|
33
|
-
*/
|
|
34
|
-
export declare function schemaToJsonSchema(schema: SupportedSchema): JSONSchema7;
|
|
35
|
-
/**
|
|
36
|
-
* Safely converts a schema to JSON Schema, returning undefined for invalid inputs.
|
|
37
|
-
* @param schema - The schema to convert (may be undefined)
|
|
38
|
-
* @param onError - Optional callback invoked on conversion error
|
|
39
|
-
* @returns The JSON Schema representation, or undefined if conversion fails
|
|
40
|
-
*/
|
|
41
|
-
export declare function safeSchemaToJsonSchema(schema: SupportedSchema | undefined | null, onError?: (error: unknown) => void): JSONSchema7 | undefined;
|
|
42
|
-
/**
|
|
43
|
-
* Extracts parameter specifications from a tool's inputSchema.
|
|
44
|
-
* @param tool - The tool containing the schema
|
|
45
|
-
* @returns An array of parameter specifications
|
|
46
|
-
*/
|
|
47
|
-
export declare function getParametersFromToolSchema(tool: TamboTool): ParameterSpec[];
|
|
48
|
-
export type { SupportedSchema };
|
|
49
|
-
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/schema/schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG/C,OAAO,EACL,aAAa,EACb,eAAe,EACf,SAAS,EACV,MAAM,6BAA6B,CAAC;AAuBrC;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,eAAe,GAAG,WAAW,CAOvE;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,eAAe,GAAG,SAAS,GAAG,IAAI,EAC1C,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,GACjC,WAAW,GAAG,SAAS,CAYzB;AAoCD;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,IAAI,EAAE,SAAS,GAAG,aAAa,EAAE,CAe5E;AAED,YAAY,EAAE,eAAe,EAAE,CAAC"}
|
package/esm/schema/schema.js
DELETED
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Schema utilities for working with Standard Schema and JSON Schema.
|
|
3
|
-
*
|
|
4
|
-
* This module provides a unified interface for handling different schema types
|
|
5
|
-
* used in Tambo components and tools. It uses Standard Schema (https://standardschema.dev/)
|
|
6
|
-
* as the primary interface, which is implemented by Zod 3.24+ and other validation libraries.
|
|
7
|
-
*
|
|
8
|
-
* JSON Schema conversion is handled by `@standard-community/standard-json`.
|
|
9
|
-
* @module schema
|
|
10
|
-
*/
|
|
11
|
-
import { loadVendor, toJsonSchema } from "@standard-community/standard-json";
|
|
12
|
-
import { zodToJsonSchema } from "zod-to-json-schema";
|
|
13
|
-
import { toJSONSchema as zod4ToJSONSchema } from "zod/v4/core";
|
|
14
|
-
import { looksLikeJSONSchema } from "./json-schema.js";
|
|
15
|
-
import { isStandardSchema } from "./standard-schema.js";
|
|
16
|
-
/**
|
|
17
|
-
* Register the zod vendor handler for synchronous JSON Schema conversion.
|
|
18
|
-
* This uses Zod 4's native toJSONSchema for Zod 4.x schemas and zod-to-json-schema for Zod 3.x.
|
|
19
|
-
*/
|
|
20
|
-
loadVendor("zod", (schema) => {
|
|
21
|
-
// Check if this is a Zod 4 schema (has _zod property)
|
|
22
|
-
if (schema && typeof schema === "object" && "_zod" in schema) {
|
|
23
|
-
// Use Zod 4's native toJSONSchema from zod/v4/core
|
|
24
|
-
// Cast through unknown since the Zod 4 internal types don't match our detection pattern
|
|
25
|
-
return zod4ToJSONSchema(schema);
|
|
26
|
-
}
|
|
27
|
-
// Fall back to zod-to-json-schema for Zod 3.x
|
|
28
|
-
return zodToJsonSchema(schema);
|
|
29
|
-
});
|
|
30
|
-
/**
|
|
31
|
-
* Converts a schema (Standard Schema or JSON Schema) to a JSON Schema object.
|
|
32
|
-
*
|
|
33
|
-
* If the schema is already a JSON Schema, it is returned as-is.
|
|
34
|
-
* For Standard Schema validators (Zod 3.24+, etc.), uses
|
|
35
|
-
* `@standard-community/standard-json` for conversion.
|
|
36
|
-
* @param schema - The schema to convert
|
|
37
|
-
* @returns The JSON Schema representation
|
|
38
|
-
* @example
|
|
39
|
-
* ```typescript
|
|
40
|
-
* import { z } from "zod/v4";
|
|
41
|
-
*
|
|
42
|
-
* // Convert a Zod schema
|
|
43
|
-
* const zodSchema = z.object({ name: z.string() });
|
|
44
|
-
* const jsonSchema = schemaToJsonSchema(zodSchema);
|
|
45
|
-
*
|
|
46
|
-
* // Pass through a JSON Schema
|
|
47
|
-
* const existingJsonSchema = { type: "object", properties: { name: { type: "string" } } };
|
|
48
|
-
* schemaToJsonSchema(existingJsonSchema); // returns the same object
|
|
49
|
-
* ```
|
|
50
|
-
*/
|
|
51
|
-
export function schemaToJsonSchema(schema) {
|
|
52
|
-
// Already a JSON Schema - return as-is
|
|
53
|
-
if (!isStandardSchema(schema)) {
|
|
54
|
-
return schema;
|
|
55
|
-
}
|
|
56
|
-
return toJsonSchema.sync(schema);
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Safely converts a schema to JSON Schema, returning undefined for invalid inputs.
|
|
60
|
-
* @param schema - The schema to convert (may be undefined)
|
|
61
|
-
* @param onError - Optional callback invoked on conversion error
|
|
62
|
-
* @returns The JSON Schema representation, or undefined if conversion fails
|
|
63
|
-
*/
|
|
64
|
-
export function safeSchemaToJsonSchema(schema, onError) {
|
|
65
|
-
if (!schema) {
|
|
66
|
-
return undefined;
|
|
67
|
-
}
|
|
68
|
-
try {
|
|
69
|
-
return schemaToJsonSchema(schema);
|
|
70
|
-
}
|
|
71
|
-
catch (error) {
|
|
72
|
-
console.error("Error converting schema to JSON Schema:", error);
|
|
73
|
-
onError?.(error);
|
|
74
|
-
return undefined;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Creates parameter specs from an input schema.
|
|
79
|
-
* The schema represents the shape of the single object argument to the tool function.
|
|
80
|
-
* @param schema - The input schema (JSON Schema)
|
|
81
|
-
* @returns An array of parameter specifications
|
|
82
|
-
*/
|
|
83
|
-
function createParametersFromSchema(schema) {
|
|
84
|
-
const properties = schema.properties ?? {};
|
|
85
|
-
return Object.entries(properties).map(([key, propSchema]) => ({
|
|
86
|
-
name: key,
|
|
87
|
-
type: propSchema && typeof propSchema === "object" && "type" in propSchema
|
|
88
|
-
? propSchema.type
|
|
89
|
-
: "object",
|
|
90
|
-
description: propSchema &&
|
|
91
|
-
typeof propSchema === "object" &&
|
|
92
|
-
"description" in propSchema
|
|
93
|
-
? (propSchema.description ?? "")
|
|
94
|
-
: "",
|
|
95
|
-
isRequired: Array.isArray(schema.required)
|
|
96
|
-
? schema.required.includes(key)
|
|
97
|
-
: false,
|
|
98
|
-
schema: typeof propSchema === "object" && propSchema !== null
|
|
99
|
-
? propSchema
|
|
100
|
-
: {},
|
|
101
|
-
}));
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* Extracts parameter specifications from a tool's inputSchema.
|
|
105
|
-
* @param tool - The tool containing the schema
|
|
106
|
-
* @returns An array of parameter specifications
|
|
107
|
-
*/
|
|
108
|
-
export function getParametersFromToolSchema(tool) {
|
|
109
|
-
const schema = tool.inputSchema;
|
|
110
|
-
// Convert to JSON Schema if needed
|
|
111
|
-
let jsonSchema;
|
|
112
|
-
if (looksLikeJSONSchema(schema)) {
|
|
113
|
-
jsonSchema = schema;
|
|
114
|
-
}
|
|
115
|
-
else if (isStandardSchema(schema)) {
|
|
116
|
-
jsonSchema = schemaToJsonSchema(schema);
|
|
117
|
-
}
|
|
118
|
-
else {
|
|
119
|
-
console.warn("Unknown inputSchema type, returning empty parameters");
|
|
120
|
-
return [];
|
|
121
|
-
}
|
|
122
|
-
return createParametersFromSchema(jsonSchema);
|
|
123
|
-
}
|
|
124
|
-
//# sourceMappingURL=schema.js.map
|
package/esm/schema/schema.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/schema/schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,mCAAmC,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C,sDAAsD,CAAC,CAAC;QACrE,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,OAAO,0BAA0B,CAAC,UAAU,CAAC,CAAC;AAChD,CAAC","sourcesContent":["/**\n * Schema utilities for working with Standard Schema and JSON Schema.\n *\n * This module provides a unified interface for handling different schema types\n * used in Tambo components and tools. It uses Standard Schema (https://standardschema.dev/)\n * as the primary interface, which is implemented by Zod 3.24+ and other validation libraries.\n *\n * JSON Schema conversion is handled by `@standard-community/standard-json`.\n * @module schema\n */\n\nimport { loadVendor, toJsonSchema } from \"@standard-community/standard-json\";\nimport type { JSONSchema7 } from \"json-schema\";\nimport { zodToJsonSchema } from \"zod-to-json-schema\";\nimport { toJSONSchema as zod4ToJSONSchema } from \"zod/v4/core\";\nimport {\n ParameterSpec,\n SupportedSchema,\n TamboTool,\n} from \"../model/component-metadata\";\nimport { looksLikeJSONSchema } from \"./json-schema\";\nimport { isStandardSchema } from \"./standard-schema\";\n\n/**\n * Register the zod vendor handler for synchronous JSON Schema conversion.\n * This uses Zod 4's native toJSONSchema for Zod 4.x schemas and zod-to-json-schema for Zod 3.x.\n */\nloadVendor(\"zod\", (schema: unknown): JSONSchema7 => {\n // Check if this is a Zod 4 schema (has _zod property)\n if (schema && typeof schema === \"object\" && \"_zod\" in schema) {\n // Use Zod 4's native toJSONSchema from zod/v4/core\n // Cast through unknown since the Zod 4 internal types don't match our detection pattern\n return zod4ToJSONSchema(\n schema as unknown as Parameters<typeof zod4ToJSONSchema>[0],\n ) as JSONSchema7;\n }\n // Fall back to zod-to-json-schema for Zod 3.x\n return zodToJsonSchema(\n schema as Parameters<typeof zodToJsonSchema>[0],\n ) as JSONSchema7;\n});\n\n/**\n * Converts a schema (Standard Schema or JSON Schema) to a JSON Schema object.\n *\n * If the schema is already a JSON Schema, it is returned as-is.\n * For Standard Schema validators (Zod 3.24+, etc.), uses\n * `@standard-community/standard-json` for conversion.\n * @param schema - The schema to convert\n * @returns The JSON Schema representation\n * @example\n * ```typescript\n * import { z } from \"zod/v4\";\n *\n * // Convert a Zod schema\n * const zodSchema = z.object({ name: z.string() });\n * const jsonSchema = schemaToJsonSchema(zodSchema);\n *\n * // Pass through a JSON Schema\n * const existingJsonSchema = { type: \"object\", properties: { name: { type: \"string\" } } };\n * schemaToJsonSchema(existingJsonSchema); // returns the same object\n * ```\n */\nexport function schemaToJsonSchema(schema: SupportedSchema): JSONSchema7 {\n // Already a JSON Schema - return as-is\n if (!isStandardSchema(schema)) {\n return schema;\n }\n\n return toJsonSchema.sync(schema) as JSONSchema7;\n}\n\n/**\n * Safely converts a schema to JSON Schema, returning undefined for invalid inputs.\n * @param schema - The schema to convert (may be undefined)\n * @param onError - Optional callback invoked on conversion error\n * @returns The JSON Schema representation, or undefined if conversion fails\n */\nexport function safeSchemaToJsonSchema(\n schema: SupportedSchema | undefined | null,\n onError?: (error: unknown) => void,\n): JSONSchema7 | undefined {\n if (!schema) {\n return undefined;\n }\n\n try {\n return schemaToJsonSchema(schema);\n } catch (error) {\n console.error(\"Error converting schema to JSON Schema:\", error);\n onError?.(error);\n return undefined;\n }\n}\n\n/**\n * Creates parameter specs from an input schema.\n * The schema represents the shape of the single object argument to the tool function.\n * @param schema - The input schema (JSON Schema)\n * @returns An array of parameter specifications\n */\nfunction createParametersFromSchema(schema: JSONSchema7): ParameterSpec[] {\n const properties = schema.properties ?? {};\n\n return Object.entries(properties).map(\n ([key, propSchema]) =>\n ({\n name: key,\n type:\n propSchema && typeof propSchema === \"object\" && \"type\" in propSchema\n ? (propSchema.type as string)\n : \"object\",\n description:\n propSchema &&\n typeof propSchema === \"object\" &&\n \"description\" in propSchema\n ? (propSchema.description ?? \"\")\n : \"\",\n isRequired: Array.isArray(schema.required)\n ? schema.required.includes(key)\n : false,\n schema:\n typeof propSchema === \"object\" && propSchema !== null\n ? propSchema\n : {},\n }) satisfies ParameterSpec,\n );\n}\n\n/**\n * Extracts parameter specifications from a tool's inputSchema.\n * @param tool - The tool containing the schema\n * @returns An array of parameter specifications\n */\nexport function getParametersFromToolSchema(tool: TamboTool): ParameterSpec[] {\n const schema = tool.inputSchema;\n\n // Convert to JSON Schema if needed\n let jsonSchema: JSONSchema7;\n if (looksLikeJSONSchema(schema)) {\n jsonSchema = schema;\n } else if (isStandardSchema(schema)) {\n jsonSchema = schemaToJsonSchema(schema);\n } else {\n console.warn(\"Unknown inputSchema type, returning empty parameters\");\n return [];\n }\n\n return createParametersFromSchema(jsonSchema);\n}\n\nexport type { SupportedSchema };\n"]}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
2
|
-
/**
|
|
3
|
-
* Type guard to check if an object implements the Standard Schema interface.
|
|
4
|
-
*
|
|
5
|
-
* Standard Schema compliant validators have a `~standard` property containing
|
|
6
|
-
* metadata about the schema including version, vendor, and validate function.
|
|
7
|
-
* Uses duck typing to avoid cross-version Zod compatibility issues.
|
|
8
|
-
* @param obj - The object to check
|
|
9
|
-
* @returns True if the object implements StandardSchemaV1
|
|
10
|
-
* @example
|
|
11
|
-
* ```typescript
|
|
12
|
-
* import { z } from "zod/v4";
|
|
13
|
-
*
|
|
14
|
-
* const zodSchema = z.object({ name: z.string() });
|
|
15
|
-
* isStandardSchema(zodSchema); // true
|
|
16
|
-
*
|
|
17
|
-
* const jsonSchema = { type: "object", properties: { name: { type: "string" } } };
|
|
18
|
-
* isStandardSchema(jsonSchema); // false
|
|
19
|
-
* ```
|
|
20
|
-
*/
|
|
21
|
-
export declare function isStandardSchema(obj: unknown): obj is StandardSchemaV1;
|
|
22
|
-
//# sourceMappingURL=standard-schema.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"standard-schema.d.ts","sourceRoot":"","sources":["../../src/schema/standard-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,gBAAgB,CAuBtE"}
|