Skip to main content
Glama
carloshpdoc

memorydetective

Regex-search a Swift file (no LSP)

swiftSearchPattern

Search Swift source files with pure regex to detect closure capture lists, Task blocks, and other patterns missed by LSP. Returns matched lines with positions and snippets.

Instructions

[mg.code] Pure regex search over a file's contents — no SourceKit-LSP, no IndexStoreDB. Catches what LSP misses: closure capture lists ([weak self], [unowned self]), Task { ... self ... } blocks, and any other pattern the agent constructs from a leak chain. Returns matches with line/character positions and a trimmed snippet.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filePathYesAbsolute path to a Swift source file.
patternYesRegex pattern (JavaScript flavour). The `g` flag is implied — every match is returned.
flagsNoAdditional RegExp flags ("i", "m", "s", "im", etc.).
maxMatchesNoCap on matches returned (default 50).
Behavior4/5

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

With no annotations, the description carries full burden. It discloses that the tool does not use SourceKit-LSP or IndexStoreDB, is a pure regex search, and returns positional data with snippets. It could mention that it is read-only with no side effects, but the current detail is sufficient for safe invocation.

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

Conciseness5/5

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

The description is a single, well-structured paragraph. The first sentence immediately states the core functionality and constraints. Every subsequent sentence adds meaningful context (what it catches, return format) without unnecessary words.

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

Completeness4/5

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

Given the tool's moderate complexity and absence of an output schema, the description adequately covers purpose, usage, and return format. It could address edge cases like invalid regex or missing file, but overall it is complete enough for effective use.

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 100%, but the description adds value beyond schema descriptions. It explicitly notes the regex is JavaScript flavor with an implied 'g' flag, and suggests patterns for leak hunting. These details help the agent craft effective queries.

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 performs pure regex search over a Swift file's contents, distinguishing it from LSP-based tools. Specific examples (closure capture lists, Task blocks) make the purpose unmistakable and differentiate it from sibling tools like swiftFindSymbolReferences.

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 implies when to use the tool—'Catches what LSP misses'—and provides concrete patterns from leak investigations. While it does not explicitly list when not to use or name alternatives, the context is strong enough for an AI agent to infer appropriate scenarios.

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