Skip to content

The open-source agent harness - the runtime layer that turns an LLM into a working agent.

chore: handle connector authorize using custom hook on chat (#349)

sayan-truefoundryf1c5c6bea7a7
diff --git a/.changeset/mcp-auth-optional-catalog-fallback.md b/.changeset/mcp-auth-optional-catalog-fallback.md
new file mode 100644
index 000000000..16ef5cbda
--- /dev/null
+++ b/.changeset/mcp-auth-optional-catalog-fallback.md
@@ -0,0 +1,5 @@
+---
+'@truefoundry/trueforge-ui': patch
+---
+
+Fall back to the pending MCP authorization URL when the UI server does not expose a catalog.
diff --git a/packages/frontend/package.json b/packages/frontend/package.json
index cde558600..9860ec2b4 100644
--- a/packages/frontend/package.json
+++ b/packages/frontend/package.json
@@ -27,7 +27,7 @@
"@assistant-ui/core": "0.2.22",
"@assistant-ui/react": "^0.14.24",
"@assistant-ui/store": "0.2.21",
- "@truefoundry/assistant-ui-runtime": "0.1.20",
+ "@truefoundry/assistant-ui-runtime": "0.1.21",
"@truefoundry/trueforge-sdk": "workspace:*",
"@truefoundry/trueforge-ui": "workspace:*",
"monaco-editor": "^0.52.0",
diff --git a/packages/trueforge-ui/example/package.json b/packages/trueforge-ui/example/package.json
index 18853ad7f..695f1b4ee 100644
--- a/packages/trueforge-ui/example/package.json
+++ b/packages/trueforge-ui/example/package.json
@@ -15,7 +15,7 @@
"dependencies": {
"@assistant-ui/core": "^0.2.22",
"@assistant-ui/react": "^0.14.24",
- "@truefoundry/assistant-ui-runtime": "0.1.20",
+ "@truefoundry/assistant-ui-runtime": "0.1.21",
"@truefoundry/trueforge-ui": "link:..",
"react": "^19.2.4",
"react-dom": "^19.2.4",
diff --git a/packages/trueforge-ui/package.json b/packages/trueforge-ui/package.json
index d93c35516..4ce34ec89 100644
--- a/packages/trueforge-ui/package.json
+++ b/packages/trueforge-ui/package.json
@@ -97,7 +97,7 @@
"@openuidev/react-headless": "^0.9.4",
"@openuidev/react-lang": "^0.2.9",
"@openuidev/react-ui": "^0.13.2",
- "@truefoundry/assistant-ui-runtime": "0.1.20",
+ "@truefoundry/assistant-ui-runtime": "0.1.21",
"@truefoundry/trueforge-sdk": "workspace:*",
"clsx": "^2.1.1",
"lucide-react": "^0.562.0",
diff --git a/packages/trueforge-ui/src/containers/McpAuthContainer.tsx b/packages/trueforge-ui/src/containers/McpAuthContainer.tsx
index 35be2d792..c79f03daa 100644
--- a/packages/trueforge-ui/src/containers/McpAuthContainer.tsx
+++ b/packages/trueforge-ui/src/containers/McpAuthContainer.tsx
@@ -3,15 +3,45 @@
import { useThreadIsRunning } from '@assistant-ui/core/react';
import { useTrueFoundryMcpAuth } from '@truefoundry/assistant-ui-runtime';
+import { useDraftCatalog } from '@/atoms/draft/DraftCatalogProvider.js';
+import { useMCPAuth } from '@/hooks/useMcpAuth.js';
+import { useOptionalCatalogServer } from '@/server/ServerContext.js';
import { useSlot } from '../theme/SlotsProvider.js';
+type McpAuthPromptProps = {
+ servers: NonNullable<ReturnType<typeof useTrueFoundryMcpAuth>['pending']>['mcpServers'];
+ onContinue: () => void;
+ readOnly: boolean;
+};
+
+function CatalogMcpAuthPrompt({ servers, onContinue, readOnly }: McpAuthPromptProps) {
+ const McpAuthPrompt = useSlot('McpAuthPrompt');
+ const { handleAuthorize } = useMCPAuth();
+ const { refreshConnectors } = useDraftCatalog();
+
+ const handleConnect = (serverId: string) => {
+ void handleAuthorize(serverId, isSuccess => {
+ if (isSuccess) {
+ void refreshConnectors();
+ }
+ });
+ };
+
+ return <McpAuthPrompt servers={servers} onConnect={handleConnect} onContinue={onContinue} readOnly={readOnly} />;
+}
+
export function McpAuthContainer() {
const McpAuthPrompt = useSlot('McpAuthPrompt');
const { pending, resume } = useTrueFoundryMcpAuth();
const isRunning = useThreadIsRunning();
+ const catalog = useOptionalCatalogServer();
if (!pending) return null;
+ if (catalog) {
+ return <CatalogMcpAuthPrompt servers={pending.mcpServers} onContinue={() => void resume()} readOnly={isRunning} />;
+ }
+
const handleConnect = (serverId: string) => {
const server = pending.mcpServers.find(s => s.id === serverId);
if (server?.authUrl) {
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 8570eddcb..f3f53f440 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -61,8 +61,8 @@ importers:
specifier: 0.2.21
'@truefoundry/assistant-ui-runtime':
- specifier: 0.1.20
+ specifier: 0.1.21
'@truefoundry/trueforge-sdk':
specifier: workspace:*
version: link:../trueforge-sdk
@@ -340,8 +340,8 @@ importers:
specifier: ^0.13.2
'@truefoundry/assistant-ui-runtime':
- specifier: 0.1.20
+ specifier: 0.1.21
'@truefoundry/trueforge-sdk':
specifier: workspace:*
version: link:../trueforge-sdk
@@ -3449,8 +3449,8 @@ packages:
'@types/react-dom':
optional: true
- '@truefoundry/[email protected]':
- resolution: {integrity: sha512-yJnc/YRiOy1otjMZMftGL0VUaJEc4md9LFlFwrz16yoW6poIhyAohNWjlZ/+5KiEenQCQLeQNr2WFDGdw3U3XQ==}
+ '@truefoundry/[email protected]':
+ resolution: {integrity: sha512-p7Heuc+vXArqLeisqYAp2HlHLPdIPoEcxJUbcF0e/7fSGhVs0SWVNYtQ2nTw68GJsC5nyuJwQJ445sX+OhCa6w==}
peerDependencies:
'@types/react': '*'
react: ^18 || ^19
@@ -10595,7 +10595,7 @@ snapshots:
'@types/react': 19.2.17
'@types/react-dom': 19.2.3(@types/[email protected])
dependencies:
'@assistant-ui/store': 0.2.21(@assistant-ui/[email protected](@types/[email protected])([email protected]))(@types/[email protected])([email protected])