Skip to main content
Glama

mp_getLogs

Retrieve console logs from WeChat Mini Program development tools to monitor runtime behavior and debug issues, with an option to clear logs after retrieval.

Instructions

获取小程序控制台日志。可选择在获取后清空日志。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
connectionNo
clearNo

Implementation Reference

  • The createGetConsoleLogsTool function defines the mp_getLogs tool, including its handler (execute function) which retrieves console logs from the manager, optionally clears them based on the 'clear' parameter, formats the logs into JSON with count and log details, and returns a text result.
    function createGetConsoleLogsTool(manager: WeappAutomatorManager): AnyTool { return { name: "mp_getLogs", description: "获取小程序控制台日志。可选择在获取后清空日志。", parameters: getConsoleLogsParameters, execute: async (rawArgs, context: ToolContext) => { const args = getConsoleLogsParameters.parse(rawArgs ?? {}); const logs = manager.getConsoleLogs(); if (args.clear) { manager.clearConsoleLogs(); } return toTextResult( formatJson({ count: logs.length, logs: logs.map(log => ({ type: log.type, message: log.message, timestamp: log.timestamp, data: log.data, })), }) ); }, }; }
  • Zod schema for mp_getLogs parameters: extends connectionContainerSchema with an optional 'clear' boolean (defaults to false).
    const getConsoleLogsParameters = connectionContainerSchema.extend({ clear: z.coerce.boolean().optional().default(false), });
  • Local registration of mp_getLogs within the createApplicationTools function's return array.
    return [ createEnsureConnectionTool(manager), createNavigateTool(manager), createScreenshotTool(manager), createCallWxMethodTool(manager), createGetConsoleLogsTool(manager), ];
  • src/tools.ts:7-13 (registration)
    Registration of application tools (including mp_getLogs) by spreading into the full tools list in createTools.
    export function createTools(manager: WeappAutomatorManager): AnyTool[] { return [ ...createApplicationTools(manager), ...createPageTools(manager), ...createElementTools(manager), ]; }
  • src/index.ts:17-17 (registration)
    Final MCP server registration by adding all tools (including mp_getLogs) via server.addTools.
    server.addTools(createTools(manager));

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/yfmeii/weapp-dev-mcp'

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