Skip to main content
Glama

get-category-members

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,

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