api of MCP server detail

This commit is contained in:
JzoNg 2025-05-26 16:13:39 +08:00
parent a8bc02e39e
commit ccea3212a2
2 changed files with 63 additions and 0 deletions

View File

@ -172,3 +172,11 @@ export type WorkflowToolProviderResponse = {
} }
privacy_policy: string privacy_policy: string
} }
export type MCPServerDetail = {
id: string
server_code: string
description: string
status: string
parameters?: Record<string, string>
}

View File

@ -1,6 +1,7 @@
import { del, get, post, put } from './base' import { del, get, post, put } from './base'
import type { import type {
Collection, Collection,
MCPServerDetail,
Tool, Tool,
} from '@/app/components/tools/types' } from '@/app/components/tools/types'
import type { ToolWithProvider } from '@/app/components/workflow/types' import type { ToolWithProvider } from '@/app/components/workflow/types'
@ -175,6 +176,60 @@ export const useUpdateMCPTools = (providerID: string) => {
}) })
} }
export const useMCPServerDetail = (appID: string) => {
return useQuery<MCPServerDetail>({
queryKey: [NAME_SPACE, 'MCPServerDetail', appID],
queryFn: () => get<MCPServerDetail>(`/apps/${appID}/server`),
})
}
export const useCreateMCPServer = ({
onSuccess,
}: {
onSuccess?: () => void
}) => {
return useMutation({
mutationKey: [NAME_SPACE, 'create-mcp-server'],
mutationFn: (payload: {
appID: string
description: string
parameters?: Record<string, string>
}) => {
const { appID, ...rest } = payload
return post(`apps/${appID}/server`, {
body: {
...rest,
},
})
},
onSuccess,
})
}
export const useUpdateMCPServer = ({
onSuccess,
}: {
onSuccess?: () => void
}) => {
return useMutation({
mutationKey: [NAME_SPACE, 'update-mcp-server'],
mutationFn: (payload: {
appID: string
description?: string
status?: string
parameters?: Record<string, string>
}) => {
const { appID, ...rest } = payload
return put(`apps/${appID}/server`, {
body: {
...rest,
},
})
},
onSuccess,
})
}
export const useBuiltinProviderInfo = (providerName: string) => { export const useBuiltinProviderInfo = (providerName: string) => {
return useQuery({ return useQuery({
queryKey: [NAME_SPACE, 'builtin-provider-info', providerName], queryKey: [NAME_SPACE, 'builtin-provider-info', providerName],