feat(settings): add MCP API hooks
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -55,3 +55,119 @@ export function useDeleteTagMapping() {
|
||||
onSuccess: () => qc.invalidateQueries({ queryKey: ["settings", "tag-mappings"] }),
|
||||
});
|
||||
}
|
||||
|
||||
// ── MCP Settings ────────────────────────────────────────────────
|
||||
|
||||
export type EnvCategory =
|
||||
| "multimodal"
|
||||
| "rerank"
|
||||
| "halacha"
|
||||
| "credentials"
|
||||
| "connection"
|
||||
| "general";
|
||||
|
||||
export type EnvType = "bool" | "int" | "float" | "string";
|
||||
|
||||
export type McpEnvVar = {
|
||||
key: string;
|
||||
category: EnvCategory;
|
||||
type: EnvType;
|
||||
description: string;
|
||||
is_secret: boolean;
|
||||
is_editable: boolean;
|
||||
default: unknown;
|
||||
min: number | null;
|
||||
max: number | null;
|
||||
enum_values: string[] | null;
|
||||
infisical_value: string | null;
|
||||
container_value: string | null;
|
||||
drift: boolean;
|
||||
};
|
||||
|
||||
export type McpEnvResponse = {
|
||||
vars: McpEnvVar[];
|
||||
infisical_environment: string;
|
||||
infisical_project_id: string;
|
||||
infisical_path: string;
|
||||
coolify_app_uuid: string;
|
||||
errors: string[];
|
||||
};
|
||||
|
||||
export type McpTool = {
|
||||
name: string;
|
||||
description: string;
|
||||
params_schema: unknown;
|
||||
module: string;
|
||||
source_location: string;
|
||||
};
|
||||
|
||||
export type McpRegistration = {
|
||||
client: string;
|
||||
server_name: string;
|
||||
command: string;
|
||||
args: string[];
|
||||
cwd: string;
|
||||
env_keys: string[];
|
||||
transport: string;
|
||||
};
|
||||
|
||||
export function useMcpEnv() {
|
||||
return useQuery({
|
||||
queryKey: ["settings", "mcp-env"] as const,
|
||||
queryFn: ({ signal }) =>
|
||||
apiRequest<McpEnvResponse>("/api/settings/mcp/env", { signal }),
|
||||
staleTime: 5_000,
|
||||
});
|
||||
}
|
||||
|
||||
export function useUpdateMcpEnv() {
|
||||
const qc = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: ({ key, value }: { key: string; value: unknown }) =>
|
||||
apiRequest<{
|
||||
ok: boolean;
|
||||
key: string;
|
||||
saved_value: string;
|
||||
requires_redeploy: boolean;
|
||||
message: string;
|
||||
}>(`/api/settings/mcp/env/${encodeURIComponent(key)}`, {
|
||||
method: "PATCH",
|
||||
body: { value },
|
||||
}),
|
||||
onSuccess: () => qc.invalidateQueries({ queryKey: ["settings", "mcp-env"] }),
|
||||
});
|
||||
}
|
||||
|
||||
export function useMcpRedeploy() {
|
||||
return useMutation({
|
||||
mutationFn: () =>
|
||||
apiRequest<{ ok: boolean; deployment_uuid: string | null; message: string }>(
|
||||
"/api/settings/mcp/env/redeploy",
|
||||
{ method: "POST" },
|
||||
),
|
||||
});
|
||||
}
|
||||
|
||||
export function useMcpTools() {
|
||||
return useQuery({
|
||||
queryKey: ["settings", "mcp-tools"] as const,
|
||||
queryFn: ({ signal }) =>
|
||||
apiRequest<{ tools: McpTool[]; count: number }>("/api/settings/mcp/tools", {
|
||||
signal,
|
||||
}),
|
||||
staleTime: 60_000,
|
||||
});
|
||||
}
|
||||
|
||||
export function useMcpRegistrations() {
|
||||
return useQuery({
|
||||
queryKey: ["settings", "mcp-registrations"] as const,
|
||||
queryFn: ({ signal }) =>
|
||||
apiRequest<{
|
||||
registrations: McpRegistration[];
|
||||
error: string | null;
|
||||
message?: string;
|
||||
}>("/api/settings/mcp/registrations", { signal }),
|
||||
staleTime: 60_000,
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user