Tool: get-logs
Relevant source files
The following files were used as context for generating this wiki page:
The get-logs tool is a core component of the uLoopMCP ecosystem, designed to retrieve log information from the Unity Editor's console. It plays a crucial role in enabling autonomous development loops by allowing AI agents to inspect logs for errors, warnings, and other diagnostic information. This facilitates automated debugging workflows where an AI can compile code, run tests, analyze the resulting logs with get-logs, and then attempt to fix any identified issues.
The tool provides powerful filtering and search capabilities, including filtering by log type, full-text search with regular expression support, and the ability to search within stack traces. This allows for precise and context-aware log retrieval, minimizing the amount of data sent to the LLM and focusing on the most relevant information. It is accessible via the MCP server for LLM tools and directly through the uloop command-line interface.
Sources: README.md:21-25, README.md:88-91, TOOL_REFERENCE.md:31-32
Architecture and Data Flow
The get-logs tool operates through a multi-layered architecture, starting from the client (LLM Tool or CLI), passing through the TypeScript MCP server, and finally reaching the Unity Editor for execution.
The following diagram illustrates the typical sequence of a get-logs request:
This diagram shows the flow of a get-logs request from the client to the Unity backend and back.
Sources: TypeScriptServer~/README.md:33-35, Packages/src/Editor/Api/McpTools/GetLogs/GetLogsTool.cs:22-26, Packages/src/Editor/Core/CoreTools/ConsoleUtility/ConsoleLogRetriever.cs:21-22
Key Components
GetLogsTool.cs: The main entry point for the tool within the Unity MCP framework. It inherits fromAbstractUnityTooland is responsible for parsing the incoming request parameters, invoking theConsoleLogRetriever, and formatting the response.ConsoleLogRetriever.cs: This class contains the core logic for accessing Unity's internal log entries. It handles the actual filtering, searching, and retrieval of logs from the editor.GetLogsSchema.cs/TOOL_REFERENCE.md: Defines the input parameters for the tool, such asLogType,MaxCount, andSearchText.GetLogsResponse.cs/TOOL_REFERENCE.md: Defines the structure of the data returned by the tool, including log counts and the array of log entries.
Sources: Packages/src/Editor/Api/McpTools/GetLogs/GetLogsTool.cs, Packages/src/Editor/Core/CoreTools/ConsoleUtility/ConsoleLogRetriever.cs, TOOL_REFERENCE.md:31-53
Parameters
The get-logs tool accepts several parameters to filter and customize the log output.
| Parameter | Type | Description | Default |
|---|---|---|---|
LogType | enum | Log type to filter: "Error", "Warning", "Log", "All". | "All" |
MaxCount | number | Maximum number of logs to retrieve (latest logs are returned). | 100 |
SearchText | string | Text to search for within log messages. | "" |
UseRegex | boolean | If true, SearchText is treated as a regular expression. | false |
SearchInStackTrace | boolean | If true, the search also includes the stack trace content. | false |
IncludeStackTrace | boolean | If true, the response includes the stack trace for each log. | true |
Sources: TOOL_REFERENCE.md:33-41, README.md:92-95
Response Structure
The tool returns a JSON object containing metadata about the query and the retrieved logs.
| Field | Type | Description |
|---|---|---|
TotalCount | number | The total number of logs available in the console before filtering. |
DisplayedCount | number | The number of logs included in the response. |
LogType | string | The LogType filter that was used for the request. |
MaxCount | number | The MaxCount limit that was used. |
SearchText | string | The SearchText filter that was used. |
IncludeStackTrace | boolean | Whether stack traces were included in the Logs array. |
Logs | array | An array of log entry objects. |
Logs[].Type | string | The type of the log entry ("Error", "Warning", "Log"). |
Logs[].Message | string | The main message content of the log entry. |
Logs[].StackTrace | string | The stack trace, if IncludeStackTrace was true. |
Sources: TOOL_REFERENCE.md:42-53
Advanced Search
The tool offers advanced search features to help pinpoint specific issues efficiently.
- Regular Expression Support: By setting
UseRegex: true, theSearchTextparameter is interpreted as a regular expression, enabling complex pattern matching. For example,SearchText: "(?i).*error.*"can be used for a case-insensitive search for the word "error". - Stack Trace Search: Setting
SearchInStackTrace: trueextends the search to the content of stack traces. This is useful for finding logs related to specific methods or classes, e.g.,SearchText: "MyClass".
Sources: README.md:93-95, TOOL_REFERENCE.md:37-39
CLI Usage
The get-logs tool can be invoked directly from the command line using the uloop CLI. This is useful for manual debugging or scripting.
# Get the 10 most recent logs of any type
uloop get-logs --max-count 10
# Get all logs of type 'Error'
uloop get-logs --log-type Error
# Search for logs containing a specific string
uloop get-logs --search-text "LogGetter test complete"
The CLI is tested in end-to-end tests, which provide further examples of its usage. For instance, tests verify that --max-count and --log-type flags work as expected.
Sources: README.md:409-412, Packages/src/Cli~/src/tests/cli-e2e.test.ts:100-153
Skill Integration
For integration with LLM tools like Claude Code, get-logs is exposed as a "Skill". This allows the AI to discover and use the tool automatically when it needs to inspect logs. The skill is defined in SKILL.md and is named /uloop-get-logs.
The skill definition provides the LLM with the name and a description of when to use the tool.
---
name: uloop-get-logs
description: Get logs from the Unity console. Use this to check for errors, warnings, or other output after running a command like compile or run-tests.
---
This integration is a key part of the autonomous development loop, as it allows an instruction like "Run the tests and tell me why they failed" to be automatically translated into a sequence of run-tests followed by get-logs.
Sources: Packages/src/Editor/Api/McpTools/GetLogs/SKILL.md:1-4, README.md:369-373