ingestFile
Upload and parse files into a specified namespace, supporting multiple formats and customizable chunk configurations for efficient content management within SourceSync.ai's knowledge platform.
Instructions
Ingests a file into the namespace. Supports various file formats with automatic parsing.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| chunkConfig | No | Optional Chunk config. When not passed, default chunk config will be used. | |
| file | Yes | ||
| metadata | No | ||
| namespaceId | No | ||
| tenantId | No |
Implementation Reference
- src/sourcesync.ts:346-363 (handler)Core handler logic for ingesting a file by sending form data to the SourceSync API /v1/ingest/file endpoint.public async ingestFile({ file, metadata, }: Omit< SourceSyncIngestFileRequest, 'namespaceId' >): Promise<SourceSyncIngestResponse> { return this.client .url('/v1/ingest/file') .formData({ namespaceId: this.namespaceId, file, metadata: JSON.stringify(metadata), chunkConfig: JSON.stringify(SourceSyncApiClient.CHUNK_CONFIG), }) .post() .json<SourceSyncIngestResponse>() }
- src/index.ts:229-247 (handler)MCP server.tool registration and handler function for 'ingestFile' tool, which creates SourceSync client and delegates to its ingestFile method.server.tool( 'ingestFile', 'Ingests a file into the namespace. Supports various file formats with automatic parsing.', IngestFileSchema.shape, async (params) => { return safeApiCall(async () => { const { namespaceId, tenantId, file, metadata, chunkConfig } = params // Create a client with the provided parameters const client = createClient({ namespaceId, tenantId }) // Direct passthrough to the API return await client.ingestFile({ file: file as unknown as File, // Type cast to File as required by the client metadata, chunkConfig, }) }) },
- src/schemas.ts:194-200 (schema)Zod input schema definition for the ingestFile tool, defining parameters like file (Blob), metadata, chunkConfig, etc.export const IngestFileSchema = z.object({ namespaceId: namespaceIdSchema.optional(), file: z.instanceof(Blob), metadata: z.record(z.union([z.string(), z.array(z.string())])).optional(), chunkConfig: chunkConfigSchema.optional(), tenantId: tenantIdSchema, })
- src/index.ts:229-248 (registration)Explicit registration of the 'ingestFile' MCP tool using server.tool with name 'ingestFile'.server.tool( 'ingestFile', 'Ingests a file into the namespace. Supports various file formats with automatic parsing.', IngestFileSchema.shape, async (params) => { return safeApiCall(async () => { const { namespaceId, tenantId, file, metadata, chunkConfig } = params // Create a client with the provided parameters const client = createClient({ namespaceId, tenantId }) // Direct passthrough to the API return await client.ingestFile({ file: file as unknown as File, // Type cast to File as required by the client metadata, chunkConfig, }) }) }, )