Skip to main content
Glama
ProfessionalWiki

mediawiki-mcp-server

upload-file-from-url

Destructive

Upload files to a MediaWiki wiki directly from web URLs. Provide a URL, title, and wikitext to add files to the wiki without manual downloading and uploading.

Instructions

Uploads a file to the wiki from a web URL.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlYesURL of the file to upload
titleYesFile title
textYesWikitext on the file page
commentNoReason for uploading the file

Implementation Reference

  • Main execution logic for the 'upload-file-from-url' tool. Handles the upload via mwn.uploadFromUrl, specific error handling for disabled URL uploads, and returns success or error results.
    async function handleUploadFileFromUrlTool(
    	url: string, title: string, text: string, comment?: string
    ): Promise< CallToolResult > {
    
    	let data: ApiUploadResponse;
    	try {
    		const mwn = await getMwn();
    		data = await mwn.uploadFromUrl( url, title, text, getApiUploadParams( comment ) );
    	} catch ( error ) {
    		const errorMessage = ( error as Error ).message;
    
    		// Prevent the LLM from attempting to find an existing image on the wiki
    		// after failing to upload by URL.
    		if ( errorMessage.includes( 'copyuploaddisabled' ) ) {
    			return {
    				content: [
    					{
    						type: 'text',
    						text: 'Upload failed: Upload by URL is disabled for this wiki. Please download the image from the URL to the local disk first, then use the upload-file tool to upload it from the local file path.'
    					} as TextContent
    				],
    				isError: true
    			};
    		}
    
    		return {
    			content: [
    				{
    					type: 'text',
    					text: `Upload failed: ${ ( error as Error ).message }`
    				} as TextContent
    			],
    			isError: true
    		};
    	}
    
    	return {
    		content: uploadFileFromUrlToolResult( data )
    	};
    }
  • Registers the 'upload-file-from-url' tool with the MCP server, including name, description, input schema (Zod), annotations, and handler function reference. This also defines the schema.
    export function uploadFileFromUrlTool( server: McpServer ): RegisteredTool {
    	return server.tool(
    		'upload-file-from-url',
    		'Uploads a file to the wiki from a web URL.',
    		{
    			url: z.string().url().describe( 'URL of the file to upload' ),
    			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 from URL',
    			readOnlyHint: false,
    			destructiveHint: true
    		} as ToolAnnotations,
    		async (
    			{ url, title, text, comment }
    		) => handleUploadFileFromUrlTool( url, title, text, comment )
    	);
    }
  • Imports the uploadFileFromUrlTool registrar and includes it in the toolRegistrars array. The registerAllTools function iterates over registrars to register all tools including this one.
    import { uploadFileFromUrlTool } from './upload-file-from-url.js';
    import { deletePageTool } from './delete-page.js';
    import { getRevisionTool } from './get-revision.js';
    import { undeletePageTool } from './undelete-page.js';
    import { getCategoryMembersTool } from './get-category-members.js';
    import { searchPageByPrefixTool } from './search-page-by-prefix.js';
    
    const toolRegistrars = [
    	getPageTool,
    	getPageHistoryTool,
    	searchPageTool,
    	setWikiTool,
    	addWikiTool,
    	removeWikiTool,
    	updatePageTool,
    	getFileTool,
    	createPageTool,
    	uploadFileTool,
    	uploadFileFromUrlTool,
    	deletePageTool,
    	getRevisionTool,
    	undeletePageTool,
    	getCategoryMembersTool,
    	searchPageByPrefixTool
    ];
    
    export function registerAllTools( server: McpServer ): RegisteredTool[] {
    	const registeredTools: RegisteredTool[] = [];
    	for ( const registrar of toolRegistrars ) {
    		try {
    			registeredTools.push( registrar( server ) );
    		} catch ( error ) {
    			console.error( `Error registering tool: ${ ( error as Error ).message }` );
    		}
    	}
    	return registeredTools;
    }
  • Helper function to prepare API upload parameters, formatting the edit comment specifically for this tool.
    function getApiUploadParams( comment?: string ): ApiUploadParams {
    	return {
    		comment: formatEditComment( 'upload-file-from-url', comment )
    	};
    }
  • Helper function to format the successful upload response as an array of TextContent blocks.
    function uploadFileFromUrlToolResult( data: ApiUploadResponse ): TextContent[] {
    	const result: TextContent[] = [
    		{
    			type: 'text',
    			text: 'File uploaded successfully from URL'
    		}
    	];
    
    	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 indicate destructiveHint=true and readOnlyHint=false, covering safety aspects. The description adds context by specifying 'from a web URL', which clarifies the upload method, but does not detail behavioral traits like rate limits, file size restrictions, or authentication needs beyond annotations. No contradiction with annotations 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 front-loads the core action and resource. It wastes no words and directly communicates the tool's function without unnecessary elaboration, making it highly concise and well-structured.

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 complexity (destructive upload operation), lack of output schema, and rich annotations, the description is adequate but incomplete. It covers the basic purpose but misses details like return values, error conditions, or integration with sibling tools, leaving gaps for an AI agent to infer usage.

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 well-documented in the schema. The description adds no additional meaning beyond implying URL usage, but does not explain parameter interactions or usage nuances. With high schema coverage, the baseline score of 3 is appropriate as the description provides minimal extra value.

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 a file') and target resource ('to the wiki'), specifying the source ('from a web URL'). It distinguishes from sibling 'upload-file' by indicating URL-based upload, though not explicitly naming the alternative. The purpose is specific but could be more distinct.

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 like 'upload-file' or other file-related operations. It lacks context about prerequisites, such as URL accessibility or wiki permissions, and offers no exclusions or comparative advice with sibling tools.

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