Skip to main content
Glama
returnFile.tools.ts1.6 kB
import { z } from 'zod' import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js' import { returnFile } from '../functions/returnFile.js' import { ReturnFileResponse } from '../types.js' export function registerReturnFileTool(server: McpServer) { server.tool( 'get-file-download-link', 'Retrieves a direct download link for a specific file in the client’s Google Drive. This is typically used after identifying the desired file to provide access for download or online viewing.', { fileId: z .string() .describe('The ID of the file to retrieve the download link for'), }, async ({ fileId }) => { try { const response: ReturnFileResponse = await returnFile(fileId) if (response?.success) { return { content: [ { type: 'text', text: `Download **${response.file?.name}**:\n${response.file?.downloadLink}\n\nView Online:\n${response.file?.viewLink}`, }, ], } } else { return { content: [ { type: 'text', text: response.message || 'Failed to retrieve the file download link.', }, ], isError: true, } } } catch (error) { return { content: [ { type: 'text', text: `Error retrieving file download link: ${error}`, }, ], isError: true, } } } ) }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/michaelpine25/googleDriveMCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server