Skip to main content
Glama
carloshpdoc

memorydetective

Run an XCTest unit-test bundle with leak detection (CI-runnable)

detectLeaksInXCTest

Detects new retain cycles in XCTest unit tests by diffing before and after .memgraph snapshots, failing when cycles appear outside the allowlist.

Instructions

[mg.ci] Sibling to detectLeaksInXCUITest, targeting XCTest unit-test schemes. Build for testing, launch the test bundle with an optional -only-testing:<TestTarget>/<TestClass>[/<testMethod>] filter, poll for the runner process (xctest by default, configurable via processName for app-hosted test bundles), capture a baseline .memgraph once the runner appears, run the test to completion, capture an after .memgraph, and diff. Returns passed: false when new ROOT CYCLE blocks appear that are not in the allowlistPatterns list. Per-test granularity: call once per test method with different testCaseFilter values; aggregation is the caller's responsibility, keeping the response tied to a single, well-defined before/after pair. If the runner exits before the after-capture window (common for fast unit tests with no host), the response carries an explicit failureReason pointing at the tearDown workaround. Designed for CI gating: non-zero exit code on failure.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
workspaceNoPath to the `.xcworkspace`. Mutually exclusive with `project`.
projectNoPath to the `.xcodeproj`. Mutually exclusive with `workspace`.
schemeYesXcode scheme that builds and runs the XCTest unit-test target.
destinationNoxcodebuild destination string. Default targets the most common iOS Simulator profile.platform=iOS Simulator,name=iPhone 11,OS=latest
testCaseFilterNoOptional `-only-testing` filter in `<TestTarget>/<TestClass>` or `<TestTarget>/<TestClass>/<testMethod>` form. Omit to run every test in the scheme (slower; produces one before/after pair for the entire run).
processNameNoProcess name to attach `leaks` against. `xctest` is the default unit-test runner on the simulator. If your tests are hosted in an app, pass the host app's process name instead (the same value `pgrep -x` would match).xctest
outputDirNoDirectory where the baseline + after `.memgraph` snapshots are written./tmp/memorydetective-xctest
allowlistPatternsNoSubstrings of class names that are allowed to leak. Cycles whose root class contains any of these substrings will not fail the run.
skipBuildNoSkip the `build-for-testing` step (faster on CI when the build is cached).
runnerStartTimeoutMsNoHow long to wait for the test runner process to appear under `pgrep -x <processName>` before giving up. Default 5 minutes.
outputHtmlPathNoAbsolute path to write a self-contained HTML report (inline CSS, no external assets). When set, the response also gains an `htmlReportPath` field pointing at the same file. Designed for CI artifact upload + PR-comment attachment.
Behavior5/5

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

With no annotations, the description fully discloses the tool's behavior: it builds for testing, launches with optional filter, polls for runner process, captures two memgraphs, diffs them, and returns false on new root cycles. It also details edge cases (early runner exit, allowlistPatterns, exit codes) and explains the processName parameter for app-hosted test bundles.

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 and front-loaded with the sibling relationship and target. Every sentence contributes value, though it is somewhat lengthy. It could be slightly more concise, but overall it efficiently conveys necessary information.

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?

Despite lacking an output schema, the description explains the return behavior (passed: false, failureReason, htmlReportPath) and exit code. It covers edge cases, per-test granularity, and caller responsibilities. Given the tool's complexity (11 parameters, many behavioral nuances), the description is remarkably complete.

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

Parameters3/5

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

Schema description coverage is 100%, so the baseline is 3. The description does not add substantial new meaning beyond the schema descriptions; it contextualizes testCaseFilter for per-test usage and mentions processName customization, but these are already covered in the schema. No parameters lack explanation.

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 runs XCTest unit-test bundles with leak detection, identifies itself as a sibling to detectLeaksInXCUITest, and explains the process (build, launch, capture memgraphs, diff). It distinguishes itself by targeting XCTest unit-test schemes rather than UI tests.

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?

The description provides clear usage context: designed for CI gating, per-test granularity via testCaseFilter, aggregation responsibility on caller, and notes about fast unit tests with early runner exit. While it doesn't explicitly list when not to use or provide alternatives beyond the sibling mention, the guidance is sufficient for effective use.

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/carloshpdoc/memorydetective'

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