feat(opencode-config): redact secrets and add MCP listing to the internal config API (#366)

This commit is contained in:
Chris Scott authored and GitHub committed 2026-09-28 23:52:41 -04:00
1 parent 68b13c8e35
commit a1b7f58aae
31 files changed
+1238 -181

No files matched your search

+2 -7
View File
@@ -6,7 +6,6 @@ import { useMcpServers } from './useMcpServers'
const mocks = vi.hoisted(() => ({
getStatus: vi.fn(),
addServer: vi.fn(),
connect: vi.fn(),
disconnect: vi.fn(),
startAuth: vi.fn(),
@@ -16,7 +15,6 @@ const mocks = vi.hoisted(() => ({
vi.mock('@/api/mcp', () => ({
mcpApi: {
getStatus: mocks.getStatus,
addServer: mocks.addServer,
connect: mocks.connect,
disconnect: mocks.disconnect,
startAuth: mocks.startAuth,
@@ -35,7 +33,7 @@ describe('useMcpServers', () => {
beforeEach(() => {
vi.clearAllMocks()
mocks.getStatus.mockResolvedValue({})
mocks.addServer.mockResolvedValue(undefined)
mocks.connect.mockResolvedValue(undefined)
})
const createWrapper = (queryClient: QueryClient) =>
@@ -50,10 +48,7 @@ describe('useMcpServers', () => {
const { result } = renderHook(() => useMcpServers(), { wrapper: createWrapper(queryClient) })
await act(async () => {
await result.current.addServerAsync({
name: 'server',
config: { type: 'local', command: ['echo'] },
})
await result.current.connectAsync('server')
})
const predicateCall = invalidateQueries.mock.calls.find((call) => {
-18
View File
@@ -1,6 +1,5 @@
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'
import { mcpApi } from '@/api/mcp'
import type { McpServerConfig } from '@/api/mcp'
import { invalidateSessionCaches } from '@/lib/queryInvalidation'
import { showToast as toast } from '@/lib/toast'
@@ -14,19 +13,6 @@ export function useMcpServers() {
staleTime: 2000,
})
const addServerMutation = useMutation({
mutationFn: ({ name, config }: { name: string; config: McpServerConfig }) =>
mcpApi.addServer(name, config),
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: ['mcp-status'] })
invalidateSessionCaches(queryClient)
toast.success('MCP server added successfully')
},
onError: (error: Error) => {
toast.error(`Failed to add MCP server: ${error.message}`)
},
})
const connectMutation = useMutation({
mutationFn: (name: string) => mcpApi.connect(name),
onSuccess: () => {
@@ -78,10 +64,6 @@ export function useMcpServers() {
error: statusQuery.error,
refetch: statusQuery.refetch,
addServer: addServerMutation.mutate,
addServerAsync: addServerMutation.mutateAsync,
isAddingServer: addServerMutation.isPending,
connect: connectMutation.mutate,
connectAsync: connectMutation.mutateAsync,
isConnecting: connectMutation.isPending,