Skip to main content
Glama

Windows Automation MCP Server

browser_get_text

Extract text content from web page elements using CSS selectors for automated data collection and web scraping tasks.

Instructions

获取元素文本

Input Schema

NameRequiredDescriptionDefault
selectorYesCSS 选择器
sessionIdNo会话 ID(可选)

Input Schema (JSON Schema)

{ "properties": { "selector": { "description": "CSS 选择器", "type": "string" }, "sessionId": { "description": "会话 ID(可选)", "type": "string" } }, "required": [ "selector" ], "type": "object" }

Implementation Reference

  • The main execution logic for the browser_get_text tool. Waits for the selector, then uses page.$eval to extract and return the textContent of the element.
    async getText(selector, sessionId = 'default') { try { const page = this.pages.get(sessionId); if (!page) { return { success: false, error: '浏览器未启动' }; } await page.waitForSelector(selector, { timeout: 5000 }); const text = await page.$eval(selector, el => el.textContent); return { success: true, selector, text }; } catch (error) { return { success: false, error: error.message }; } }
  • Input schema and metadata definition for the browser_get_text tool, including required 'selector' parameter.
    { name: 'browser_get_text', description: '获取元素文本', inputSchema: { type: 'object', properties: { selector: { type: 'string', description: 'CSS 选择器' }, sessionId: { type: 'string', description: '会话 ID(可选)' }, }, required: ['selector'], }, },
  • Registration of browser_get_text in the canHandle method, used by the central dispatcher to route tool calls to this module.
    canHandle(toolName) { const tools = ['browser_launch', 'browser_navigate', 'browser_click', 'browser_type', 'browser_screenshot', 'browser_get_text', 'browser_close']; return tools.includes(toolName); }
  • Dispatch case in executeTool method that routes browser_get_text calls to the getText handler.
    case 'browser_get_text': return await this.getText(args.selector, args.sessionId);

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/eva-wanxin-git/windows-automation-mcp'

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