Skip to main content
Glama

mp_getLogs

Retrieve console logs from WeChat Mini Programs and optionally clear them after retrieval to maintain clean debugging environments.

Instructions

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
connectionNo
clearNo

Implementation Reference

  • The execute handler for mp_getLogs tool. Retrieves console logs from the manager, optionally clears them based on the 'clear' parameter, and returns a formatted JSON response with log count and details.
    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 defining the input parameters: extends connectionContainerSchema with an optional 'clear' boolean flag.
    const getConsoleLogsParameters = connectionContainerSchema.extend({ clear: z.coerce.boolean().optional().default(false), });
  • Local registration of the mp_getLogs tool within the createApplicationTools factory function, added to the array of application tools.
    return [ createEnsureConnectionTool(manager), createNavigateTool(manager), createScreenshotTool(manager), createCallWxMethodTool(manager), createGetConsoleLogsTool(manager), ];
  • src/tools.ts:7-12 (registration)
    Higher-level registration: createTools includes application tools (containing mp_getLogs).
    export function createTools(manager: WeappAutomatorManager): AnyTool[] { return [ ...createApplicationTools(manager), ...createPageTools(manager), ...createElementTools(manager), ];
  • src/index.ts:17-17 (registration)
    Final MCP server registration: all tools including mp_getLogs are added to the FastMCP server.
    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