// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { maybeFilter } from 'chunkr-ai-mcp/filtering'; import { Metadata, asTextContentResult } from 'chunkr-ai-mcp/tools/types'; import { Tool } from '@modelcontextprotocol/sdk/types.js'; import Chunkr from 'chunkr-ai'; export const metadata: Metadata = { resource: 'files', operation: 'write', tags: [], httpMethod: 'post', httpPath: '/files', operationId: 'upload_file_route', }; export const tool: Tool = { name: 'create_files', description: "When using this tool, always use the `jq_filter` parameter to reduce the response size and improve performance.\n\nOnly omit if you're sure you don't need the data.\n\nAccepts multipart/form-data with fields:\n- file: binary (required)\n- file_metadata: string (optional, JSON string)\n\n# Response Schema\n```json\n{\n $ref: '#/$defs/file',\n $defs: {\n file: {\n type: 'object',\n description: 'Metadata describing an uploaded file in Chunkr.\\n\\nReturned by POST `/files` and GET `/files/{file_id}`.',\n properties: {\n content_type: {\n type: 'string',\n description: 'MIME type detected or provided for the file.'\n },\n created_at: {\n type: 'string',\n description: 'Timestamp when the file was created.',\n format: 'date-time'\n },\n file_id: {\n type: 'string',\n description: 'Unique identifier for the file.'\n },\n file_name: {\n type: 'string',\n description: 'The original filename supplied by the client.'\n },\n file_size: {\n type: 'integer',\n description: 'Size of the stored file in bytes.'\n },\n metadata: {\n type: 'object',\n description: 'Arbitrary JSON metadata associated with the file.',\n additionalProperties: true\n },\n url: {\n type: 'string',\n description: 'Permanent Chunkr URL. Use directly with other chunkr API requests.'\n }\n },\n required: [ 'content_type',\n 'created_at',\n 'file_id',\n 'file_name',\n 'file_size',\n 'metadata',\n 'url'\n ]\n }\n }\n}\n```", inputSchema: { type: 'object', properties: { file: { type: 'string', description: 'The file to upload', }, file_metadata: { type: 'string', description: 'Arbitrary JSON metadata associated with the file.', }, jq_filter: { type: 'string', title: 'jq Filter', description: 'A jq filter to apply to the response to include certain fields. Consult the output schema in the tool description to see the fields that are available.\n\nFor example: to include only the `name` field in every object of a results array, you can provide ".results[].name".\n\nFor more information, see the [jq documentation](https://jqlang.org/manual/).', }, }, required: ['file'], }, annotations: {}, }; export const handler = async (client: Chunkr, args: Record | undefined) => { const { jq_filter, ...body } = args as any; return asTextContentResult(await maybeFilter(jq_filter, await client.files.create(body))); }; export default { metadata, tool, handler };