get-page
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
| Name | Required | Description | Default |
|---|---|---|---|
| title | Yes | Wiki page title | |
| content | No | Type of content to return | source |
| metadata | No | Whether to include metadata (page ID, revision info, size, section outline) in the response | |
| section | No | Section number (0 = lead; 1..N = heading sections). Narrows content to one section. |
Implementation Reference
- src/tools/get-page.ts:48-178 (handler)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); }, }; - src/tools/get-page.ts:9-31 (schema)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; - src/tools/get-page.ts:42-44 (registration)getPage is included in the standardTools array and registered via register() in registerAllTools().
idempotentHint: true, openWorldHint: true, } as ToolAnnotations, - src/tools/get-page.ts:33-47 (registration)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, - src/runtime/tool.ts:5-23 (helper)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>; }