Skip to main content
Glama

cls_get_log_context

Retrieve log context by fetching surrounding log entries before and after a specific log to understand full sequence when troubleshooting issues.

Instructions

获取日志上下文。根据一条日志的定位信息,查看其前后的日志记录,用于排查问题时了解完整的日志上下文。

参数说明

  • topic_id: 日志主题 ID(必填)

  • btime: 目标日志的时间(字符串),支持两种格式:

    1. 毫秒时间戳字符串(如 "1774537847429"):工具内部自动按 UTC+8 时区转换为所需格式,可直接使用 cls_search_log 返回的"时间(Time)"对应的毫秒时间戳

    2. UTC+8 时间字符串 YYYY-mm-dd HH:MM:SS.FFF(如 "2026-03-25 14:25:00.000"):需确保为 UTC+8 时区

  • pkg_id: 目标日志的包序号(从 cls_search_log 返回的 PkgId 字段获取)

  • pkg_log_id: 目标日志在包内的序号(从 cls_search_log 返回的 PkgLogId 字段获取)

  • prev_logs: 向前获取的日志条数,默认 10,最大 100

  • next_logs: 向后获取的日志条数,默认 10,最大 100

使用流程

  1. 先用 cls_search_log 查找目标日志

  2. 从结果中获取 PkgId、PkgLogId,以及"时间"对应的毫秒时间戳(或自行构造 UTC+8 时间字符串)

  3. 用这些信息调用本工具获取上下文

注意事项

  • btime 的时间字符串必须为 UTC+8 时区

  • 传入毫秒时间戳字符串时,工具会自动按 UTC+8 转换,无需手动处理时区

  • 毫秒精度会影响定位准确性,建议尽量使用精确的时间值

  • region: 地域(可选),如 ap-guangzhou、na-ashburn,不传则使用默认地域,可通过 cls_describe_regions 查询所有可用地域

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
topic_idYes
btimeYes
pkg_idYes
pkg_log_idYes
prev_logsNo
next_logsNo
regionNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes
Behavior4/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It effectively describes key behaviors: it's a read operation (获取/查看 - get/view), specifies constraints (prev_logs/next_logs defaults and maximums of 10/100), explains timezone handling (UTC+8 conversion for timestamps, must use UTC+8 for strings), mentions accuracy considerations (millisecond precision affects accuracy), and notes optional parameters with defaults. It doesn't cover rate limits or authentication needs, but provides substantial operational context.

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?

The description is well-structured with clear sections (purpose, parameter说明, 使用流程, 注意事项) and front-loaded purpose. It's appropriately sized for a 7-parameter tool with complex usage. Some sentences could be slightly tightened (e.g., the region note is a bit verbose), but overall it's efficient with minimal waste.

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?

Given the tool's complexity (7 parameters, 4 required, no schema descriptions, no annotations) and the presence of an output schema (which handles return values), the description is highly complete. It covers purpose, detailed parameter semantics, usage workflow, prerequisites, alternatives, constraints, and operational notes. The only minor gap is lack of explicit authentication/rate limit info, but this is compensated by the comprehensive parameter and usage guidance.

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

Parameters5/5

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

Schema description coverage is 0%, so the description must fully compensate. It provides detailed semantic information for all 7 parameters: explains required vs. optional, sources for values (e.g., from cls_search_log results), formats (two time string formats, integer IDs), defaults (prev_logs=10, next_logs=10, region=''), constraints (max 100), and practical usage notes (timezone handling, precision advice). This goes well beyond what the bare schema titles offer.

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 the tool's purpose: '获取日志上下文。根据一条日志的定位信息,查看其前后的日志记录,用于排查问题时了解完整的日志上下文' (Get log context. Based on a log's positioning information, view logs before and after it, used to understand the complete log context when troubleshooting problems). This is specific (verb: get/view, resource: log context), distinguishes it from siblings like cls_search_log (which finds logs) and cls_get_log_count (which counts logs), and explains the value (troubleshooting).

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

Usage Guidelines5/5

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

The description provides explicit guidance on when and how to use this tool versus alternatives. It specifies a clear workflow: '1. 先用 cls_search_log 查找目标日志 2. 从结果中获取... 3. 用这些信息调用本工具' (1. First use cls_search_log to find the target log 2. Get... from the results 3. Use this information to call this tool). It also mentions an alternative tool for region queries (cls_describe_regions) and clarifies that region is optional with a default.

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/Tinker-LGD2026/cls-mcp-server'

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