UNPKG

sourcesyncai-mcp

Version:

[![smithery badge](https://smithery.ai/badge/@pbteja1998/sourcesyncai-mcp)](https://smithery.ai/server/@pbteja1998/sourcesyncai-mcp)

193 lines (192 loc) 5.51 kB
import { z } from "zod"; import { apiClient } from "./api-client.js"; import { IngestTextSchema, IngestFileSchema, IngestUrlsSchema, IngestSitemapSchema, IngestWebsiteSchema, IngestConnectorSchema, IngestJobRunStatusSchema } from "./schemas.js"; // Common schemas const ChunkConfigSchema = z.object({ chunkSize: z.number().optional(), chunkOverlap: z.number().optional(), }); // Ingest File // export const IngestFileSchema = z.object({ // namespaceId: NamespaceIdSchema.optional(), // ingestConfig: z.object({ // source: z.literal("FILE"), // config: z.object({ // file: z.instanceof(File), // metadata: z.record(z.any()).optional(), // }), // chunkConfig: ChunkConfigSchema.optional(), // }), // tenantId: z.string().optional(), // }); // export async function ingestFile(params: z.infer<typeof IngestFileSchema>) { // const { namespaceId, tenantId, ingestConfig } = params; // const formData = new FormData(); // formData.append("file", ingestConfig.config.file); // formData.append("metadata", JSON.stringify(ingestConfig.config.metadata || {})); // if (ingestConfig.chunkConfig) { // formData.append("chunkConfig", JSON.stringify(ingestConfig.chunkConfig)); // } // return makeApiRequest({ // method: "POST", // path: "/v1/ingest/file", // tenantId, // body: formData, // queryParams: { // namespaceId: getDefaultNamespaceId(namespaceId), // }, // }); // } /** * Ingest text into a namespace */ export async function ingestText(params) { try { // Use the existing apiClient to ingest text const result = await apiClient.ingestText({ namespaceId: params.namespaceId || "", ingestConfig: { source: 'TEXT', config: { text: params.text, metadata: params.metadata || {} }, chunkConfig: params.chunkConfig }, tenantId: params.tenantId }); return { success: true, document: result }; } catch (error) { return { success: false, message: error.message || "Failed to ingest text", error }; } } /** * Ingest a file into a namespace */ export async function ingestFile(params) { try { // This is a placeholder implementation console.log("Ingesting file:", params.file); return { success: true, message: "File ingestion is not implemented yet" }; } catch (error) { return { success: false, message: error.message || "Failed to ingest file", error }; } } /** * Ingest URLs into a namespace */ export async function ingestUrls(params) { try { // This is a placeholder implementation console.log("Ingesting URLs:", params.urls); return { success: true, message: "URL ingestion is not implemented yet" }; } catch (error) { return { success: false, message: error.message || "Failed to ingest URLs", error }; } } /** * Ingest a sitemap into a namespace */ export async function ingestSitemap(params) { try { // This is a placeholder implementation console.log("Ingesting sitemap:", params.sitemapUrl); return { success: true, message: "Sitemap ingestion is not implemented yet" }; } catch (error) { return { success: false, message: error.message || "Failed to ingest sitemap", error }; } } /** * Ingest a website into a namespace */ export async function ingestWebsite(params) { try { // This is a placeholder implementation console.log("Ingesting website:", params.websiteUrl); return { success: true, message: "Website ingestion is not implemented yet" }; } catch (error) { return { success: false, message: error.message || "Failed to ingest website", error }; } } /** * Ingest content from a connector */ export async function ingestConnector(params) { try { // This is a placeholder implementation console.log("Ingesting from connector:", params.connectionId, params.source); return { success: true, message: "Connector ingestion is not implemented yet" }; } catch (error) { return { success: false, message: error.message || "Failed to ingest from connector", error }; } } /** * Get the status of an ingest job run */ export async function getIngestJobRunStatus(params) { try { // This is a placeholder implementation console.log("Getting ingest job run status:", params.ingestJobRunId); return { success: true, status: "completed", message: "Ingest job run status is not implemented yet" }; } catch (error) { return { success: false, message: error.message || "Failed to get ingest job run status", error }; } } export { IngestTextSchema, IngestFileSchema, IngestUrlsSchema, IngestSitemapSchema, IngestWebsiteSchema, IngestConnectorSchema, IngestJobRunStatusSchema };