Skip to main content
Glama
ProfessionalWiki

mediawiki-mcp-server

upload-file

Destructive

Upload files from your local disk to a MediaWiki wiki with specified titles, wikitext, and upload comments.

Instructions

Uploads a file to the wiki from the local disk.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filepathYesFile path on the local disk
titleYesFile title
textYesWikitext on the file page
commentNoReason for uploading the file

Implementation Reference

  • The core handler function that performs the file upload to the wiki using mwn.upload, catches errors, and returns appropriate CallToolResult with content.
    async function handleUploadFileTool(
    	filepath: string, title: string, text: string, comment?: string
    ): Promise< CallToolResult > {
    
    	let data: ApiUploadResponse;
    	try {
    		const mwn = await getMwn();
    		data = await mwn.upload( filepath, title, text, getApiUploadParams( comment ) );
    	} catch ( error ) {
    		return {
    			content: [
    				{
    					type: 'text',
    					text: `Upload failed: ${ ( error as Error ).message }`
    				} as TextContent
    			],
    			isError: true
    		};
    	}
    
    	return {
    		content: uploadFileToolResult( data )
    	};
    }
  • Registers the 'upload-file' tool using server.tool, including input schema with zod validators, annotations, and attaches the handler function.
    export function uploadFileTool( server: McpServer ): RegisteredTool {
    	return server.tool(
    		'upload-file',
    		'Uploads a file to the wiki from the local disk.',
    		{
    			filepath: z.string().describe( 'File path on the local disk' ),
    			title: z.string().describe( 'File title' ),
    			text: z.string().describe( 'Wikitext on the file page' ),
    			comment: z.string().optional().describe( 'Reason for uploading the file' )
    		},
    		{
    			title: 'Upload file',
    			readOnlyHint: false,
    			destructiveHint: true
    		} as ToolAnnotations,
    		async (
    			{ filepath, title, text, comment }
    		) => handleUploadFileTool( filepath, title, text, comment )
    	);
    }
  • Includes the uploadFileTool registrar in the list of all tool registrars invoked by registerAllTools to register the tool with the MCP server.
    const toolRegistrars = [
    	getPageTool,
    	getPageHistoryTool,
    	searchPageTool,
    	setWikiTool,
    	addWikiTool,
    	removeWikiTool,
    	updatePageTool,
    	getFileTool,
    	createPageTool,
    	uploadFileTool,
    	uploadFileFromUrlTool,
    	deletePageTool,
    	getRevisionTool,
    	undeletePageTool,
    	getCategoryMembersTool,
    	searchPageByPrefixTool
    ];
  • Helper function to prepare API upload parameters, formatting the edit comment specifically for 'upload-file' tool.
    function getApiUploadParams( comment?: string ): ApiUploadParams {
    	return {
    		comment: formatEditComment( 'upload-file', comment )
    	};
    }
  • Helper function to format the successful upload response as TextContent array with success message and JSON details.
    function uploadFileToolResult( data: ApiUploadResponse ): TextContent[] {
    	const result: TextContent[] = [
    		{
    			type: 'text',
    			text: 'File uploaded successfully'
    		}
    	];
    
    	result.push( {
    		type: 'text',
    		text: `Upload details: ${ JSON.stringify( data, null, 2 ) }`
    	} );
    
    	return result;
    }
Behavior3/5

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

Annotations already indicate this is a destructive write operation (readOnlyHint: false, destructiveHint: true). The description adds context about the source ('from the local disk'), which isn't in annotations, but doesn't disclose additional behavioral traits like authentication requirements, file size limits, format restrictions, or what happens if a file with the same title exists.

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 states the core functionality without unnecessary words. It's front-loaded with the main action and resource, making it immediately clear what the tool does.

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

Completeness2/5

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

For a destructive write operation with 4 parameters and no output schema, the description is insufficient. It doesn't explain what the tool returns, error conditions, or important constraints (e.g., file formats, size limits). With annotations covering safety but no output schema, more context is needed for effective use.

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?

Schema description coverage is 100%, so parameters are fully documented in the schema. The description doesn't add any parameter-specific information beyond what's in the schema (e.g., explaining relationships between parameters or usage examples). Baseline 3 is appropriate since the schema handles parameter documentation.

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 action ('Uploads') and target resource ('a file to the wiki'), specifying the source ('from the local disk'). It distinguishes from sibling 'upload-file-from-url' by specifying local disk source, but doesn't explicitly contrast with other file/write operations like 'create-page' or 'add-wiki'.

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?

No guidance on when to use this tool versus alternatives is provided. The description doesn't mention prerequisites (e.g., file must exist locally), when to choose this over 'upload-file-from-url', or how it differs from other content creation tools like 'create-page' or 'add-wiki'.

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