Skip to main content
Glama

mp_getLogs

Fetch and filter console logs from the connected mini program. Use clear=true to reset buffer before an operation, then read to capture only the new logs.

Instructions

读取当前连接目标的小程序控制台日志,支持过滤。不同项目 / wsEndpoint 的持久化日志会隔离,不会混读或互相清空。常见用法:操作前用 clear=true 清空当前目标缓冲,操作后再读以拿到本次产生的日志。

过滤参数:

  • contains:子串匹配(对 message + 序列化后的 data 一起匹配,非正则)。

  • type:按级别过滤,枚举 log/info/warn/error/exception(exception 是未捕获异常,区别于 console.error)。

  • since:相对时间窗口,单位毫秒 —— 只返回过去 N ms 内的日志(不是绝对时间戳)。

  • limit:最多返回条数,默认 100,取最新的 N 条

返回 {count, totalCount, logs[], filters, listenerAttached...}:count 是过滤后条数,totalCount 是当前目标缓冲区总条数(count<totalCount 说明被 limit/过滤截断)。listenerAttached=false 说明日志监听没挂上,可能漏日志,需 mp_recoverConnection。clear=true 只清空当前连接目标的缓冲。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
typeNo
clearNo
limitNo
sinceNo
containsNo
maxBytesNo
connectionNo可选连接覆盖(不传则用默认会话)。可用字段:mode(launch|connect)、cliPath、projectPath、wsEndpoint、timeout、port(【自动化端口】→ cli auto --auto-port,默认 9420;不是 IDE HTTP 服务端口,别把 IDE 服务端口传进来)、account、ticket、trustProject、args、cwd、autoClose、autoLaunch、launchTimeout、connectTimeout。
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Despite no annotations, the description discloses isolation by project/wsEndpoint, clear behavior (only current buffer), return fields with meaning of count/totalCount, and the listenerAttached flag indicating potential log loss. This is comprehensive.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Well-structured with purpose, usage, parameter details, and return format. Slightly verbose but all information is valuable and front-loaded.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Covers purpose, parameters, usage, return object, and edge cases (listenerAttached). No output schema exists, but return values are described. Complete for the tool's complexity.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is low (14%), but the description explains all parameters in detail: contains substring matching, type enum values, since as relative ms, limit defaults, clear behavior, and connection object. Adds significant meaning beyond schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states it reads applet console logs with filtering support. It is distinct from sibling tools, which are primarily for element or page interactions.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Provides a common usage pattern (clear buffer before operation, read after). Does not explicitly state when not to use, but given it is the only log-reading tool, the context is clear.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/Chaixueyuan/weapp-agent-mcp'

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