Skip to main content
Glama

search-page

Search wiki page titles and contents using specific terms and retrieve matching results with a configurable limit for MediaWiki content.

Instructions

Search wiki page titles and contents for the provided search terms, and returns matching pages.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNoMaximum number of search results to return (1-100)
queryYesSearch terms

Implementation Reference

  • Main handler function that executes the tool: calls REST API /v1/search/page, handles errors, formats results using helper.
    async function handleSearchPageTool( query: string, limit?: number ): Promise< CallToolResult > { let data: MwRestApiSearchPageResponse; try { data = await makeRestGetRequest<MwRestApiSearchPageResponse>( '/v1/search/page', { q: query, ...( limit ? { limit: limit.toString() } : {} ) } ); } catch ( error ) { return { content: [ { type: 'text', text: `Failed to retrieve search data: ${ ( error as Error ).message }` } as TextContent ], isError: true }; } const pages = data.pages || []; if ( pages.length === 0 ) { return { content: [ { type: 'text', text: `No pages found for ${ query }` } as TextContent ] }; } return { content: pages.map( getSearchResultToolResult ) }; }
  • Tool registration function defining name 'search-page', description, input schema (query: string, limit?: number), annotations, and handler reference. Called from index.ts.
    export function searchPageTool( server: McpServer ): RegisteredTool { // TODO: Not having named parameters is a pain, // but using low-level Server type or using a wrapper function are addedd complexity return server.tool( 'search-page', 'Search wiki page titles and contents for the provided search terms, and returns matching pages.', { query: z.string().describe( 'Search terms' ), limit: z.number().int().min( 1 ).max( 100 ).optional().describe( 'Maximum number of search results to return' ) }, { title: 'Search page', readOnlyHint: true, destructiveHint: false } as ToolAnnotations, async ( { query, limit } ) => handleSearchPageTool( query, limit ) ); }
  • Helper to format each search result page into a text block with title, description, ID, URL, and thumbnail.
    function getSearchResultToolResult( result: MwRestApiSearchResultObject ): TextContent { const { server, articlepath } = wikiService.getCurrent().config; return { type: 'text', text: [ `Title: ${ result.title }`, `Description: ${ result.description ?? 'Not available' }`, `Page ID: ${ result.id }`, `Page URL: ${ `${ server }${ articlepath }/${ result.key }` }`, `Thumbnail URL: ${ result.thumbnail?.url ?? 'Not available' }` ].join( '\n' ) }; }
  • Imports and includes searchPageTool in the list of tool registrars for global registration via registerAllTools.
    import { searchPageTool } from './search-page.js'; import { setWikiTool } from './set-wiki.js'; import { addWikiTool } from './add-wiki.js'; import { removeWikiTool } from './remove-wiki.js'; import { updatePageTool } from './update-page.js'; import { getFileTool } from './get-file.js'; import { createPageTool } from './create-page.js'; import { uploadFileTool } from './upload-file.js'; 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,
  • Zod input schema definition for the tool: query (string), limit (optional number 1-100).
    query: z.string().describe( 'Search terms' ), limit: z.number().int().min( 1 ).max( 100 ).optional().describe( 'Maximum number of search results to return' ) },

Other Tools

Related 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