Skip to main content
Glama
aws-powertools

Powertools MCP Search Server

fetch_doc_page

Retrieve detailed AWS Lambda Powertools documentation in markdown format by fetching a specific page URL obtained from search_docs. Use to access in-depth explanations of features or functions.

Instructions

Fetches the content of a Powertools documentation page and returns it as markdown. This allows you to read the full documentation for a specific feature or function. You MUST use the url returned form the search_docs tool since this will be the page to load.The URL must be from the docs.powertools.aws.dev domain. Use this after finding relevant pages with search_docs to get detailed information.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlYes

Implementation Reference

  • The main handler function for the 'fetch_doc_page' tool. It takes a URL, fetches the documentation page content using `fetchWithCache`, logs the operation, handles errors, and returns a `CallToolResult`.
    const tool = async (props: ToolProps): Promise<CallToolResult> => {
      const { url } = props;
      logger.appendKeys({ tool: toolName });
      logger.appendKeys({ url: url.toString() });
    
      try {
        return buildResponse({
          content: await fetchWithCache({ url, contentType: 'text/markdown' }),
        });
      } catch (error) {
        return buildResponse({
          content: `${(error as Error).message}`,
          isError: true,
        });
        /* v8 ignore start */
      } finally {
        /* v8 ignore stop */
        logger.removeKeys(['tool', 'url']);
      }
    };
  • Zod schema for input validation and transformation of the URL parameter, ensuring it matches allowed domains, runtimes, and versions, and appending '/index.md'.
    const schema = {
      url: z
        .string()
        .url()
        .refine((url) => {
          const parsedUrl = new URL(url);
          if (parsedUrl.hostname !== ALLOWED_DOMAIN) {
            return false;
          }
          const pathParts = parsedUrl.pathname.split('/').filter(Boolean);
          const runtime = pathParts[1];
          if (!runtimes.includes(runtime as (typeof runtimes)[number])) {
            return false;
          }
          if (
            runtime === 'typescript' ||
            runtime === 'python' ||
            runtime === 'java'
          ) {
            const version = pathParts[2];
            const isValidSemver = /^\d+\.\d+\.\d+$/.test(version);
            const isLatest = version === 'latest';
            if (isValidSemver === false && isLatest === false) {
              return false;
            }
          }
    
          return true;
        })
        .transform((url) => {
          const parsedUrl = new URL(url);
          parsedUrl.pathname = parsedUrl.pathname.replace(/\/$/, '');
          parsedUrl.pathname = `${parsedUrl.pathname}/index.md`;
          return parsedUrl;
        }),
    };
  • src/server.ts:30-35 (registration)
    Registration of the 'fetch_doc_page' tool with the MCP server using `server.tool()`, providing name, description, input schema, and handler.
    server.tool(
      fetchDocPageName,
      fetchDocPageDescription,
      fetchDocPageInputSchema,
      fetchDocPage
    );
  • Constants defining the tool name 'fetch_doc_page' and its description.
    const name = 'fetch_doc_page' as const;
    const description =
      'Fetches the content of a Powertools documentation page and returns it as markdown.' +
      'Use this after finding relevant pages with search_docs to get detailed information.';
    
    export { name, description };
Install Server

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/aws-powertools/powertools-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server