Skip to main content
Glama
ProfessionalWiki

mediawiki-mcp-server

get-file

Read-only

Retrieve file information and download links from MediaWiki, including thumbnail, preview, and original formats, by providing the file title.

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 get-file tool logic: fetches file information via REST API using the provided title, handles errors, and formats the response.
    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 )
    	};
    }
  • Registers the 'get-file' tool with the MCP server, including name, description, input schema (title: string), annotations, and references the handler function.
    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 )
    	);
    }
  • Helper function that converts the raw file data into a formatted text content array for the tool response.
    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' )
    		}
    	];
    }
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already declare readOnlyHint=true and destructiveHint=false, indicating this is a safe read operation. The description adds useful context by specifying the types of download links returned (thumbnail, preview, original), which is not covered by annotations. However, it does not disclose other behavioral traits like error conditions, rate limits, or authentication needs, leaving some gaps.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads the core action ('Returns information about a file') and adds specific details about download links. There is no wasted text, and every part of the sentence contributes to understanding the tool's functionality.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's low complexity (1 parameter, no output schema) and good annotations, the description is adequate but incomplete. It covers the basic purpose and output details but lacks usage guidelines, error handling, or integration with sibling tools. For a read-only tool in a wiki context, more contextual information would be beneficial.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% description coverage, with the 'title' parameter documented as 'File title'. The description does not add any meaning beyond this schema, such as clarifying the format or constraints of the title. With high schema coverage, the baseline score of 3 is appropriate, as the description does not compensate but also does not detract.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with a specific verb ('Returns') and resource ('information about a file'), including what information is returned (download links for thumbnail, preview, and original formats). However, it does not explicitly differentiate this tool from sibling tools like 'get-page' or 'get-revision', which might also retrieve file-related information in a wiki context.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It does not mention sibling tools like 'get-page' or 'upload-file', nor does it specify prerequisites or exclusions (e.g., whether the file must exist or be accessible). Usage is implied only through the tool name and description, with no explicit context.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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