Skip to main content
Glama

get-page

Read-onlyIdempotent

Retrieve a single wiki page as wikitext source, rendered HTML, or metadata. Specify title and optional section to narrow content. Include metadata for revision ID and page size.

Instructions

Returns a single wiki page (wikitext source, rendered HTML, or metadata only). If the title does not exist, an error is returned. Use metadata=true to retrieve the revision ID (for edit-conflict detection), page size, and section outline. Set content="none" to fetch only metadata. Large content is truncated at 50000 bytes by default with a trailing marker listing available sections; a follow-up call with section=N fetches a specific section. For more than one page at a time, use get-pages. For a specific historical revision, use get-revision.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
titleYesWiki page title
contentNoType of content to returnsource
metadataNoWhether to include metadata (page ID, revision info, size, section outline) in the response
sectionNoSection number (0 = lead; 1..N = heading sections). Narrows content to one section.

Implementation Reference

  • The handle function that executes the 'get-page' tool logic: fetches a wiki page (wikitext source, rendered HTML, or metadata only), handles sections, truncation, and returns formatted results.
    	async handle({ title, content, metadata, section }, ctx: ToolContext): Promise<CallToolResult> {
    		if (content === ContentFormat.none && !metadata) {
    			return ctx.format.invalidInput('When content is set to "none", metadata must be true');
    		}
    		if (section !== undefined && content === ContentFormat.none) {
    			return ctx.format.invalidInput('section is not compatible with content="none"');
    		}
    
    		const mwn = await ctx.mwn();
    
    		const payload: {
    			pageId?: number;
    			title?: string;
    			latestRevisionId?: number;
    			latestRevisionTimestamp?: string;
    			contentModel?: string;
    			size?: number;
    			url?: string;
    			sections?: string[];
    			source?: string;
    			html?: string;
    			truncation?: TruncationInfo;
    		} = {};
    
    		const needsReadCall =
    			metadata || content === ContentFormat.source || content === ContentFormat.none;
    		const needsSource = content === ContentFormat.source;
    
    		let sections: string[] | undefined;
    
    		if (needsReadCall) {
    			const rvprop = needsSource
    				? 'ids|timestamp|contentmodel|size|content'
    				: 'ids|timestamp|contentmodel|size';
    			const readParams: Record<string, string | number> = { rvprop };
    			if (needsSource && section !== undefined) {
    				readParams.rvsection = section;
    			}
    			const page = await mwn.read(title, readParams);
    
    			if (page.missing) {
    				return ctx.format.notFound(`Page "${title}" not found`);
    			}
    
    			const rev = page.revisions?.[0];
    
    			if (metadata) {
    				sections = await ctx.sections.list(mwn, title);
    			}
    
    			if (metadata || content === ContentFormat.none) {
    				payload.pageId = page.pageid;
    				payload.title = page.title;
    				payload.latestRevisionId = rev?.revid;
    				payload.latestRevisionTimestamp = rev?.timestamp;
    				payload.contentModel = rev?.contentmodel;
    				if (rev?.size !== undefined) {
    					payload.size = rev.size;
    				}
    				if (sections !== undefined) {
    					payload.sections = sections;
    				}
    				payload.url = getPageUrl(page.title, ctx.selection);
    			}
    
    			if (needsSource && rev?.content !== undefined) {
    				const truncated = truncateByBytes(rev.content);
    				payload.source = truncated.text;
    				if (truncated.truncated) {
    					if (sections === undefined) {
    						sections = await ctx.sections.list(mwn, title);
    					}
    					payload.truncation = {
    						reason: 'content-truncated',
    						returnedBytes: truncated.returnedBytes,
    						totalBytes: truncated.totalBytes,
    						itemNoun: 'wikitext',
    						toolName: 'get-page',
    						sections,
    						remedyHint: 'To read a specific section, call get-page again with section=N.',
    					};
    				}
    			}
    		}
    
    		if (content === ContentFormat.html) {
    			const parseParams: Record<string, string | number> = {
    				action: 'parse',
    				page: title,
    				prop: 'text',
    				formatversion: '2',
    			};
    			if (section !== undefined) {
    				parseParams.section = section;
    			}
    			const parseResult = await mwn.request(parseParams);
    			const html: string | undefined = parseResult.parse?.text;
    
    			if (html !== undefined) {
    				const truncated = truncateByBytes(html);
    				payload.html = truncated.text;
    
    				if (payload.title === undefined) {
    					const resolvedTitle: string = parseResult.parse?.title ?? title;
    					payload.title = resolvedTitle;
    					if (parseResult.parse?.pageid !== undefined) {
    						payload.pageId = parseResult.parse.pageid;
    					}
    					payload.url = getPageUrl(resolvedTitle, ctx.selection);
    				}
    
    				if (truncated.truncated) {
    					if (sections === undefined) {
    						sections = await ctx.sections.list(mwn, title);
    					}
    					payload.truncation = {
    						reason: 'content-truncated',
    						returnedBytes: truncated.returnedBytes,
    						totalBytes: truncated.totalBytes,
    						itemNoun: 'HTML',
    						toolName: 'get-page',
    						sections,
    						remedyHint: 'To read a specific section, call get-page again with section=N.',
    					};
    				}
    			}
    		}
    
    		return ctx.format.ok(payload);
    	},
    };
  • Input schema definition using Zod: title (string), content (ContentFormat enum, defaults to source), metadata (boolean, defaults to false), section (optional non-negative integer).
    const inputSchema = {
    	title: z.string().describe('Wiki page title'),
    	content: z
    		.nativeEnum(ContentFormat)
    		.optional()
    		.default(ContentFormat.source)
    		.describe('Type of content to return'),
    	metadata: z
    		.boolean()
    		.optional()
    		.default(false)
    		.describe(
    			'Whether to include metadata (page ID, revision info, size, section outline) in the response',
    		),
    	section: z
    		.number()
    		.int()
    		.nonnegative()
    		.optional()
    		.describe(
    			'Section number (0 = lead; 1..N = heading sections). Narrows content to one section.',
    		),
    } as const;
  • getPage is included in the standardTools array and registered via register() in registerAllTools().
    	idempotentHint: true,
    	openWorldHint: true,
    } as ToolAnnotations,
  • Tool definition object with name 'get-page', description, inputSchema, annotations, failureVerb, and target extractor.
    export const getPage: Tool<typeof inputSchema> = {
    	name: 'get-page',
    	description:
    		'Returns a single wiki page (wikitext source, rendered HTML, or metadata only). If the title does not exist, an error is returned. Use metadata=true to retrieve the revision ID (for edit-conflict detection), page size, and section outline. Set content="none" to fetch only metadata. Large content is truncated at 50000 bytes by default with a trailing marker listing available sections; a follow-up call with section=N fetches a specific section. For more than one page at a time, use get-pages. For a specific historical revision, use get-revision.',
    	inputSchema,
    	annotations: {
    		title: 'Get page',
    		readOnlyHint: true,
    		destructiveHint: false,
    		idempotentHint: true,
    		openWorldHint: true,
    	} as ToolAnnotations,
    	failureVerb: 'retrieve page data',
    	target: (a) => a.title,
  • The Tool interface that defines the shape of a tool object including name, description, inputSchema, annotations, and handle method.
    export interface Tool<TSchema extends ZodRawShape, TCtx extends ToolContext = ToolContext> {
    	readonly name: string;
    	readonly description: string;
    	readonly inputSchema: TSchema;
    	readonly annotations: ToolAnnotations;
    	/**
    	 * Verb phrase used by the dispatcher to wrap raw upstream errors as
    	 * "Failed to <verb>: <message>". Falls back to `name` if omitted.
    	 */
    	readonly failureVerb?: string;
    	/**
    	 * Extracts a single identifier from the tool's input args (typically a page
    	 * title, search query, or URL) for the `target` field of the `tool_call`
    	 * telemetry event. Omitted for tools that don't have a single canonical
    	 * subject (e.g. get-pages, compare-pages, set-wiki).
    	 */
    	readonly target?: (args: z.infer<z.ZodObject<TSchema>>) => string;
    	readonly handle: (args: z.infer<z.ZodObject<TSchema>>, ctx: TCtx) => Promise<CallToolResult>;
    }
Behavior5/5

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

Discloses key behaviors: error on non-existent title, large content truncation at 50000 bytes with a trailing marker, and the ability to fetch a section via follow-up call. Annotations already indicate read-only and idempotent, and description adds these behavioral details.

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 well-structured: starts with the core purpose, then lists options and edge cases. Every sentence provides necessary information without redundancy.

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

Completeness5/5

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

Given the lack of output schema, the description adequately explains return types (source, html, metadata) and addresses truncation and section retrieval. It references sibling tools for multi-page and revision queries, providing full context for usage.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Though schema coverage is 100%, the description adds value by explaining the meaning of metadata (revision ID, size, outline) and content='none' (fetch only metadata), and how the section parameter works for truncated content.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool returns a single wiki page with configurable content type and metadata. It distinguishes itself from sibling tools get-pages (multiple pages) and get-revision (historical revision).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicitly guides when to use alternatives: 'For more than one page at a time, use get-pages. For a specific historical revision, use get-revision.' Also explains when to set metadata=true and content='none'.

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