@tambo-ai/react 0.64.1 → 0.65.2

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.
Files changed (130) hide show
  1. package/README.md +304 -327
  2. package/dist/hooks/use-tambo-threads.d.ts +0 -12
  3. package/dist/hooks/use-tambo-threads.d.ts.map +1 -1
  4. package/dist/hooks/use-tambo-threads.js.map +1 -1
  5. package/dist/index.d.ts +3 -1
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +6 -2
  8. package/dist/index.js.map +1 -1
  9. package/dist/mcp/__tests__/elicitation.test.js +7 -3
  10. package/dist/mcp/__tests__/elicitation.test.js.map +1 -1
  11. package/dist/mcp/__tests__/mcp-hooks.test.js +149 -123
  12. package/dist/mcp/__tests__/mcp-hooks.test.js.map +1 -1
  13. package/dist/mcp/__tests__/tambo-mcp-provider.test.js +176 -120
  14. package/dist/mcp/__tests__/tambo-mcp-provider.test.js.map +1 -1
  15. package/dist/mcp/__tests__/use-mcp-servers.test.js +12 -9
  16. package/dist/mcp/__tests__/use-mcp-servers.test.js.map +1 -1
  17. package/dist/mcp/elicitation.d.ts +4 -40
  18. package/dist/mcp/elicitation.d.ts.map +1 -1
  19. package/dist/mcp/elicitation.js +1 -1
  20. package/dist/mcp/elicitation.js.map +1 -1
  21. package/dist/mcp/index.d.ts +2 -1
  22. package/dist/mcp/index.d.ts.map +1 -1
  23. package/dist/mcp/index.js +2 -1
  24. package/dist/mcp/index.js.map +1 -1
  25. package/dist/mcp/mcp-client.d.ts +14 -26
  26. package/dist/mcp/mcp-client.d.ts.map +1 -1
  27. package/dist/mcp/mcp-client.js +4 -7
  28. package/dist/mcp/mcp-client.js.map +1 -1
  29. package/dist/mcp/mcp-hooks.d.ts +27 -78
  30. package/dist/mcp/mcp-hooks.d.ts.map +1 -1
  31. package/dist/mcp/tambo-mcp-provider.d.ts +27 -45
  32. package/dist/mcp/tambo-mcp-provider.d.ts.map +1 -1
  33. package/dist/mcp/tambo-mcp-provider.js +36 -87
  34. package/dist/mcp/tambo-mcp-provider.js.map +1 -1
  35. package/dist/model/mcp-server-info.d.ts +74 -0
  36. package/dist/model/mcp-server-info.d.ts.map +1 -0
  37. package/dist/model/mcp-server-info.js +29 -0
  38. package/dist/model/mcp-server-info.js.map +1 -0
  39. package/dist/providers/__tests__/tambo-thread-provider-initial-messages.test.js +22 -8
  40. package/dist/providers/__tests__/tambo-thread-provider-initial-messages.test.js.map +1 -1
  41. package/dist/providers/__tests__/tambo-thread-provider.test.js +318 -129
  42. package/dist/providers/__tests__/tambo-thread-provider.test.js.map +1 -1
  43. package/dist/providers/index.d.ts +1 -1
  44. package/dist/providers/index.d.ts.map +1 -1
  45. package/dist/providers/index.js +2 -1
  46. package/dist/providers/index.js.map +1 -1
  47. package/dist/providers/tambo-client-provider.d.ts +4 -0
  48. package/dist/providers/tambo-client-provider.d.ts.map +1 -1
  49. package/dist/providers/tambo-client-provider.js +3 -0
  50. package/dist/providers/tambo-client-provider.js.map +1 -1
  51. package/dist/providers/tambo-mcp-token-provider.d.ts +3 -0
  52. package/dist/providers/tambo-mcp-token-provider.d.ts.map +1 -1
  53. package/dist/providers/tambo-mcp-token-provider.js +11 -3
  54. package/dist/providers/tambo-mcp-token-provider.js.map +1 -1
  55. package/dist/providers/tambo-provider.d.ts +1 -0
  56. package/dist/providers/tambo-provider.d.ts.map +1 -1
  57. package/dist/providers/tambo-provider.js +10 -5
  58. package/dist/providers/tambo-provider.js.map +1 -1
  59. package/dist/providers/tambo-registry-provider.d.ts +37 -0
  60. package/dist/providers/tambo-registry-provider.d.ts.map +1 -1
  61. package/dist/providers/tambo-registry-provider.js +162 -2
  62. package/dist/providers/tambo-registry-provider.js.map +1 -1
  63. package/dist/providers/tambo-stubs.d.ts.map +1 -1
  64. package/dist/providers/tambo-stubs.js +10 -1
  65. package/dist/providers/tambo-stubs.js.map +1 -1
  66. package/esm/hooks/use-tambo-threads.d.ts +0 -12
  67. package/esm/hooks/use-tambo-threads.d.ts.map +1 -1
  68. package/esm/hooks/use-tambo-threads.js.map +1 -1
  69. package/esm/index.d.ts +3 -1
  70. package/esm/index.d.ts.map +1 -1
  71. package/esm/index.js +3 -2
  72. package/esm/index.js.map +1 -1
  73. package/esm/mcp/__tests__/elicitation.test.js +8 -4
  74. package/esm/mcp/__tests__/elicitation.test.js.map +1 -1
  75. package/esm/mcp/__tests__/mcp-hooks.test.js +149 -123
  76. package/esm/mcp/__tests__/mcp-hooks.test.js.map +1 -1
  77. package/esm/mcp/__tests__/tambo-mcp-provider.test.js +178 -122
  78. package/esm/mcp/__tests__/tambo-mcp-provider.test.js.map +1 -1
  79. package/esm/mcp/__tests__/use-mcp-servers.test.js +12 -9
  80. package/esm/mcp/__tests__/use-mcp-servers.test.js.map +1 -1
  81. package/esm/mcp/elicitation.d.ts +4 -40
  82. package/esm/mcp/elicitation.d.ts.map +1 -1
  83. package/esm/mcp/elicitation.js +2 -2
  84. package/esm/mcp/elicitation.js.map +1 -1
  85. package/esm/mcp/index.d.ts +2 -1
  86. package/esm/mcp/index.d.ts.map +1 -1
  87. package/esm/mcp/index.js +1 -1
  88. package/esm/mcp/index.js.map +1 -1
  89. package/esm/mcp/mcp-client.d.ts +14 -26
  90. package/esm/mcp/mcp-client.d.ts.map +1 -1
  91. package/esm/mcp/mcp-client.js +3 -5
  92. package/esm/mcp/mcp-client.js.map +1 -1
  93. package/esm/mcp/mcp-hooks.d.ts +27 -78
  94. package/esm/mcp/mcp-hooks.d.ts.map +1 -1
  95. package/esm/mcp/tambo-mcp-provider.d.ts +27 -45
  96. package/esm/mcp/tambo-mcp-provider.d.ts.map +1 -1
  97. package/esm/mcp/tambo-mcp-provider.js +35 -86
  98. package/esm/mcp/tambo-mcp-provider.js.map +1 -1
  99. package/esm/model/mcp-server-info.d.ts +74 -0
  100. package/esm/model/mcp-server-info.d.ts.map +1 -0
  101. package/esm/model/mcp-server-info.js +25 -0
  102. package/esm/model/mcp-server-info.js.map +1 -0
  103. package/esm/providers/__tests__/tambo-thread-provider-initial-messages.test.js +23 -9
  104. package/esm/providers/__tests__/tambo-thread-provider-initial-messages.test.js.map +1 -1
  105. package/esm/providers/__tests__/tambo-thread-provider.test.js +319 -130
  106. package/esm/providers/__tests__/tambo-thread-provider.test.js.map +1 -1
  107. package/esm/providers/index.d.ts +1 -1
  108. package/esm/providers/index.d.ts.map +1 -1
  109. package/esm/providers/index.js +1 -1
  110. package/esm/providers/index.js.map +1 -1
  111. package/esm/providers/tambo-client-provider.d.ts +4 -0
  112. package/esm/providers/tambo-client-provider.d.ts.map +1 -1
  113. package/esm/providers/tambo-client-provider.js +3 -0
  114. package/esm/providers/tambo-client-provider.js.map +1 -1
  115. package/esm/providers/tambo-mcp-token-provider.d.ts +3 -0
  116. package/esm/providers/tambo-mcp-token-provider.d.ts.map +1 -1
  117. package/esm/providers/tambo-mcp-token-provider.js +13 -5
  118. package/esm/providers/tambo-mcp-token-provider.js.map +1 -1
  119. package/esm/providers/tambo-provider.d.ts +1 -0
  120. package/esm/providers/tambo-provider.d.ts.map +1 -1
  121. package/esm/providers/tambo-provider.js +11 -6
  122. package/esm/providers/tambo-provider.js.map +1 -1
  123. package/esm/providers/tambo-registry-provider.d.ts +37 -0
  124. package/esm/providers/tambo-registry-provider.d.ts.map +1 -1
  125. package/esm/providers/tambo-registry-provider.js +161 -2
  126. package/esm/providers/tambo-registry-provider.js.map +1 -1
  127. package/esm/providers/tambo-stubs.d.ts.map +1 -1
  128. package/esm/providers/tambo-stubs.js +10 -1
  129. package/esm/providers/tambo-stubs.js.map +1 -1
  130. package/package.json +6 -6
@@ -4,7 +4,7 @@ export { TamboContextAttachmentProvider, useTamboContextAttachment, } from "./ta
4
4
  export { TamboContextHelpersProvider, useTamboContextHelpers, } from "./tambo-context-helpers-provider";
5
5
  export { Pending, Streaming, Success, TamboPropStreamProvider, useTamboStream, } from "./tambo-prop-stream-provider";
6
6
  export { TamboContext, TamboProvider, useTambo } from "./tambo-provider";
7
- export { TamboRegistryProvider, useTamboRegistry, } from "./tambo-registry-provider";
7
+ export { TamboRegistryProvider, useTamboMcpServerInfos, useTamboRegistry, } from "./tambo-registry-provider";
8
8
  export { TamboStubProvider } from "./tambo-stubs";
9
9
  export { TamboThreadInputProvider, useTamboThreadInput, } from "./tambo-thread-input-provider";
10
10
  export { TamboThreadContext, TamboThreadProvider, useTamboGenerationStage, useTamboThread, } from "./tambo-thread-provider";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/providers/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,mBAAmB,EACnB,uBAAuB,EACvB,cAAc,GACf,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,sBAAsB,EACtB,iBAAiB,GAClB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,8BAA8B,EAC9B,yBAAyB,GAK1B,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EACL,2BAA2B,EAC3B,sBAAsB,GAGvB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EACL,OAAO,EACP,SAAS,EACT,OAAO,EACP,uBAAuB,EACvB,cAAc,GACf,MAAM,8BAA8B,CAAC;AAMtC,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACzE,OAAO,EACL,qBAAqB,EACrB,gBAAgB,GAEjB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,iBAAiB,EAA+B,MAAM,eAAe,CAAC;AAC/E,OAAO,EACL,wBAAwB,EACxB,mBAAmB,GAEpB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,uBAAuB,EACvB,cAAc,GAEf,MAAM,yBAAyB,CAAC","sourcesContent":["export type { TamboComponent, TamboTool } from \"../model/component-metadata\";\nexport {\n TamboClientProvider,\n useIsTamboTokenUpdating,\n useTamboClient,\n} from \"./tambo-client-provider\";\nexport {\n TamboComponentProvider,\n useTamboComponent,\n} from \"./tambo-component-provider\";\nexport {\n TamboContextAttachmentProvider,\n useTamboContextAttachment,\n type ContextAttachment,\n type ContextAttachmentState,\n type ContextHelperData,\n type TamboContextAttachmentProviderProps,\n} from \"./tambo-context-attachment-provider\";\nexport {\n TamboContextHelpersProvider,\n useTamboContextHelpers,\n type TamboContextHelpersContextProps,\n type TamboContextHelpersProviderProps,\n} from \"./tambo-context-helpers-provider\";\nexport {\n Pending,\n Streaming,\n Success,\n TamboPropStreamProvider,\n useTamboStream,\n} from \"./tambo-prop-stream-provider\";\nexport type {\n StreamStateComponentProps,\n StreamStatus,\n TamboPropStreamContextValue,\n} from \"./tambo-prop-stream-provider\";\nexport { TamboContext, TamboProvider, useTambo } from \"./tambo-provider\";\nexport {\n TamboRegistryProvider,\n useTamboRegistry,\n type TamboRegistryContext,\n} from \"./tambo-registry-provider\";\nexport { TamboStubProvider, type TamboStubProviderProps } from \"./tambo-stubs\";\nexport {\n TamboThreadInputProvider,\n useTamboThreadInput,\n type TamboThreadInputContextProps,\n} from \"./tambo-thread-input-provider\";\nexport {\n TamboThreadContext,\n TamboThreadProvider,\n useTamboGenerationStage,\n useTamboThread,\n type TamboThreadProviderProps,\n} from \"./tambo-thread-provider\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/providers/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,mBAAmB,EACnB,uBAAuB,EACvB,cAAc,GACf,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,sBAAsB,EACtB,iBAAiB,GAClB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,8BAA8B,EAC9B,yBAAyB,GAK1B,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EACL,2BAA2B,EAC3B,sBAAsB,GAGvB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EACL,OAAO,EACP,SAAS,EACT,OAAO,EACP,uBAAuB,EACvB,cAAc,GACf,MAAM,8BAA8B,CAAC;AAMtC,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACzE,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EACtB,gBAAgB,GAEjB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,iBAAiB,EAA+B,MAAM,eAAe,CAAC;AAC/E,OAAO,EACL,wBAAwB,EACxB,mBAAmB,GAEpB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,uBAAuB,EACvB,cAAc,GAEf,MAAM,yBAAyB,CAAC","sourcesContent":["export type { TamboComponent, TamboTool } from \"../model/component-metadata\";\nexport {\n TamboClientProvider,\n useIsTamboTokenUpdating,\n useTamboClient,\n} from \"./tambo-client-provider\";\nexport {\n TamboComponentProvider,\n useTamboComponent,\n} from \"./tambo-component-provider\";\nexport {\n TamboContextAttachmentProvider,\n useTamboContextAttachment,\n type ContextAttachment,\n type ContextAttachmentState,\n type ContextHelperData,\n type TamboContextAttachmentProviderProps,\n} from \"./tambo-context-attachment-provider\";\nexport {\n TamboContextHelpersProvider,\n useTamboContextHelpers,\n type TamboContextHelpersContextProps,\n type TamboContextHelpersProviderProps,\n} from \"./tambo-context-helpers-provider\";\nexport {\n Pending,\n Streaming,\n Success,\n TamboPropStreamProvider,\n useTamboStream,\n} from \"./tambo-prop-stream-provider\";\nexport type {\n StreamStateComponentProps,\n StreamStatus,\n TamboPropStreamContextValue,\n} from \"./tambo-prop-stream-provider\";\nexport { TamboContext, TamboProvider, useTambo } from \"./tambo-provider\";\nexport {\n TamboRegistryProvider,\n useTamboMcpServerInfos,\n useTamboRegistry,\n type TamboRegistryContext,\n} from \"./tambo-registry-provider\";\nexport { TamboStubProvider, type TamboStubProviderProps } from \"./tambo-stubs\";\nexport {\n TamboThreadInputProvider,\n useTamboThreadInput,\n type TamboThreadInputContextProps,\n} from \"./tambo-thread-input-provider\";\nexport {\n TamboThreadContext,\n TamboThreadProvider,\n useTamboGenerationStage,\n useTamboThread,\n type TamboThreadProviderProps,\n} from \"./tambo-thread-provider\";\n"]}
@@ -30,6 +30,10 @@ export interface TamboClientContextProps {
30
30
  queryClient: QueryClient;
31
31
  /** Whether the session token is currently being updated */
32
32
  isUpdatingToken: boolean;
33
+ /** The current MCP access token for the internal Tambo MCP server */
34
+ mcpAccessToken: string | null;
35
+ /** Update the MCP access token (for internal use by TamboThreadProvider) */
36
+ setMcpAccessToken: (token: string | null) => void;
33
37
  }
34
38
  export declare const TamboClientContext: React.Context<TamboClientContextProps | undefined>;
35
39
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"tambo-client-provider.d.ts","sourceRoot":"","sources":["../../src/providers/tambo-client-provider.tsx"],"names":[],"mappings":"AACA,OAAO,OAA0B,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,KAAK,EAAE,EAAiB,iBAAiB,EAAY,MAAM,OAAO,CAAC;AAI1E,MAAM,WAAW,wBAAwB;IACvC;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,WAAW,CAAC,EAAE,YAAY,GAAG,SAAS,CAAC;IAEvC;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,uBAAuB;IACtC,yBAAyB;IACzB,MAAM,EAAE,OAAO,CAAC;IAChB,sCAAsC;IACtC,WAAW,EAAE,WAAW,CAAC;IACzB,2DAA2D;IAC3D,eAAe,EAAE,OAAO,CAAC;CAC1B;AAED,eAAO,MAAM,kBAAkB,oDAEnB,CAAC;AAEb;;;;;;;;;;GAUG;AACH,eAAO,MAAM,mBAAmB,EAAE,KAAK,CAAC,EAAE,CACxC,iBAAiB,CAAC,wBAAwB,CAAC,CAmC5C,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,cAAc,eAM1B,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,mBAQ/B,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,uBAAuB,eAQnC,CAAC"}
1
+ {"version":3,"file":"tambo-client-provider.d.ts","sourceRoot":"","sources":["../../src/providers/tambo-client-provider.tsx"],"names":[],"mappings":"AACA,OAAO,OAA0B,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,KAAK,EAAE,EAAiB,iBAAiB,EAAY,MAAM,OAAO,CAAC;AAI1E,MAAM,WAAW,wBAAwB;IACvC;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,WAAW,CAAC,EAAE,YAAY,GAAG,SAAS,CAAC;IAEvC;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,uBAAuB;IACtC,yBAAyB;IACzB,MAAM,EAAE,OAAO,CAAC;IAChB,sCAAsC;IACtC,WAAW,EAAE,WAAW,CAAC;IACzB,2DAA2D;IAC3D,eAAe,EAAE,OAAO,CAAC;IACzB,qEAAqE;IACrE,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,4EAA4E;IAC5E,iBAAiB,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;CACnD;AAED,eAAO,MAAM,kBAAkB,oDAEnB,CAAC;AAEb;;;;;;;;;;GAUG;AACH,eAAO,MAAM,mBAAmB,EAAE,KAAK,CAAC,EAAE,CACxC,iBAAiB,CAAC,wBAAwB,CAAC,CAsC5C,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,cAAc,eAM1B,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,mBAQ/B,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,uBAAuB,eAQnC,CAAC"}
@@ -31,12 +31,15 @@ export const TamboClientProvider = ({ children, tamboUrl, apiKey, environment, u
31
31
  }
32
32
  const [client] = useState(() => new TamboAI(tamboConfig));
33
33
  const [queryClient] = useState(() => new QueryClient());
34
+ const [mcpAccessToken, setMcpAccessToken] = useState(null);
34
35
  // Keep the session token updated and get the updating state
35
36
  const { isFetching: isUpdatingToken } = useTamboSessionToken(client, queryClient, userToken);
36
37
  return (React.createElement(TamboClientContext.Provider, { value: {
37
38
  client,
38
39
  queryClient,
39
40
  isUpdatingToken,
41
+ mcpAccessToken,
42
+ setMcpAccessToken,
40
43
  } }, children));
41
44
  };
42
45
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"tambo-client-provider.js","sourceRoot":"","sources":["../../src/providers/tambo-client-provider.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;AACb,OAAO,OAA0B,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,KAAK,EAAE,EAAE,aAAa,EAAqB,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC1E,OAAO,WAAW,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAmCvE,MAAM,CAAC,MAAM,kBAAkB,GAAG,aAAa,CAE7C,SAAS,CAAC,CAAC;AAEb;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAE5B,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,SAAS,EAAE,EAAE,EAAE;IAC7D,MAAM,WAAW,GAAkB;QACjC,MAAM;QACN,cAAc,EAAE;YACd,uBAAuB,EAAE,WAAW,CAAC,OAAO;SAC7C;KACF,CAAC;IACF,IAAI,QAAQ,EAAE,CAAC;QACb,WAAW,CAAC,OAAO,GAAG,QAAQ,CAAC;IACjC,CAAC;IACD,IAAI,WAAW,EAAE,CAAC;QAChB,WAAW,CAAC,WAAW,GAAG,WAAW,CAAC;IACxC,CAAC;I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CAAC;QAC1B,MAAM,IAAI,KAAK,CACb,mEAAmE,CACpE,CAAC;IACJ,CAAC;IACD,OAAO,OAAO,CAAC,eAAe,CAAC;AACjC,CAAC,CAAC","sourcesContent":["\"use client\";\nimport TamboAI, { ClientOptions } from \"@tambo-ai/typescript-sdk\";\nimport { QueryClient } from \"@tanstack/react-query\";\nimport React, { createContext, PropsWithChildren, useState } from \"react\";\nimport packageJson from \"../../package.json\";\nimport { useTamboSessionToken } from \"./hooks/use-tambo-session-token\";\n\nexport interface TamboClientProviderProps {\n /**\n * The URL of the Tambo API (only used for local development and debugging)\n */\n tamboUrl?: string;\n /**\n * The API key for the Tambo API. This typically comes from a variable like\n * `process.env.NEXT_PUBLIC_TAMBO_API_KEY`\n */\n apiKey: string;\n /**\n * The environment to use for the Tambo API\n */\n environment?: \"production\" | \"staging\";\n\n /**\n * The user token to use to identify the user in the Tambo API. This token is\n * a 3rd party token like a Google or GitHub access token, exchanged with the\n * Tambo API to get a session token. This is used to securely identify the\n * user when calling the Tambo API.\n */\n userToken?: string;\n}\n\nexport interface TamboClientContextProps {\n /** The TamboAI client */\n client: TamboAI;\n /** The tambo-specific query client */\n queryClient: QueryClient;\n /** Whether the session token is currently being updated */\n isUpdatingToken: boolean;\n}\n\nexport const TamboClientContext = createContext<\n TamboClientContextProps | undefined\n>(undefined);\n\n/**\n * The TamboClientProvider is a React provider that provides a TamboAI client\n * and a query client to the descendants of the provider.\n * @param props - The props for the TamboClientProvider\n * @param props.children - The children to wrap\n * @param props.tamboUrl - The URL of the Tambo API\n * @param props.apiKey - The API key for the Tambo API\n * @param props.environment - The environment to use for the Tambo API\n * @param props.userToken - The oauth access token to use to identify the user in the Tambo API\n * @returns The TamboClientProvider component\n */\nexport const TamboClientProvider: React.FC<\n PropsWithChildren<TamboClientProviderProps>\n> = ({ children, tamboUrl, apiKey, environment, userToken }) => {\n const tamboConfig: ClientOptions = {\n apiKey,\n defaultHeaders: {\n \"X-Tambo-React-Version\": packageJson.version,\n },\n };\n if (tamboUrl) {\n tamboConfig.baseURL = tamboUrl;\n }\n if (environment) {\n tamboConfig.environment = environment;\n }\n const [client] = useState(() => new TamboAI(tamboConfig));\n const [queryClient] = useState(() => new QueryClient());\n\n // Keep the session token updated and get the updating state\n const { isFetching: isUpdatingToken } = useTamboSessionToken(\n client,\n queryClient,\n userToken,\n );\n\n return (\n <TamboClientContext.Provider\n value={{\n client,\n queryClient,\n isUpdatingToken,\n }}\n >\n {children}\n </TamboClientContext.Provider>\n );\n};\n\n/**\n * The useTamboClient hook provides access to the TamboAI client\n * to the descendants of the TamboClientProvider.\n * @returns The TamboAI client\n */\nexport const useTamboClient = () => {\n const context = React.useContext(TamboClientContext);\n if (context === undefined) {\n throw new Error(\"useTamboClient must be used within a TamboClientProvider\");\n }\n return context.client;\n};\n\n/**\n * The useTamboQueryClient hook provides access to the tambo-specific query client\n * to the descendants of the TamboClientProvider.\n * @returns The tambo-specific query client\n * @private\n */\nexport const useTamboQueryClient = () => {\n const context = React.useContext(TamboClientContext);\n if (context === undefined) {\n throw new Error(\n \"useTamboQueryClient must be used within a TamboClientProvider\",\n );\n }\n return context.queryClient;\n};\n\n/**\n * Hook to check if the session token is currently being updated\n * @returns true if the token is being refreshed, false otherwise\n */\nexport const useIsTamboTokenUpdating = () => {\n const context = React.useContext(TamboClientContext);\n if (context === undefined) {\n throw new Error(\n \"useIsTamboTokenUpdating must be used within a TamboClientProvider\",\n );\n }\n return context.isUpdatingToken;\n};\n"]}
1
+ {"version":3,"file":"tambo-client-provider.js","sourceRoot":"","sources":["../../src/providers/tambo-client-provider.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;AACb,OAAO,OAA0B,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,KAAK,EAAE,EAAE,aAAa,EAAqB,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC1E,OAAO,WAAW,MAAM,oBAAoB,CAAC;AAC7C,O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AU,CAAC,kBAAkB,CAAC,CAAC;IACrD,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,0DAA0D,CAAC,CAAC;IAC9E,CAAC;IACD,OAAO,OAAO,CAAC,MAAM,CAAC;AACxB,CAAC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAG,EAAE;IACtC,MAAM,OAAO,GAAG,KAAK,CAAC,UAAU,CAAC,kBAAkB,CAAC,CAAC;IACrD,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CACb,+DAA+D,CAChE,CAAC;IACJ,CAAC;IACD,OAAO,OAAO,CAAC,WAAW,CAAC;AAC7B,CAAC,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAAG,EAAE;IAC1C,MAAM,OAAO,GAAG,KAAK,CAAC,UAAU,CAAC,kBAAkB,CAAC,CAAC;IACrD,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CACb,mEAAmE,CACpE,CAAC;IACJ,CAAC;IACD,OAAO,OAAO,CAAC,eAAe,CAAC;AACjC,CAAC,CAAC","sourcesContent":["\"use client\";\nimport TamboAI, { ClientOptions } from \"@tambo-ai/typescript-sdk\";\nimport { QueryClient } from \"@tanstack/react-query\";\nimport React, { createContext, PropsWithChildren, useState } from \"react\";\nimport packageJson from \"../../package.json\";\nimport { useTamboSessionToken } from \"./hooks/use-tambo-session-token\";\n\nexport interface TamboClientProviderProps {\n /**\n * The URL of the Tambo API (only used for local development and debugging)\n */\n tamboUrl?: string;\n /**\n * The API key for the Tambo API. This typically comes from a variable like\n * `process.env.NEXT_PUBLIC_TAMBO_API_KEY`\n */\n apiKey: string;\n /**\n * The environment to use for the Tambo API\n */\n environment?: \"production\" | \"staging\";\n\n /**\n * The user token to use to identify the user in the Tambo API. This token is\n * a 3rd party token like a Google or GitHub access token, exchanged with the\n * Tambo API to get a session token. This is used to securely identify the\n * user when calling the Tambo API.\n */\n userToken?: string;\n}\n\nexport interface TamboClientContextProps {\n /** The TamboAI client */\n client: TamboAI;\n /** The tambo-specific query client */\n queryClient: QueryClient;\n /** Whether the session token is currently being updated */\n isUpdatingToken: boolean;\n /** The current MCP access token for the internal Tambo MCP server */\n mcpAccessToken: string | null;\n /** Update the MCP access token (for internal use by TamboThreadProvider) */\n setMcpAccessToken: (token: string | null) => void;\n}\n\nexport const TamboClientContext = createContext<\n TamboClientContextProps | undefined\n>(undefined);\n\n/**\n * The TamboClientProvider is a React provider that provides a TamboAI client\n * and a query client to the descendants of the provider.\n * @param props - The props for the TamboClientProvider\n * @param props.children - The children to wrap\n * @param props.tamboUrl - The URL of the Tambo API\n * @param props.apiKey - The API key for the Tambo API\n * @param props.environment - The environment to use for the Tambo API\n * @param props.userToken - The oauth access token to use to identify the user in the Tambo API\n * @returns The TamboClientProvider component\n */\nexport const TamboClientProvider: React.FC<\n PropsWithChildren<TamboClientProviderProps>\n> = ({ children, tamboUrl, apiKey, environment, userToken }) => {\n const tamboConfig: ClientOptions = {\n apiKey,\n defaultHeaders: {\n \"X-Tambo-React-Version\": packageJson.version,\n },\n };\n if (tamboUrl) {\n tamboConfig.baseURL = tamboUrl;\n }\n if (environment) {\n tamboConfig.environment = environment;\n }\n const [client] = useState(() => new TamboAI(tamboConfig));\n const [queryClient] = useState(() => new QueryClient());\n const [mcpAccessToken, setMcpAccessToken] = useState<string | null>(null);\n\n // Keep the session token updated and get the updating state\n const { isFetching: isUpdatingToken } = useTamboSessionToken(\n client,\n queryClient,\n userToken,\n );\n\n return (\n <TamboClientContext.Provider\n value={{\n client,\n queryClient,\n isUpdatingToken,\n mcpAccessToken,\n setMcpAccessToken,\n }}\n >\n {children}\n </TamboClientContext.Provider>\n );\n};\n\n/**\n * The useTamboClient hook provides access to the TamboAI client\n * to the descendants of the TamboClientProvider.\n * @returns The TamboAI client\n */\nexport const useTamboClient = () => {\n const context = React.useContext(TamboClientContext);\n if (context === undefined) {\n throw new Error(\"useTamboClient must be used within a TamboClientProvider\");\n }\n return context.client;\n};\n\n/**\n * The useTamboQueryClient hook provides access to the tambo-specific query client\n * to the descendants of the TamboClientProvider.\n * @returns The tambo-specific query client\n * @private\n */\nexport const useTamboQueryClient = () => {\n const context = React.useContext(TamboClientContext);\n if (context === undefined) {\n throw new Error(\n \"useTamboQueryClient must be used within a TamboClientProvider\",\n );\n }\n return context.queryClient;\n};\n\n/**\n * Hook to check if the session token is currently being updated\n * @returns true if the token is being refreshed, false otherwise\n */\nexport const useIsTamboTokenUpdating = () => {\n const context = React.useContext(TamboClientContext);\n if (context === undefined) {\n throw new Error(\n \"useIsTamboTokenUpdating must be used within a TamboClientProvider\",\n );\n }\n return context.isUpdatingToken;\n};\n"]}
@@ -19,6 +19,9 @@ export interface TamboMcpTokenContextProps {
19
19
  * Provider for managing the MCP access token that is returned by the Tambo API.
20
20
  * This token is used to authenticate with the internal Tambo MCP server.
21
21
  * The base URL is derived from the TamboClient's baseURL property.
22
+ *
23
+ * **NOTE**: This provider now delegates token state management to TamboClientProvider.
24
+ * It exists primarily for backward compatibility and to add the tamboBaseUrl.
22
25
  * @internal
23
26
  * @param props - The provider props
24
27
  * @param props.children - The children to wrap
@@ -1 +1 @@
1
- {"version":3,"file":"tambo-mcp-token-provider.d.ts","sourceRoot":"","sources":["../../src/providers/tambo-mcp-token-provider.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAEZ,iBAAiB,EAGlB,MAAM,OAAO,CAAC;AAGf,MAAM,WAAW,yBAAyB;IACxC;;OAEG;IACH,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B;;;OAGG;IACH,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC;;;OAGG;IACH,iBAAiB,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;CACnD;AAMD;;;;;;;;GAQG;AACH,eAAO,MAAM,qBAAqB,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CAa7D,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,QAAO,yBAQnC,CAAC"}
1
+ {"version":3,"file":"tambo-mcp-token-provider.d.ts","sourceRoot":"","sources":["../../src/providers/tambo-mcp-token-provider.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAEZ,iBAAiB,EAGlB,MAAM,OAAO,CAAC;AAGf,MAAM,WAAW,yBAAyB;IACxC;;OAEG;IACH,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B;;;OAGG;IACH,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC;;;OAGG;IACH,iBAAiB,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;CACnD;AAMD;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,qBAAqB,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CAsB7D,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,QAAO,yBAQnC,CAAC"}
@@ -1,20 +1,28 @@
1
1
  "use client";
2
- import React, { createContext, useContext, useState, } from "react";
3
- import { useTamboClient } from "./tambo-client-provider";
2
+ import React, { createContext, useContext, useMemo, } from "react";
3
+ import { TamboClientContext } from "./tambo-client-provider";
4
4
  const TamboMcpTokenContext = createContext(undefined);
5
5
  /**
6
6
  * Provider for managing the MCP access token that is returned by the Tambo API.
7
7
  * This token is used to authenticate with the internal Tambo MCP server.
8
8
  * The base URL is derived from the TamboClient's baseURL property.
9
+ *
10
+ * **NOTE**: This provider now delegates token state management to TamboClientProvider.
11
+ * It exists primarily for backward compatibility and to add the tamboBaseUrl.
9
12
  * @internal
10
13
  * @param props - The provider props
11
14
  * @param props.children - The children to wrap
12
15
  * @returns The TamboMcpTokenProvider component
13
16
  */
14
17
  export const TamboMcpTokenProvider = ({ children, }) => {
15
- const [mcpAccessToken, setMcpAccessToken] = useState(null);
16
- const { baseURL: tamboBaseUrl } = useTamboClient();
17
- return (React.createElement(TamboMcpTokenContext.Provider, { value: { mcpAccessToken, tamboBaseUrl, setMcpAccessToken } }, children));
18
+ const clientContext = useContext(TamboClientContext);
19
+ if (!clientContext) {
20
+ throw new Error("TamboMcpTokenProvider must be used within a TamboClientProvider");
21
+ }
22
+ const { client, mcpAccessToken, setMcpAccessToken } = clientContext;
23
+ const tamboBaseUrl = client.baseURL;
24
+ const value = useMemo(() => ({ mcpAccessToken, tamboBaseUrl, setMcpAccessToken }), [mcpAccessToken, tamboBaseUrl, setMcpAccessToken]);
25
+ return (React.createElement(TamboMcpTokenContext.Provider, { value: value }, children));
18
26
  };
19
27
  /**
20
28
  * Hook to access the current MCP access token.
@@ -1 +1 @@
1
- {"version":3,"file":"tambo-mcp-token-provider.js","sourceRoot":"","sources":["../../src/providers/tambo-mcp-token-provider.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;AACb,OAAO,KAAK,EAAE,EACZ,aAAa,EAEb,UAAU,EACV,QAAQ,GACT,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAmBzD,MAAM,oBAAoB,GAAG,aAAa,CAExC,SAAS,CAAC,CAAC;AAEb;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAgC,CAAC,EACjE,QAAQ,GACT,EAAE,EAAE;IACH,MAAM,CAAC,cAAc,EAAE,iBAAiB,CAAC,GAAG,QAAQ,CAAgB,IAAI,CAAC,CAAC;IAC1E,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,GAAG,cAAc,EAAE,CAAC;IAEnD,OAAO,CACL,oBAAC,oBAAoB,CAAC,QAAQ,IAC5B,KAAK,EAAE,EAAE,cAAc,EAAE,YAAY,EAAE,iBAAiB,EAAE,IAEzD,QAAQ,CACqB,CACjC,CAAC;AACJ,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAA8B,EAAE;IAC9D,MAAM,OAAO,GAAG,UAAU,CAAC,oBAAoB,CAAC,CAAC;IACjD,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CACb,8DAA8D,CAC/D,CAAC;IACJ,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC","sourcesContent":["\"use client\";\nimport React, {\n createContext,\n PropsWithChildren,\n useContext,\n useState,\n} from \"react\";\nimport { useTamboClient } from \"./tambo-client-provider\";\n\nexport interface TamboMcpTokenContextProps {\n /**\n * The current MCP access token for the internal Tambo MCP server\n */\n mcpAccessToken: string | null;\n /**\n * The base URL for the Tambo API (used to construct the MCP server URL)\n * Returns undefined if the client is not yet initialized\n */\n tamboBaseUrl: string | undefined;\n /**\n * Update the MCP access token (for internal use by TamboThreadProvider)\n * @internal\n */\n setMcpAccessToken: (token: string | null) => void;\n}\n\nconst TamboMcpTokenContext = createContext<\n TamboMcpTokenContextProps | undefined\n>(undefined);\n\n/**\n * Provider for managing the MCP access token that is returned by the Tambo API.\n * This token is used to authenticate with the internal Tambo MCP server.\n * The base URL is derived from the TamboClient's baseURL property.\n * @internal\n * @param props - The provider props\n * @param props.children - The children to wrap\n * @returns The TamboMcpTokenProvider component\n */\nexport const TamboMcpTokenProvider: React.FC<PropsWithChildren> = ({\n children,\n}) => {\n const [mcpAccessToken, setMcpAccessToken] = useState<string | null>(null);\n const { baseURL: tamboBaseUrl } = useTamboClient();\n\n return (\n <TamboMcpTokenContext.Provider\n value={{ mcpAccessToken, tamboBaseUrl, setMcpAccessToken }}\n >\n {children}\n </TamboMcpTokenContext.Provider>\n );\n};\n\n/**\n * Hook to access the current MCP access token.\n * @internal\n * @returns The current MCP access token and a setter function\n */\nexport const useTamboMcpToken = (): TamboMcpTokenContextProps => {\n const context = useContext(TamboMcpTokenContext);\n if (context === undefined) {\n throw new Error(\n \"useTamboMcpToken must be used within a TamboMcpTokenProvider\",\n );\n }\n return context;\n};\n"]}
1
+ {"version":3,"file":"tambo-mcp-token-provider.js","sourceRoot":"","sources":["../../src/providers/tambo-mcp-token-provider.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;AACb,OAAO,KAAK,EAAE,EACZ,aAAa,EAEb,UAAU,EACV,OAAO,GACR,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAmB7D,MAAM,oBAAoB,GAAG,aAAa,CAExC,SAAS,CAAC,CAAC;AAEb;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAgC,CAAC,EACjE,QAAQ,GACT,EAAE,EAAE;IACH,MAAM,aAAa,GAAG,UAAU,CAAC,kBAAkB,CAAC,CAAC;IACrD,IAAI,CAAC,aAAa,EAAE,CAAC;QACnB,MAAM,IAAI,KAAK,CACb,iEAAiE,CAClE,CAAC;IACJ,CAAC;IACD,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,iBAAiB,EAAE,GAAG,aAAa,CAAC;IACpE,MAAM,YAAY,GAAG,MAAM,CAAC,OAAO,CAAC;IAEpC,MAAM,KAAK,GAAG,OAAO,CACnB,GAAG,EAAE,CAAC,CAAC,EAAE,cAAc,EAAE,YAAY,EAAE,iBAAiB,EAAE,CAAC,EAC3D,CAAC,cAAc,EAAE,YAAY,EAAE,iBAAiB,CAAC,CAClD,CAAC;IAEF,OAAO,CACL,oBAAC,oBAAoB,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,IACxC,QAAQ,CACqB,CACjC,CAAC;AACJ,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAA8B,EAAE;IAC9D,MAAM,OAAO,GAAG,UAAU,CAAC,oBAAoB,CAAC,CAAC;IACjD,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CACb,8DAA8D,CAC/D,CAAC;IACJ,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC","sourcesContent":["\"use client\";\nimport React, {\n createContext,\n PropsWithChildren,\n useContext,\n useMemo,\n} from \"react\";\nimport { TamboClientContext } from \"./tambo-client-provider\";\n\nexport interface TamboMcpTokenContextProps {\n /**\n * The current MCP access token for the internal Tambo MCP server\n */\n mcpAccessToken: string | null;\n /**\n * The base URL for the Tambo API (used to construct the MCP server URL)\n * Returns undefined if the client is not yet initialized\n */\n tamboBaseUrl: string | undefined;\n /**\n * Update the MCP access token (for internal use by TamboThreadProvider)\n * @internal\n */\n setMcpAccessToken: (token: string | null) => void;\n}\n\nconst TamboMcpTokenContext = createContext<\n TamboMcpTokenContextProps | undefined\n>(undefined);\n\n/**\n * Provider for managing the MCP access token that is returned by the Tambo API.\n * This token is used to authenticate with the internal Tambo MCP server.\n * The base URL is derived from the TamboClient's baseURL property.\n *\n * **NOTE**: This provider now delegates token state management to TamboClientProvider.\n * It exists primarily for backward compatibility and to add the tamboBaseUrl.\n * @internal\n * @param props - The provider props\n * @param props.children - The children to wrap\n * @returns The TamboMcpTokenProvider component\n */\nexport const TamboMcpTokenProvider: React.FC<PropsWithChildren> = ({\n children,\n}) => {\n const clientContext = useContext(TamboClientContext);\n if (!clientContext) {\n throw new Error(\n \"TamboMcpTokenProvider must be used within a TamboClientProvider\",\n );\n }\n const { client, mcpAccessToken, setMcpAccessToken } = clientContext;\n const tamboBaseUrl = client.baseURL;\n\n const value = useMemo(\n () => ({ mcpAccessToken, tamboBaseUrl, setMcpAccessToken }),\n [mcpAccessToken, tamboBaseUrl, setMcpAccessToken],\n );\n\n return (\n <TamboMcpTokenContext.Provider value={value}>\n {children}\n </TamboMcpTokenContext.Provider>\n );\n};\n\n/**\n * Hook to access the current MCP access token.\n * @internal\n * @returns The current MCP access token and a setter function\n */\nexport const useTamboMcpToken = (): TamboMcpTokenContextProps => {\n const context = useContext(TamboMcpTokenContext);\n if (context === undefined) {\n throw new Error(\n \"useTamboMcpToken must be used within a TamboMcpTokenProvider\",\n );\n }\n return context;\n};\n"]}
@@ -17,6 +17,7 @@ import { TamboGenerationStageContextProps, TamboThreadContextProps, TamboThreadP
17
17
  * @param props.components - The components to register
18
18
  * @param props.environment - The environment to use for the Tambo API
19
19
  * @param props.tools - The tools to register
20
+ * @param props.mcpServers - The MCP servers to register (metadata only - use TamboMcpProvider for connections)
20
21
  * @param props.streaming - Whether to stream the response by default. Defaults to true.
21
22
  * @param props.autoGenerateThreadName - Whether to automatically generate thread names. Defaults to true.
22
23
  * @param props.autoGenerateNameThreshold - The message count threshold at which the thread name will be auto-generated. Defaults to 3.
@@ -1 +1 @@
1
- {"version":3,"file":"tambo-provider.d.ts","sourceRoot":"","sources":["../../src/providers/tambo-provider.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,iBAAiB,EAA6B,MAAM,OAAO,CAAC;AAC5E,OAAO,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAC;AACvE,OAAO,EACL,uBAAuB,EAEvB,wBAAwB,EAIzB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,0BAA0B,EAG3B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,sBAAsB,EAEtB,mCAAmC,EAEpC,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EACL,+BAA+B,EAE/B,gCAAgC,EAEjC,MAAM,kCAAkC,CAAC;AAM1C,OAAO,EAEL,0BAA0B,EAC3B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAEL,6BAA6B,EAC9B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,gCAAgC,EAChC,uBAAuB,EAEvB,wBAAwB,EAEzB,MAAM,yBAAyB,CAAC;AAEjC;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAClC,iBAAiB,CACf,wBAAwB,GACtB,0BAA0B,GAC1B,wBAAwB,GACxB,gCAAgC,GAChC,6BAA6B,GAC7B,OAAO,CAAC,IAA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CAAC,IAAI,CAAC,mCAAmC,EAAE,sBAAsB,CAAC,CAAC,CAC7E,CA2DF,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG,uBAAuB,GACrD,uBAAuB,GACvB,gCAAgC,GAChC,0BAA0B,GAC1B,wBAAwB,GACxB,+BAA+B,GAC/B,sBAAsB,CAAC;AAEzB,eAAO,MAAM,YAAY,kCAExB,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,sBAAsB,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CAwC9D,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,QAAQ,yBAEpB,CAAC"}
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
  import React, { createContext, useContext } from "react";
3
- import { TamboClientProvider, useIsTamboTokenUpdating, useTamboClient, useTamboQueryClient, } from "./tambo-client-provider";
3
+ import { TamboClientContext, TamboClientProvider, } from "./tambo-client-provider";
4
4
  import { TamboComponentProvider, useTamboComponent, } from "./tambo-component-provider";
5
5
  import { TamboContextAttachmentProvider, useTamboContextAttachment, } from "./tambo-context-attachment-provider";
6
6
  import { TamboContextHelpersProvider, useTamboContextHelpers, } from "./tambo-context-helpers-provider";
@@ -19,6 +19,7 @@ import { TamboThreadProvider, useTamboThread, } from "./tambo-thread-provider";
19
19
  * @param props.components - The components to register
20
20
  * @param props.environment - The environment to use for the Tambo API
21
21
  * @param props.tools - The tools to register
22
+ * @param props.mcpServers - The MCP servers to register (metadata only - use TamboMcpProvider for connections)
22
23
  * @param props.streaming - Whether to stream the response by default. Defaults to true.
23
24
  * @param props.autoGenerateThreadName - Whether to automatically generate thread names. Defaults to true.
24
25
  * @param props.autoGenerateNameThreshold - The message count threshold at which the thread name will be auto-generated. Defaults to 3.
@@ -30,9 +31,9 @@ import { TamboThreadProvider, useTamboThread, } from "./tambo-thread-provider";
30
31
  * @param props.getContextHelperData - Optional function to customize the data sent to the AI for each context attachment
31
32
  * @returns The TamboProvider component
32
33
  */
33
- export const TamboProvider = ({ children, tamboUrl, apiKey, userToken, components, environment, tools, streaming, autoGenerateThreadName, autoGenerateNameThreshold, contextHelpers, contextKey, initialMessages, onCallUnregisteredTool, getContextHelperData, }) => {
34
+ export const TamboProvider = ({ children, tamboUrl, apiKey, userToken, components, environment, tools, mcpServers, streaming, autoGenerateThreadName, autoGenerateNameThreshold, contextHelpers, contextKey, initialMessages, onCallUnregisteredTool, getContextHelperData, }) => {
34
35
  return (React.createElement(TamboClientProvider, { tamboUrl: tamboUrl, apiKey: apiKey, environment: environment, userToken: userToken },
35
- React.createElement(TamboRegistryProvider, { components: components, tools: tools, onCallUnregisteredTool: onCallUnregisteredTool },
36
+ React.createElement(TamboRegistryProvider, { components: components, tools: tools, mcpServers: mcpServers, onCallUnregisteredTool: onCallUnregisteredTool },
36
37
  React.createElement(TamboContextHelpersProvider, { contextHelpers: contextHelpers },
37
38
  React.createElement(TamboMcpTokenProvider, null,
38
39
  React.createElement(TamboThreadProvider, { streaming: streaming, autoGenerateThreadName: autoGenerateThreadName, autoGenerateNameThreshold: autoGenerateNameThreshold, initialMessages: initialMessages },
@@ -52,9 +53,11 @@ export const TamboContext = createContext({});
52
53
  */
53
54
  export const TamboCompositeProvider = ({ children, }) => {
54
55
  const threads = useTamboThread();
55
- const client = useTamboClient();
56
- const queryClient = useTamboQueryClient();
57
- const isUpdatingToken = useIsTamboTokenUpdating();
56
+ const clientContext = useContext(TamboClientContext);
57
+ if (!clientContext) {
58
+ throw new Error("TamboCompositeProvider must be used within a TamboClientProvider");
59
+ }
60
+ const { client, queryClient, isUpdatingToken, mcpAccessToken, setMcpAccessToken, } = clientContext;
58
61
  const componentRegistry = useTamboComponent();
59
62
  const interactableComponents = useTamboInteractable();
60
63
  const contextHelpers = useTamboContextHelpers();
@@ -63,6 +66,8 @@ export const TamboCompositeProvider = ({ children, }) => {
63
66
  client,
64
67
  queryClient,
65
68
  isUpdatingToken,
69
+ mcpAccessToken,
70
+ setMcpAccessToken,
66
71
  ...componentRegistry,
67
72
  ...threads,
68
73
  ...interactableComponents,
@@ -1 +1 @@
1
- {"version":3,"file":"tambo-provider.js","sourceRoot":"","sources":["../../src/providers/tambo-provider.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;AACb,OAAO,KAAK,EAAE,EAAqB,aAAa,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAE5E,OAAO,EAEL,mBAAmB,EAEnB,uBAAuB,EACvB,cAAc,EACd,mBAAmB,GACpB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAEL,sBAAsB,EACtB,iBAAiB,GAClB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAEL,8BAA8B,EAE9B,yBAAyB,GAC1B,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAEL,2BAA2B,EAE3B,sBAAsB,GACvB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EACL,yBAAyB,EACzB,oBAAoB,GACrB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EACL,qBAAqB,GAEtB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,wBAAwB,GAEzB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAGL,mBAAmB,EAEnB,cAAc,GACf,MAAM,yBAAyB,CAAC;AAEjC;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,CAAC,MAAM,aAAa,GAStB,CAAC,EACH,QAAQ,EACR,QAAQ,EACR,MAAM,EACN,SAAS,EACT,UAAU,EACV,WAAW,EACX,KAAK,EACL,SAAS,EACT,sBAAsB,EACtB,yBAAyB,EACzB,cAAc,EACd,UAAU,EACV,eAAe,EACf,sBAAsB,EACtB,oBAAoB,GACrB,EAAE,EAAE;IACH,OAAO,CACL,oBAAC,mBAAmB,IAClB,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,WAAW,EACxB,SAAS,EAAE,SAAS;QAEpB,oBAAC,qBAA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c;YACjB,GAAG,iBAAiB;SACrB,IAEA,QAAQ,CACa,CACzB,CAAC;AACJ,CAAC,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,GAAG,EAAE;IAC3B,OAAO,UAAU,CAAC,YAAY,CAAC,CAAC;AAClC,CAAC,CAAC","sourcesContent":["\"use client\";\nimport React, { PropsWithChildren, createContext, useContext } from \"react\";\nimport { TamboInteractableContext } from \"../model/tambo-interactable\";\nimport {\n TamboClientContextProps,\n TamboClientProvider,\n TamboClientProviderProps,\n useIsTamboTokenUpdating,\n useTamboClient,\n useTamboQueryClient,\n} from \"./tambo-client-provider\";\nimport {\n TamboComponentContextProps,\n TamboComponentProvider,\n useTamboComponent,\n} from \"./tambo-component-provider\";\nimport {\n ContextAttachmentState,\n TamboContextAttachmentProvider,\n TamboContextAttachmentProviderProps,\n useTamboContextAttachment,\n} from \"./tambo-context-attachment-provider\";\nimport {\n TamboContextHelpersContextProps,\n TamboContextHelpersProvider,\n TamboContextHelpersProviderProps,\n useTamboContextHelpers,\n} from \"./tambo-context-helpers-provider\";\nimport {\n TamboInteractableProvider,\n useTamboInteractable,\n} from \"./tambo-interactable-provider\";\nimport { TamboMcpTokenProvider } from \"./tambo-mcp-token-provider\";\nimport {\n TamboRegistryProvider,\n TamboRegistryProviderProps,\n} from \"./tambo-registry-provider\";\nimport {\n TamboThreadInputProvider,\n TamboThreadInputProviderProps,\n} from \"./tambo-thread-input-provider\";\nimport {\n TamboGenerationStageContextProps,\n TamboThreadContextProps,\n TamboThreadProvider,\n TamboThreadProviderProps,\n useTamboThread,\n} from \"./tambo-thread-provider\";\n\n/**\n * The TamboProvider gives full access to the whole Tambo API. This includes the\n * TamboAI client, the component registry, the current thread context, and interactable components.\n * @param props - The props for the TamboProvider\n * @param props.children - The children to wrap\n * @param props.tamboUrl - The URL of the Tambo API\n * @param props.apiKey - The API key for the Tambo API\n * @param props.components - The components to register\n * @param props.environment - The environment to use for the Tambo API\n * @param props.tools - The tools to register\n * @param props.streaming - Whether to stream the response by default. Defaults to true.\n * @param props.autoGenerateThreadName - Whether to automatically generate thread names. Defaults to true.\n * @param props.autoGenerateNameThreshold - The message count threshold at which the thread name will be auto-generated. Defaults to 3.\n * @param props.contextHelpers - Configuration for which context helpers are enabled/disabled\n * @param props.userToken - The user's OAuth token (access or ID) used to identify the user and exchange for a Tambo session token (preferred over contextKey)\n * @param props.contextKey - Optional context key to be used in the thread input provider\n * @param props.onCallUnregisteredTool - Callback function called when an unregistered tool is called\n * @param props.initialMessages - Initial messages to be included in new threads\n * @param props.getContextHelperData - Optional function to customize the data sent to the AI for each context attachment\n * @returns The TamboProvider component\n */\nexport const TamboProvider: React.FC<\n PropsWithChildren<\n TamboClientProviderProps &\n TamboRegistryProviderProps &\n TamboThreadProviderProps &\n TamboContextHelpersProviderProps &\n TamboThreadInputProviderProps &\n Partial<Pick<TamboContextAttachmentProviderProps, \"getContextHelperData\">>\n >\n> = ({\n children,\n tamboUrl,\n apiKey,\n userToken,\n components,\n environment,\n tools,\n streaming,\n autoGenerateThreadName,\n autoGenerateNameThreshold,\n contextHelpers,\n contextKey,\n initialMessages,\n onCallUnregisteredTool,\n getContextHelperData,\n}) => {\n return (\n <TamboClientProvider\n tamboUrl={tamboUrl}\n apiKey={apiKey}\n environment={environment}\n userToken={userToken}\n >\n <TamboRegistryProvider\n components={components}\n tools={tools}\n onCallUnregisteredTool={onCallUnregisteredTool}\n >\n <TamboContextHelpersProvider contextHelpers={contextHelpers}>\n <TamboMcpTokenProvider>\n <TamboThreadProvider\n streaming={streaming}\n autoGenerateThreadName={autoGenerateThreadName}\n autoGenerateNameThreshold={autoGenerateNameThreshold}\n initialMessages={initialMessages}\n >\n <TamboThreadInputProvider contextKey={contextKey}>\n <TamboContextAttachmentProvider\n getContextHelperData={getContextHelperData}\n >\n <TamboComponentProvider>\n <TamboInteractableProvider>\n <TamboCompositeProvider>\n {children}\n </TamboCompositeProvider>\n </TamboInteractableProvider>\n </TamboComponentProvider>\n </TamboContextAttachmentProvider>\n </TamboThreadInputProvider>\n </TamboThreadProvider>\n </TamboMcpTokenProvider>\n </TamboContextHelpersProvider>\n </TamboRegistryProvider>\n </TamboClientProvider>\n );\n};\n\nexport type TamboContextProps = TamboClientContextProps &\n TamboThreadContextProps &\n TamboGenerationStageContextProps &\n TamboComponentContextProps &\n TamboInteractableContext &\n TamboContextHelpersContextProps &\n ContextAttachmentState;\n\nexport const TamboContext = createContext<TamboContextProps>(\n {} as TamboContextProps,\n);\n\n/**\n * TamboCompositeProvider is a provider that combines the TamboClient,\n * TamboThread, TamboComponent, and TamboInteractable providers\n * @param props - The props for the TamboCompositeProvider\n * @param props.children - The children to wrap\n * @returns The wrapped component\n */\nexport const TamboCompositeProvider: React.FC<PropsWithChildren> = ({\n children,\n}) => {\n const threads = useTamboThread();\n const client = useTamboClient();\n const queryClient = useTamboQueryClient();\n const isUpdatingToken = useIsTamboTokenUpdating();\n const componentRegistry = useTamboComponent();\n const interactableComponents = useTamboInteractable();\n const contextHelpers = useTamboContextHelpers();\n const contextAttachment = useTamboContextAttachment();\n\n return (\n <TamboContext.Provider\n value={{\n client,\n queryClient,\n isUpdatingToken,\n ...componentRegistry,\n ...threads,\n ...interactableComponents,\n ...contextHelpers,\n ...contextAttachment,\n }}\n >\n {children}\n </TamboContext.Provider>\n );\n};\n\n/**\n * The useTambo hook provides access to the Tambo API. This is the primary entrypoint\n * for the Tambo React SDK.\n *\n * This includes the TamboAI client, the component registry, the current thread context,\n * and interactable component management.\n * @returns The Tambo API\n */\nexport const useTambo = () => {\n return useContext(TamboContext);\n};\n"]}
1
+ {"version":3,"file":"tambo-provider.js","sourceRoot":"","sources":["../../src/providers/tambo-provider.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;AACb,OAAO,KAAK,EAAE,EAAqB,aAAa,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAE5E,OAAO,EACL,kBAAkB,EAElB,mBAAmB,GAEpB,MAAM,yBA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,GAAG,GAAG,EAAE;IAC3B,OAAO,UAAU,CAAC,YAAY,CAAC,CAAC;AAClC,CAAC,CAAC","sourcesContent":["\"use client\";\nimport React, { PropsWithChildren, createContext, useContext } from \"react\";\nimport { TamboInteractableContext } from \"../model/tambo-interactable\";\nimport {\n TamboClientContext,\n TamboClientContextProps,\n TamboClientProvider,\n TamboClientProviderProps,\n} from \"./tambo-client-provider\";\nimport {\n TamboComponentContextProps,\n TamboComponentProvider,\n useTamboComponent,\n} from \"./tambo-component-provider\";\nimport {\n ContextAttachmentState,\n TamboContextAttachmentProvider,\n TamboContextAttachmentProviderProps,\n useTamboContextAttachment,\n} from \"./tambo-context-attachment-provider\";\nimport {\n TamboContextHelpersContextProps,\n TamboContextHelpersProvider,\n TamboContextHelpersProviderProps,\n useTamboContextHelpers,\n} from \"./tambo-context-helpers-provider\";\nimport {\n TamboInteractableProvider,\n useTamboInteractable,\n} from \"./tambo-interactable-provider\";\nimport { TamboMcpTokenProvider } from \"./tambo-mcp-token-provider\";\nimport {\n TamboRegistryProvider,\n TamboRegistryProviderProps,\n} from \"./tambo-registry-provider\";\nimport {\n TamboThreadInputProvider,\n TamboThreadInputProviderProps,\n} from \"./tambo-thread-input-provider\";\nimport {\n TamboGenerationStageContextProps,\n TamboThreadContextProps,\n TamboThreadProvider,\n TamboThreadProviderProps,\n useTamboThread,\n} from \"./tambo-thread-provider\";\n\n/**\n * The TamboProvider gives full access to the whole Tambo API. This includes the\n * TamboAI client, the component registry, the current thread context, and interactable components.\n * @param props - The props for the TamboProvider\n * @param props.children - The children to wrap\n * @param props.tamboUrl - The URL of the Tambo API\n * @param props.apiKey - The API key for the Tambo API\n * @param props.components - The components to register\n * @param props.environment - The environment to use for the Tambo API\n * @param props.tools - The tools to register\n * @param props.mcpServers - The MCP servers to register (metadata only - use TamboMcpProvider for connections)\n * @param props.streaming - Whether to stream the response by default. Defaults to true.\n * @param props.autoGenerateThreadName - Whether to automatically generate thread names. Defaults to true.\n * @param props.autoGenerateNameThreshold - The message count threshold at which the thread name will be auto-generated. Defaults to 3.\n * @param props.contextHelpers - Configuration for which context helpers are enabled/disabled\n * @param props.userToken - The user's OAuth token (access or ID) used to identify the user and exchange for a Tambo session token (preferred over contextKey)\n * @param props.contextKey - Optional context key to be used in the thread input provider\n * @param props.onCallUnregisteredTool - Callback function called when an unregistered tool is called\n * @param props.initialMessages - Initial messages to be included in new threads\n * @param props.getContextHelperData - Optional function to customize the data sent to the AI for each context attachment\n * @returns The TamboProvider component\n */\nexport const TamboProvider: React.FC<\n PropsWithChildren<\n TamboClientProviderProps &\n TamboRegistryProviderProps &\n TamboThreadProviderProps &\n TamboContextHelpersProviderProps &\n TamboThreadInputProviderProps &\n Partial<Pick<TamboContextAttachmentProviderProps, \"getContextHelperData\">>\n >\n> = ({\n children,\n tamboUrl,\n apiKey,\n userToken,\n components,\n environment,\n tools,\n mcpServers,\n streaming,\n autoGenerateThreadName,\n autoGenerateNameThreshold,\n contextHelpers,\n contextKey,\n initialMessages,\n onCallUnregisteredTool,\n getContextHelperData,\n}) => {\n return (\n <TamboClientProvider\n tamboUrl={tamboUrl}\n apiKey={apiKey}\n environment={environment}\n userToken={userToken}\n >\n <TamboRegistryProvider\n components={components}\n tools={tools}\n mcpServers={mcpServers}\n onCallUnregisteredTool={onCallUnregisteredTool}\n >\n <TamboContextHelpersProvider contextHelpers={contextHelpers}>\n <TamboMcpTokenProvider>\n <TamboThreadProvider\n streaming={streaming}\n autoGenerateThreadName={autoGenerateThreadName}\n autoGenerateNameThreshold={autoGenerateNameThreshold}\n initialMessages={initialMessages}\n >\n <TamboThreadInputProvider contextKey={contextKey}>\n <TamboContextAttachmentProvider\n getContextHelperData={getContextHelperData}\n >\n <TamboComponentProvider>\n <TamboInteractableProvider>\n <TamboCompositeProvider>\n {children}\n </TamboCompositeProvider>\n </TamboInteractableProvider>\n </TamboComponentProvider>\n </TamboContextAttachmentProvider>\n </TamboThreadInputProvider>\n </TamboThreadProvider>\n </TamboMcpTokenProvider>\n </TamboContextHelpersProvider>\n </TamboRegistryProvider>\n </TamboClientProvider>\n );\n};\n\nexport type TamboContextProps = TamboClientContextProps &\n TamboThreadContextProps &\n TamboGenerationStageContextProps &\n TamboComponentContextProps &\n TamboInteractableContext &\n TamboContextHelpersContextProps &\n ContextAttachmentState;\n\nexport const TamboContext = createContext<TamboContextProps>(\n {} as TamboContextProps,\n);\n\n/**\n * TamboCompositeProvider is a provider that combines the TamboClient,\n * TamboThread, TamboComponent, and TamboInteractable providers\n * @param props - The props for the TamboCompositeProvider\n * @param props.children - The children to wrap\n * @returns The wrapped component\n */\nexport const TamboCompositeProvider: React.FC<PropsWithChildren> = ({\n children,\n}) => {\n const threads = useTamboThread();\n const clientContext = useContext(TamboClientContext);\n if (!clientContext) {\n throw new Error(\n \"TamboCompositeProvider must be used within a TamboClientProvider\",\n );\n }\n const {\n client,\n queryClient,\n isUpdatingToken,\n mcpAccessToken,\n setMcpAccessToken,\n } = clientContext;\n const componentRegistry = useTamboComponent();\n const interactableComponents = useTamboInteractable();\n const contextHelpers = useTamboContextHelpers();\n const contextAttachment = useTamboContextAttachment();\n\n return (\n <TamboContext.Provider\n value={{\n client,\n queryClient,\n isUpdatingToken,\n mcpAccessToken,\n setMcpAccessToken,\n ...componentRegistry,\n ...threads,\n ...interactableComponents,\n ...contextHelpers,\n ...contextAttachment,\n }}\n >\n {children}\n </TamboContext.Provider>\n );\n};\n\n/**\n * The useTambo hook provides access to the Tambo API. This is the primary entrypoint\n * for the Tambo React SDK.\n *\n * This includes the TamboAI client, the component registry, the current thread context,\n * and interactable component management.\n * @returns The Tambo API\n */\nexport const useTambo = () => {\n return useContext(TamboContext);\n};\n"]}
@@ -1,14 +1,18 @@
1
1
  import type TamboAI from "@tambo-ai/typescript-sdk";
2
2
  import React, { PropsWithChildren } from "react";
3
3
  import { ComponentRegistry, TamboComponent, TamboTool } from "../model/component-metadata";
4
+ import { McpServerInfo, type NormalizedMcpServerInfo } from "../model/mcp-server-info";
4
5
  export interface TamboRegistryContext {
5
6
  componentList: ComponentRegistry;
6
7
  toolRegistry: Record<string, TamboTool>;
7
8
  componentToolAssociations: Record<string, string[]>;
9
+ mcpServerInfos: NormalizedMcpServerInfo[];
8
10
  registerComponent: (options: TamboComponent) => void;
9
11
  registerTool: (tool: TamboTool) => void;
10
12
  registerTools: (tools: TamboTool[]) => void;
11
13
  addToolAssociation: (componentName: string, tool: TamboTool) => void;
14
+ registerMcpServer: (info: McpServerInfo) => void;
15
+ registerMcpServers: (infos: McpServerInfo[]) => void;
12
16
  onCallUnregisteredTool?: (toolName: string, args: TamboAI.ToolCallParameter[]) => Promise<string>;
13
17
  }
14
18
  export declare const TamboRegistryContext: React.Context<TamboRegistryContext>;
@@ -17,6 +21,8 @@ export interface TamboRegistryProviderProps {
17
21
  components?: TamboComponent[];
18
22
  /** The tools to register */
19
23
  tools?: TamboTool[];
24
+ /** The MCP servers to register */
25
+ mcpServers?: (McpServerInfo | string)[];
20
26
  /**
21
27
  * A function to call when an unknown tool is called. If this function is not
22
28
  * provided, an error will be thrown when a tool call is requested by the
@@ -34,6 +40,7 @@ export interface TamboRegistryProviderProps {
34
40
  * @param props.children - The children to wrap
35
41
  * @param props.components - The components to register
36
42
  * @param props.tools - The tools to register
43
+ * @param props.mcpServers - The MCP servers to register
37
44
  * @param props.onCallUnregisteredTool - The function to call when an unknown tool is called (optional)
38
45
  * @returns The TamboRegistryProvider component
39
46
  */
@@ -44,4 +51,34 @@ export declare const TamboRegistryProvider: React.FC<PropsWithChildren<TamboRegi
44
51
  * @returns The component registry
45
52
  */
46
53
  export declare const useTamboRegistry: () => TamboRegistryContext;
54
+ /**
55
+ * Hook to access the MCP server metadata from TamboRegistryProvider.
56
+ * This provides access to the registered MCP server configurations (metadata only, not connections).
57
+ *
58
+ * This hook can be used anywhere within the TamboProvider hierarchy to access
59
+ * the list of configured MCP servers without needing to be inside TamboMcpProvider.
60
+ * @returns Array of MCP server metadata
61
+ * @example
62
+ * ```tsx
63
+ * function MyComponent() {
64
+ * const mcpServers = useTamboMcpServerInfos();
65
+ *
66
+ * return (
67
+ * <div>
68
+ * <h3>Configured MCP Servers:</h3>
69
+ * {mcpServers.map((server) => (
70
+ * <div key={server.url}>
71
+ * {server.name || server.url}
72
+ * </div>
73
+ * ))}
74
+ * </div>
75
+ * );
76
+ * }
77
+ * ```
78
+ *
79
+ * The returned objects are `NormalizedMcpServerInfo` instances, meaning both
80
+ * `serverKey` and `transport` are always populated (with `transport`
81
+ * defaulting to HTTP when not explicitly specified).
82
+ */
83
+ export declare const useTamboMcpServerInfos: () => NormalizedMcpServerInfo[];
47
84
  //# sourceMappingURL=tambo-registry-provider.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tambo-registry-provider.d.ts","sourceRoot":"","sources":["../../src/providers/tambo-registry-provider.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,OAAO,MAAM,0BAA0B,CAAC;AACpD,OAAO,KAAK,EAAE,EAEZ,iBAAiB,EAKlB,MAAM,OAAO,CAAC;AAGf,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,SAAS,EACV,MAAM,6BAA6B,CAAC;AAIrC,MAAM,WAAW,oBAAoB;IACnC,aAAa,EAAE,iBAAiB,CAAC;IACjC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IACxC,yBAAyB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IACpD,iBAAiB,EAAE,CAAC,OAAO,EAAE,cAAc,KAAK,IAAI,CAAC;IACrD,YAAY,EAAE,CAAC,IAAI,EAAE,SAAS,KAAK,IAAI,CAAC;IACxC,aAAa,EAAE,CAAC,KAAK,EAAE,SAAS,EAAE,KAAK,IAAI,CAAC;IAC5C,kBAAkB,EAAE,CAAC,aAAa,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,KAAK,IAAI,CAAC;IACrE,sBAAsB,CAAC,EAAE,CACvB,QAAQ,EAAE,MAAM,EAChB,IAA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allback, useContext, useEffect, useState, } from "react";
2
+ import React, { createContext, useCallback, useContext, useEffect, useMemo, useState, } from "react";
3
3
  import { ZodSchema } from "zod";
4
4
  import zodToJsonSchema from "zod-to-json-schema";
5
+ import { getMcpServerUniqueKey, MCPTransport, } from "../model/mcp-server-info";
5
6
  import { assertValidName } from "../util/validate-component-name";
6
7
  import { assertNoZodRecord } from "../util/validate-zod-schema";
8
+ /**
9
+ * Derives a short, meaningful key from a server URL.
10
+ * Strips TLDs and common prefixes to get a human-readable identifier.
11
+ * For example, "https://mcp.linear.app/mcp" becomes "linear".
12
+ * @returns A lowercased, human-readable key derived from the URL
13
+ */
14
+ function deriveServerKey(url) {
15
+ try {
16
+ const parsed = new URL(url);
17
+ const hostname = parsed.hostname;
18
+ // Split hostname into parts
19
+ const parts = hostname.split(".");
20
+ // Remove common TLD patterns
21
+ // Handle cases like: .com, .org, .co.uk, .com.au, etc.
22
+ let relevantParts = [...parts];
23
+ // If we have 3+ parts and the last two are short (likely TLD like .co.uk)
24
+ if (relevantParts.length >= 3 &&
25
+ relevantParts[relevantParts.length - 1].length <= 3 &&
26
+ relevantParts[relevantParts.length - 2].length <= 3) {
27
+ relevantParts = relevantParts.slice(0, -2);
28
+ }
29
+ // Otherwise just remove the last part (TLD like .com)
30
+ else if (relevantParts.length >= 2) {
31
+ relevantParts = relevantParts.slice(0, -1);
32
+ }
33
+ // From what's left, prefer the rightmost part that's not a common prefix
34
+ // Common prefixes: www, api, mcp, app, etc.
35
+ const commonPrefixes = new Set([
36
+ "www",
37
+ "api",
38
+ "mcp",
39
+ "app",
40
+ "staging",
41
+ "dev",
42
+ "prod",
43
+ ]);
44
+ // Work backwards through the parts to find a meaningful name
45
+ for (let i = relevantParts.length - 1; i >= 0; i--) {
46
+ const part = relevantParts[i];
47
+ if (part && !commonPrefixes.has(part.toLowerCase())) {
48
+ return part.toLowerCase();
49
+ }
50
+ }
51
+ // Fallback: use the last relevant part even if it's a common prefix
52
+ return relevantParts[relevantParts.length - 1]?.toLowerCase() || hostname;
53
+ }
54
+ catch {
55
+ // If URL parsing fails, just return a sanitized version of the input
56
+ return url.replace(/[^a-zA-Z0-9]/g, "_").toLowerCase();
57
+ }
58
+ }
59
+ /**
60
+ * Normalizes an MCP server info object, ensuring it has a serverKey.
61
+ * If serverKey is not provided, derives it from the URL.
62
+ * @returns The normalized MCP server info object
63
+ */
64
+ function normalizeServerInfo(server) {
65
+ const base = typeof server === "string"
66
+ ? {
67
+ url: server,
68
+ transport: MCPTransport.HTTP,
69
+ }
70
+ : server;
71
+ const serverKey = base.serverKey ?? deriveServerKey(base.url);
72
+ const transport = base.transport ?? MCPTransport.HTTP;
73
+ return { ...base, transport, serverKey };
74
+ }
7
75
  export const TamboRegistryContext = createContext({
8
76
  componentList: {},
9
77
  toolRegistry: {},
10
78
  componentToolAssociations: {},
79
+ mcpServerInfos: [],
11
80
  /**
12
81
  *
13
82
  */
@@ -24,6 +93,14 @@ export const TamboRegistryContext = createContext({
24
93
  *
25
94
  */
26
95
  addToolAssociation: () => { },
96
+ /**
97
+ *
98
+ */
99
+ registerMcpServer: () => { },
100
+ /**
101
+ *
102
+ */
103
+ registerMcpServers: () => { },
27
104
  });
28
105
  /**
29
106
  * The TamboRegistryProvider is a React provider that provides a component
@@ -32,13 +109,16 @@ export const TamboRegistryContext = createContext({
32
109
  * @param props.children - The children to wrap
33
110
  * @param props.components - The components to register
34
111
  * @param props.tools - The tools to register
112
+ * @param props.mcpServers - The MCP servers to register
35
113
  * @param props.onCallUnregisteredTool - The function to call when an unknown tool is called (optional)
36
114
  * @returns The TamboRegistryProvider component
37
115
  */
38
- export const TamboRegistryProvider = ({ children, components: userComponents, tools: userTools, onCallUnregisteredTool, }) => {
116
+ export const TamboRegistryProvider = ({ children, components: userComponents, tools: userTools, mcpServers: userMcpServers, onCallUnregisteredTool, }) => {
39
117
  const [componentList, setComponentList] = useState({});
40
118
  const [toolRegistry, setToolRegistry] = useState({});
41
119
  const [componentToolAssociations, setComponentToolAssociations] = useState({});
120
+ const [staticMcpServerInfos, setStaticMcpServerInfos] = useState([]);
121
+ const [dynamicMcpServerInfos, setDynamicMcpServerInfos] = useState([]);
42
122
  const registerTool = useCallback((tool, warnOnOverwrite = true) => {
43
123
  // Validate tool name
44
124
  assertValidName(tool.name, "tool");
@@ -59,6 +139,14 @@ export const TamboRegistryProvider = ({ children, components: userComponents, to
59
139
  const registerTools = useCallback((tools, warnOnOverwrite = true) => {
60
140
  tools.forEach((tool) => registerTool(tool, warnOnOverwrite));
61
141
  }, [registerTool]);
142
+ const registerMcpServer = useCallback((info) => {
143
+ const normalized = normalizeServerInfo(info);
144
+ setDynamicMcpServerInfos((prev) => [...prev, normalized]);
145
+ }, []);
146
+ const registerMcpServers = useCallback((infos) => {
147
+ const normalized = infos.map(normalizeServerInfo);
148
+ setDynamicMcpServerInfos((prev) => [...prev, ...normalized]);
149
+ }, []);
62
150
  const addToolAssociation = useCallback((componentName, tool) => {
63
151
  // Validate component and tool names
64
152
  assertValidName(componentName, "component");
@@ -128,14 +216,53 @@ export const TamboRegistryProvider = ({ children, components: userComponents, to
128
216
  registerTools(userTools, false);
129
217
  }
130
218
  }, [registerTools, userTools]);
219
+ useEffect(() => {
220
+ if (!userMcpServers || userMcpServers.length === 0) {
221
+ setStaticMcpServerInfos([]);
222
+ return;
223
+ }
224
+ // Normalize servers from props and ensure all have serverKey and transport
225
+ const normalized = userMcpServers.map(normalizeServerInfo);
226
+ setStaticMcpServerInfos(normalized);
227
+ }, [userMcpServers]);
228
+ const mcpServerInfos = useMemo(() => {
229
+ const allServers = [...staticMcpServerInfos, ...dynamicMcpServerInfos];
230
+ if (allServers.length === 0) {
231
+ return allServers;
232
+ }
233
+ // 1. Deduplicate by connection identity using a stable key
234
+ const byKey = new Map();
235
+ for (const server of allServers) {
236
+ const key = getMcpServerUniqueKey(server);
237
+ byKey.set(key, server);
238
+ }
239
+ const deduped = Array.from(byKey.values());
240
+ // 2. Ensure serverKey uniqueness for readable, unambiguous prefixes
241
+ const seen = new Map();
242
+ return deduped.map((server) => {
243
+ const baseKey = server.serverKey;
244
+ const count = (seen.get(baseKey) ?? 0) + 1;
245
+ seen.set(baseKey, count);
246
+ if (count === 1) {
247
+ return server;
248
+ }
249
+ return {
250
+ ...server,
251
+ serverKey: `${baseKey}-${count}`,
252
+ };
253
+ });
254
+ }, [staticMcpServerInfos, dynamicMcpServerInfos]);
131
255
  const value = {
132
256
  componentList,
133
257
  toolRegistry,
134
258
  componentToolAssociations,
259
+ mcpServerInfos,
135
260
  registerComponent,
136
261
  registerTool,
137
262
  registerTools,
138
263
  addToolAssociation,
264
+ registerMcpServer,
265
+ registerMcpServers,
139
266
  onCallUnregisteredTool,
140
267
  };
141
268
  return (React.createElement(TamboRegistryContext.Provider, { value: value }, children));
@@ -148,6 +275,38 @@ export const TamboRegistryProvider = ({ children, components: userComponents, to
148
275
  export const useTamboRegistry = () => {
149
276
  return useContext(TamboRegistryContext);
150
277
  };
278
+ /**
279
+ * Hook to access the MCP server metadata from TamboRegistryProvider.
280
+ * This provides access to the registered MCP server configurations (metadata only, not connections).
281
+ *
282
+ * This hook can be used anywhere within the TamboProvider hierarchy to access
283
+ * the list of configured MCP servers without needing to be inside TamboMcpProvider.
284
+ * @returns Array of MCP server metadata
285
+ * @example
286
+ * ```tsx
287
+ * function MyComponent() {
288
+ * const mcpServers = useTamboMcpServerInfos();
289
+ *
290
+ * return (
291
+ * <div>
292
+ * <h3>Configured MCP Servers:</h3>
293
+ * {mcpServers.map((server) => (
294
+ * <div key={server.url}>
295
+ * {server.name || server.url}
296
+ * </div>
297
+ * ))}
298
+ * </div>
299
+ * );
300
+ * }
301
+ * ```
302
+ *
303
+ * The returned objects are `NormalizedMcpServerInfo` instances, meaning both
304
+ * `serverKey` and `transport` are always populated (with `transport`
305
+ * defaulting to HTTP when not explicitly specified).
306
+ */
307
+ export const useTamboMcpServerInfos = () => {
308
+ return useContext(TamboRegistryContext).mcpServerInfos;
309
+ };
151
310
  function getSerializedProps(propsDefinition, propsSchema, name) {
152
311
  if (propsDefinition) {
153
312
  console.warn(`propsDefinition is deprecated. Use propsSchema instead.`);