Skip to main content
Glama
jomon003

PlayMCP Browser Automation Server

by jomon003

getPageTitle

Extract the title of the current webpage during automation tasks using Playwright in the PlayMCP server. Simplify web scraping, testing, and browser interactions by retrieving page titles programmatically.

Instructions

Get the title of the current page

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function in PlaywrightController that executes the tool logic: checks if browser is initialized, retrieves the page title using Playwright API, logs activity, and handles errors.
    async getPageTitle(): Promise<string> { try { if (!this.isInitialized()) { throw new Error('Browser not initialized'); } this.log('Getting page title'); const title = await this.state.page?.title(); this.log('Page title retrieved:', title); return title || ''; } catch (error: any) { console.error('Get page title error:', error); throw new BrowserError('Failed to get page title', 'Check if the page is loaded'); } }
  • Defines the Tool object including name, description, and input schema (no required parameters). This schema is used for MCP tool listing and validation.
    const GET_PAGE_TITLE_TOOL: Tool = { name: "getPageTitle", description: "Get the title of the current page", inputSchema: { type: "object", properties: {}, required: [] } };
  • src/server.ts:514-553 (registration)
    Registers the getPageTitle tool in the central tools map, which is provided to the MCP server capabilities for tool listing.
    const tools = { openBrowser: OPEN_BROWSER_TOOL, navigate: NAVIGATE_TOOL, type: TYPE_TOOL, click: CLICK_TOOL, moveMouse: MOVE_MOUSE_TOOL, scroll: SCROLL_TOOL, screenshot: SCREENSHOT_TOOL, getPageSource: GET_PAGE_SOURCE_TOOL, getPageText: GET_PAGE_TEXT_TOOL, getPageTitle: GET_PAGE_TITLE_TOOL, getPageUrl: GET_PAGE_URL_TOOL, getScripts: GET_SCRIPTS_TOOL, getStylesheets: GET_STYLESHEETS_TOOL, getMetaTags: GET_META_TAGS_TOOL, getLinks: GET_LINKS_TOOL, getImages: GET_IMAGES_TOOL, getForms: GET_FORMS_TOOL, getElementContent: GET_ELEMENT_CONTENT_TOOL, getElementHierarchy: GET_ELEMENT_HIERARCHY_TOOL, executeJavaScript: EXECUTE_JAVASCRIPT_TOOL, goForward: GO_FORWARD_TOOL, hover: HOVER_TOOL, dragAndDrop: DRAG_AND_DROP_TOOL, selectOption: SELECT_OPTION_TOOL, pressKey: PRESS_KEY_TOOL, waitForText: WAIT_FOR_TEXT_TOOL, waitForSelector: WAIT_FOR_SELECTOR_TOOL, resize: RESIZE_TOOL, handleDialog: HANDLE_DIALOG_TOOL, getConsoleMessages: GET_CONSOLE_MESSAGES_TOOL, getNetworkRequests: GET_NETWORK_REQUESTS_TOOL, uploadFiles: UPLOAD_FILES_TOOL, evaluateWithReturn: EVALUATE_WITH_RETURN_TOOL, takeScreenshot: TAKE_SCREENSHOT_TOOL, mouseMove: MOUSE_MOVE_TOOL, mouseClick: MOUSE_CLICK_TOOL, mouseDrag: MOUSE_DRAG_TOOL, closeBrowser: CLOSE_BROWSER_TOOL };
  • src/server.ts:693-698 (registration)
    In the callTool request handler, matches the tool name and delegates execution to playwrightController.getPageTitle(), returning the title as text content.
    case 'getPageTitle': { const title = await playwrightController.getPageTitle(); return { content: [{ type: "text", text: title }] }; }

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/jomon003/PlayMCP'

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