(
serverId: string,
workspaceId: string
)
| 116 | } |
| 117 | |
| 118 | private async getServerConfig( |
| 119 | serverId: string, |
| 120 | workspaceId: string |
| 121 | ): Promise<McpServerConfig | null> { |
| 122 | const [server] = await db |
| 123 | .select() |
| 124 | .from(mcpServers) |
| 125 | .where( |
| 126 | and( |
| 127 | eq(mcpServers.id, serverId), |
| 128 | eq(mcpServers.workspaceId, workspaceId), |
| 129 | eq(mcpServers.enabled, true), |
| 130 | isNull(mcpServers.deletedAt) |
| 131 | ) |
| 132 | ) |
| 133 | .limit(1) |
| 134 | |
| 135 | if (!server) { |
| 136 | return null |
| 137 | } |
| 138 | |
| 139 | if (!isMcpDomainAllowed(server.url || undefined)) { |
| 140 | return null |
| 141 | } |
| 142 | |
| 143 | return { |
| 144 | id: server.id, |
| 145 | name: server.name, |
| 146 | description: server.description || undefined, |
| 147 | transport: 'streamable-http' as const, |
| 148 | url: server.url || undefined, |
| 149 | authType: (server.authType as McpServerConfig['authType']) ?? 'headers', |
| 150 | workspaceId: server.workspaceId, |
| 151 | headers: (server.headers as Record<string, string>) || {}, |
| 152 | timeout: server.timeout || 30000, |
| 153 | retries: server.retries || 3, |
| 154 | enabled: server.enabled, |
| 155 | createdAt: server.createdAt.toISOString(), |
| 156 | updatedAt: server.updatedAt.toISOString(), |
| 157 | } |
| 158 | } |
| 159 | |
| 160 | private async getWorkspaceServers(workspaceId: string): Promise<McpServerConfig[]> { |
| 161 | const whereConditions = [ |
no test coverage detected