// 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}/url', operationId: 'get_file_url_route', }; export const tool: Tool = { name: 'url_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 a presigned download URL by default. If `base64_urls=true`, returns\nbase64-encoded file content. Control expiry with `expires_in` (seconds).\n\n# Response Schema\n```json\n{\n $ref: '#/$defs/file_url',\n $defs: {\n file_url: {\n type: 'object',\n properties: {\n url: {\n type: 'string',\n description: 'The presigned URL or base64 data (if base64_urls=true)'\n },\n expires_in: {\n type: 'integer',\n description: 'Expiry in seconds (omitted when base64)'\n }\n },\n required: [ 'url'\n ]\n }\n }\n}\n```", inputSchema: { type: 'object', properties: { file_id: { type: 'string', }, base64_urls: { type: 'boolean', description: 'If true, returns base64 data instead of a presigned URL', }, expires_in: { type: 'integer', description: 'Expiry in seconds for the presigned URL (default 3600)', }, 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.url(file_id, body))); }; export default { metadata, tool, handler };