Skip to main content
Glama

get-file

Fetch file details and download links, including thumbnail, preview, and original formats, by providing the file title using this MCP server tool for MediaWiki.

Instructions

Returns information about a file, including links to download the file in thumbnail, preview, and original formats.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
titleYesFile title

Implementation Reference

  • The handler function that executes the tool logic: makes a REST GET request to /v1/file/{title}, handles errors, and formats the response using getFileToolResult.
    async function handleGetFileTool( title: string ): Promise< CallToolResult > { let data: MwRestApiFileObject; try { data = await makeRestGetRequest<MwRestApiFileObject>( `/v1/file/${ encodeURIComponent( title ) }` ); } catch ( error ) { return { content: [ { type: 'text', text: `Failed to retrieve file data: ${ ( error as Error ).message }` } as TextContent ], isError: true }; } return { content: getFileToolResult( data ) }; }
  • The registration function for the 'get-file' tool, called from src/tools/index.ts. It uses server.tool to register the tool with name, description, input schema, annotations, and points to the handler.
    export function getFileTool( server: McpServer ): RegisteredTool { return server.tool( 'get-file', 'Returns information about a file, including links to download the file in thumbnail, preview, and original formats.', { title: z.string().describe( 'File title' ) }, { title: 'Get file', readOnlyHint: true, destructiveHint: false } as ToolAnnotations, async ( { title } ) => handleGetFileTool( title ) ); }
  • Input schema definition using Zod: requires a 'title' string parameter.
    title: z.string().describe( 'File title' ) },
  • Helper function that formats the retrieved MwRestApiFileObject into a text response with key file information.
    function getFileToolResult( result: MwRestApiFileObject ): TextContent[] { return [ { type: 'text', text: [ `File title: ${ result.title }`, `File description URL: ${ result.file_description_url }`, `Latest revision timestamp: ${ result.latest.timestamp }`, `Latest revision user: ${ result.latest.user.name }`, `Preferred URL: ${ result.preferred.url }`, `Original URL: ${ result.original.url }`, `Thumbnail URL: ${ result.thumbnail?.url }` ].join( '\n' ) } ]; }

Other Tools

Related Tools

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/ProfessionalWiki/MediaWiki-MCP-Server'

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