The open-source agent harness - the runtime layer that turns an LLM into a working agent.
AGE-1642: fix mapping for connect / disconnect (#76)
Heer Ambavi742fe6dff701
diff --git a/packages/frontend/src/connectorCatalog.ts b/packages/frontend/src/connectorCatalog.tsindex 6070f1f30..7a6b78f76 100644--- a/packages/frontend/src/connectorCatalog.ts+++ b/packages/frontend/src/connectorCatalog.ts@@ -79,8 +79,8 @@ export function toUiConnector(server: Harness.ConfiguredMcpServer): UiConnectordescription: server.url,url: server.url,auth,- requiresAuth: auth.type === 'oauth',- authenticated: server.authStatus.status === 'authenticated',+ requiresAuth: server.authStatus.status === 'auth_required',+ authenticated: server.authStatus.status !== 'auth_required',};}@@ -145,7 +145,6 @@ async function resolveWriteAuth(req: { id?: string; auth: ConnectorAuth }): Promreturn { type: 'apiKey', apiKey: stored, headerName };}-/** Settings connector port for `createTrueFoundryServer`. Delete omitted; disconnect unsupported. */export function createConnectorCatalog(): ConnectorCatalogServer<ToolBase,UiConnectorAuth,@@ -197,6 +196,13 @@ export function createConnectorCatalog(): ConnectorCatalogServer<const server = await getConfigured(req.id);return toUiConnector(server);},- disconnectConnector: () => Promise.reject(new Error('Disconnect is not supported by Harness yet')),+ disconnectConnector: async req => {+ const existing = await getConfigured(req.id);+ if (existing.auth?.type !== 'dcr') {+ throw new Error(`Disconnect is only supported for OAuth MCP servers`);+ }+ const body = await client.mcpServers.deleteAuthorize(req.id);+ return toUiConnector(body.data);+ },};}diff --git a/packages/frontend/tests/connectorCatalog.test.ts b/packages/frontend/tests/connectorCatalog.test.tsindex c6d2a7de9..9107fa275 100644--- a/packages/frontend/tests/connectorCatalog.test.ts+++ b/packages/frontend/tests/connectorCatalog.test.ts@@ -59,7 +59,7 @@ describe('connectorCatalog mappers', () => {type: 'remote',name: 'deepwiki',url: 'https://mcp.deepwiki.com/mcp',- authStatus: { status: 'authenticated' },+ authStatus: { status: 'not_required' },}),{id: 'deepwiki',@@ -73,6 +73,28 @@ describe('connectorCatalog mappers', () => {);});+ it('maps auth_required vs authenticated for oauth connectors', () => {+ const pending = toUiConnector({+ type: 'remote',+ name: 'linear',+ url: 'https://mcp.linear.app/mcp',+ auth: { type: 'dcr' },+ authStatus: { status: 'auth_required' },+ });+ assert.equal(pending.authenticated, false);+ assert.equal(pending.requiresAuth, true);++ const connected = toUiConnector({+ type: 'remote',+ name: 'linear',+ url: 'https://mcp.linear.app/mcp',+ auth: { type: 'dcr' },+ authStatus: { status: 'authenticated' },+ });+ assert.equal(connected.authenticated, true);+ assert.equal(connected.requiresAuth, false);+ });+it('maps tool rows with description for getToolsByConnectorId', () => {assert.deepEqual(toUiTool({ name: 'search', description: 'Find docs' }), {id: 'search',diff --git a/packages/trueforge-ui-sdk/src/containers/SettingsBuilder/ConnectorDetails.tsx b/packages/trueforge-ui-sdk/src/containers/SettingsBuilder/ConnectorDetails.tsxindex 2963f7c47..d2e3906ab 100644--- a/packages/trueforge-ui-sdk/src/containers/SettingsBuilder/ConnectorDetails.tsx+++ b/packages/trueforge-ui-sdk/src/containers/SettingsBuilder/ConnectorDetails.tsx@@ -81,7 +81,7 @@ const ConnectorDetails = ({ connector, onBack, onDisconnect, busy = false }: Con</span></div>- {connector.auth.type !== 'none' && !connector.requiresAuth ? (+ {connector.auth.type === 'oauth' && !connector.requiresAuth ? (<Button variant="outline" size="sm" type="button" disabled={busy} onClick={onDisconnect}>Disconnect</Button>