Skip to main content
Glama

Selenium MCP Server

by themindmod
getPageSourceTool.ts1.02 kB
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { getWebDriver } from "../services/seleniumService.js"; /** * Registers the selenium_getPageSource tool with the MCP server. */ export function registerGetPageSourceTool(server: McpServer): void { const description = "Retrieves the full HTML source code of the current page in the browser."; server.tool( 'selenium_getPageSource', description, async () => { const driver = getWebDriver(); try { console.log('Getting page source...'); const pageSource = await driver.getPageSource(); console.log('Successfully retrieved page source.'); return { content: [ { type: "text", text: pageSource, }, ] }; } catch (error: any) { console.error(`Error getting page source:`, error); throw new Error(`Failed to get page source. Error: ${error.message || 'Unknown error'}`); } } ); }

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/themindmod/selenium-mcp-server'

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