()
| 660 | } |
| 661 | |
| 662 | const authorizeServer = async () => { |
| 663 | const targetId = serverId |
| 664 | if (!targetId) return |
| 665 | setAuthorizing(true) |
| 666 | try { |
| 667 | const resp = await customMcpServersApi.authorizeCustomMcpServer(targetId) |
| 668 | if (resp.data) { |
| 669 | setStatus(resp.data.status) |
| 670 | if (resp.data.tools) { |
| 671 | try { |
| 672 | const parsed = JSON.parse(resp.data.tools) || {} |
| 673 | const tools = Array.isArray(parsed?.tools) ? parsed.tools : [] |
| 674 | setDiscoveredTools(tools) |
| 675 | showSnackbar(`Connected! Discovered ${tools.length} tools`) |
| 676 | } catch { |
| 677 | setDiscoveredTools([]) |
| 678 | } |
| 679 | } |
| 680 | } |
| 681 | } catch (error) { |
| 682 | setStatus(MCP_SERVER_STATUS.ERROR) |
| 683 | showSnackbar(`Authorization failed: ${getErrorMsg(error)}`, 'error') |
| 684 | } finally { |
| 685 | setAuthorizing(false) |
| 686 | if (typeof onAuthorize === 'function') onAuthorize(targetId) |
| 687 | } |
| 688 | } |
| 689 | |
| 690 | // Masked values stay visible in the form so the user keeps context. Fields |
| 691 | // left untouched still carry the masked placeholder; the backend recognises |
nothing calls this directly
no test coverage detected