osc_upload_file
Upload a file to an Eyevinn Open Source Cloud Storage Minio instance by specifying the instance name, bucket, object key, and file path.
Instructions
Upload a file to Eyevinn Open Source Cloud Storage (OSC) Minio instance
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Name of the minio instance | |
| bucket | Yes | Name of the bucket | |
| objectKey | Yes | Object key for the uploaded file | |
| file | Yes | File to upload |
Implementation Reference
- src/tools/osc.ts:145-164 (handler)The 'uploadFile' helper function that resolves the Minio instance and delegates to uploadFileToMinioBucket. This is the main handler logic called by the switch case for osc_upload_file.
export async function uploadFile( name: string, bucket: string, objectKey: string, file: string, context: Context ) { const instance = await getMinioInstance(context, name); if (!instance) { throw new Error(`Minio instance with name ${name} not found`); } return await uploadFileToMinioBucket( instance.endpoint, instance.accessKeyId, instance.secretAccessKey, bucket, objectKey, file ); } - src/resources/minio_minio.ts:85-113 (handler)The actual upload implementation: creates a Minio client from endpoint/credentials, determines MIME type from file extension, and uploads via minioClient.fPutObject.
export async function uploadFileToMinioBucket( endpoint: string, accessKeyId: string, secretAccessKey: string, bucket: string, objectKey: string, filePath: string ) { const minioClient = new Minio.Client({ endPoint: new URL(endpoint).hostname, accessKey: accessKeyId, secretKey: secretAccessKey }); // Get mime type based on file extension const contentType = mime.lookup(filePath) || 'application/octet-stream'; const metaData = { 'Content-Type': contentType }; const uploadedObject = await minioClient.fPutObject( bucket, objectKey, filePath, metaData ); return uploadedObject; } - src/schemas.ts:3-11 (schema)Zod schema defining the inputs for osc_upload_file: name (minio instance name, regex validated), bucket, objectKey, and file path.
export const UploadFileSchema = z.object({ name: z .string() .regex(/^[a-z0-9]+$/) .describe('Name of the minio instance'), bucket: z.string().describe('Name of the bucket'), objectKey: z.string().describe('Object key for the uploaded file'), file: z.string().describe('File to upload') }); - src/tools/osc.ts:19-26 (registration)Registration of the tool 'osc_upload_file' with its name, description, and inputSchema in the listOscTools function.
export function listOscTools() { return [ { name: 'osc_upload_file', description: 'Upload a file to Eyevinn Open Source Cloud Storage (OSC) Minio instance', inputSchema: zodToJsonSchema(UploadFileSchema) }, - src/index.ts:103-117 (registration)Top-level registration: listOscTools() provides the tool list via ListToolsRequestSchema, and handleOscToolRequest routes 'osc_' prefixed tool calls to the handler.
private setupToolHandlers(): void { this.server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: listOscTools() })); this.server.setRequestHandler(CallToolRequestSchema, async (request) => { if (request.params.name.startsWith('osc_')) { return await handleOscToolRequest(request, this.context); } else { throw new McpError( ErrorCode.InvalidRequest, `Unknown tool: ${request.params.name}` ); } });