// 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: 'read', tags: [], httpMethod: 'get', httpPath: '/files/{file_id}', operationId: 'get_file_route', }; export const tool: Tool = { name: 'get_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\nReturns metadata for a file owned by the authenticated user.\nThe response includes a permanent `ch://files/{file_id}` URL,\nfile name, content type, size, user-provided metadata, and timestamps.\n\nIf the file is not found or the user is not authorized, the response will be 401 Unauthorized.\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_id: { type: 'string', }, 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_id'], }, annotations: { readOnlyHint: true, }, }; export const handler = async (client: Chunkr, args: Record | undefined) => { const { file_id, jq_filter, ...body } = args as any; return asTextContentResult(await maybeFilter(jq_filter, await client.files.get(file_id))); }; export default { metadata, tool, handler };