Skip to main content
Glama
ProfessionalWiki

mediawiki-mcp-server

get-category-members

Read-only

Retrieve page IDs, namespaces, and titles for all members in a MediaWiki category, with filtering options for file types, pages, and subcategories.

Instructions

Gets all members in the category. Returns only page IDs, namespaces, and titles.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
categoryYesCategory name
typesNoTypes of members to include
namespacesNoNamespace IDs to filter by

Implementation Reference

  • The main handler function that fetches category members using the mwn library, applies filters, handles errors, and maps results using the helper.
    async function handleGetCategoryMembersTool(
    	category: string, types?: CategoryMemberType[], namespaces?: number[]
    ): Promise< CallToolResult > {
    	let data: ApiPageInfo[];
    	try {
    		const mwn = await getMwn();
    		const mwnCategory = new mwn.Category( category );
    
    		const options: ApiQueryCategoryMembersParams = {};
    
    		if ( types ) {
    			options.cmtype = types;
    		}
    
    		if ( namespaces ) {
    			options.cmnamespace = namespaces;
    		}
    
    		data = await mwnCategory.members( options );
    	} catch ( error ) {
    		return {
    			content: [
    				{
    					type: 'text',
    					text: `Get category members failed: ${ ( error as Error ).message }`
    				} as TextContent
    			],
    			isError: true
    		};
    	}
    
    	return {
    		content: data.map( getCategoryMembersToolResult )
    	};
    }
  • Tool registrar function that calls server.tool() to register 'get-category-members' with description, input schema using Zod, annotations, and references the handler.
    export function getCategoryMembersTool( server: McpServer ): RegisteredTool {
    	return server.tool(
    		'get-category-members',
    		'Gets all members in the category. Returns only page IDs, namespaces, and titles.',
    		{
    			category: z.string().describe( 'Category name' ),
    			types: z.array( z.nativeEnum( CategoryMemberType ) ).optional().describe( 'Types of members to include' ),
    			namespaces: z.array( z.number().int().nonnegative() ).optional().describe( 'Namespace IDs to filter by' )
    		},
    		{
    			title: 'Get category members',
    			readOnlyHint: true,
    			destructiveHint: false
    		} as ToolAnnotations,
    		async (
    			{ category, types, namespaces }
    		) => handleGetCategoryMembersTool( category, types, namespaces )
    	);
    }
  • Helper function that formats a single category member (ApiPageInfo) into a structured TextContent block for the tool response.
    function getCategoryMembersToolResult( result: ApiPageInfo ): TextContent {
    	return {
    		type: 'text',
    		text: [
    			`Page ID: ${ result.pageid }`,
    			`Namespace: ${ result.ns }`,
    			`Title: ${ result.title }`
    		].join( '\n' )
    	};
    }
  • Enum used in the input schema to specify types of category members (file, page, subcat).
    enum CategoryMemberType {
    	file = 'file',
    	page = 'page',
    	subcat = 'subcat'
    }
  • Imports the tool registrar and adds it to the list of tool registrars called by registerAllTools(server).
    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,
Behavior3/5

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

Annotations already declare readOnlyHint=true and destructiveHint=false, indicating a safe read operation. The description adds value by specifying the return format ('page IDs, namespaces, and titles'), which isn't covered by annotations. However, it lacks details on pagination, error handling, or rate limits, leaving behavioral 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 and return values. Every word earns its place, with no redundancy or unnecessary elaboration, making it easy for an agent to parse quickly.

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 moderate complexity (3 parameters, no output schema) and rich annotations, the description is adequate but incomplete. It specifies the return format, which helps, but doesn't cover error cases or performance implications, leaving room for improvement in guiding the agent effectively.

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 doesn't add meaning beyond the schema, such as explaining how 'types' or 'namespaces' affect filtering. With high schema coverage, the baseline score of 3 is appropriate as the description doesn't compensate with extra insights.

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 verb 'Gets' and the resource 'all members in the category', specifying what the tool does. However, it doesn't explicitly differentiate from sibling tools like 'get-page' or 'search-page', which might also retrieve page information but through different mechanisms.

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 'search-page' or 'get-page'. It doesn't mention prerequisites, such as needing a valid category name, or exclusions, leaving the agent to infer usage from context alone.

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