Skip to main content
Glama

Find Event Subscriptions

find_by_event_subscription
Read-onlyIdempotent

Find which C# types subscribe to an event by locating '+=' handlers, including external events, to see who listens, where handlers are wired, and spot possible leaks.

Instructions

Find the TYPES that subscribe to a C# event: a '+=' whose left side resolves to an event, anywhere in the type; external events too ('Button.Click'). find_usages on a solution-declared event lists its (un)subscribing and raising METHODS.

Use it for 'who listens to this event?', where handlers are wired, and as a leak hint. A '+=' on a number, string or delegate field is skipped (no subscription). XAML-wired handlers (Click="OnClick") are 'markupWires' (handler, viewCount, views), owe no '-=', are never 'unreleased' and, recording no event, never match eventName.

Returns scope, event, typesScanned, subscriptionSitesChecked, subscriptionSitesUnresolved, matches (at most 200 types: name, namespace, events, unreleased, markupWires; sorted by namespace, name) and when they apply 'note', availableEvents, testMatchesFiltered. A partial type is one row ('files' when spread over several); 'fullName' marks namesakes, 'project' linked-file twins (the build 'Name(tfm)' where only it declares the type; 'projects' where several do). A hit lists ALL event keys ('DeclaringType.EventName') the type subscribes to.

'unreleased' lists each subscription no '-=' of the type removes ('Event <- Handler'). A '-=' counts for the same event AND the same handler on ANY receiver, so an old/new swap reads released; a lambda never matches, so a lambda subscription is always listed; a subscription to an object the type owns is listed although it cannot outlive it. [] means each has a matching '-='; no list means not measured (see the note). A place to look, not a proven leak.

An empty answer: availableEvents lists the events subscribed in scope; read testMatchesFiltered first if present. An EMPTY availableEvents means none was RECORDED - recognition needs a resolved left side. The site counts settle it: '0 of 0' is nothing to see, '0 of 7, 0 unresolved' a real absence, '0 of 7, 7 unresolved' an unmeasured scope.

Read-only; works on a recalled session. Test-project types are excluded unless includeTests=true.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "sessionId": "<sessionId>"
    },
    "name": "find_by_event_subscription"
  }
}

Input Schema

NameRequiredDescriptionDefault
scopeNo'solution' (default) or a namespace prefix (e.g. 'MyApp.UI') to narrow scope.solution
eventNameNoFilter to types subscribing to this event - the event name ('Click') or the qualified 'DeclaringType.EventName' key ('Button.Click'), case-insensitive, matched exactly (never as a substring). A qualified solution type in front ('Ns.Type.Event', 'Outer.Inner.Event') reads as that key where no type of that simple name lies outside it (a 'note' says so). Omit to list every type with any subscription.
sessionIdYesThe session_id returned by analyze_solution. Also takes an absolute .sln/.slnx/.slnf path, analyzed on first use.
includeTestsNoInclude test-project types (default false - production focus; test setup that wires events would drown the signal).

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv0.5.46521
    • changedInput schema / properties / eventName / description
      Previous value: -"Filter to types subscribing to this event - the event name ('Click') or the qualified 'DeclaringType.EventName' key ('Button.Click'), case-insensitive. Omit to list every type with any subscription."New value: +"Filter to types subscribing to this event - the event name ('Click') or the qualified 'DeclaringType.EventName' key ('Button.Click'), case-insensitive, matched exactly (never as a substring). A qualified solution type in front ('Ns.Type.Event', 'Outer.Inner.Event') reads as that key where no type of that simple name lies outside it (a 'note' says so). Omit to list every type with any subscription."
  2. Changed1 schema field changedv0.5.46513
    • changedInput schema / properties / sessionId / description
      Previous value: -"The session_id returned by analyze_solution."New value: +"The session_id returned by analyze_solution. Also takes an absolute .sln/.slnx/.slnf path, analyzed on first use."
  3. First observed

TDQS

A4.6/5.0
Behavior5/5

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

Annotations only cover safety (readOnly, idempotent, non-destructive), and the description goes well beyond that: '+=' on a number, string or delegate field is skipped, XAML-wired handlers land in markupWires and are never 'unreleased', and it discloses the input-file analysis path. The 'unreleased' semantics are unusually well disclosed, including the false-positive cases (old/new handler swaps count as released; lambdas always listed; owned objects listed though they cannot outlive the type) and the []-vs-absent-list distinction meaning measured vs. not measured.

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 purpose and the sibling disambiguation are front-loaded, and with no output schema most of the return-shape detail earns its place. It is still a dense wall of parenthetical clauses (the 'project'/'fullName'/'Name(tfm)' sentence is hard to parse) and the empty-answer guidance is spread across two paragraphs that could be one.

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?

No output schema exists, and the description documents the return payload fully: scope, event, typesScanned, matches fields, note, availableEvents and testMatchesFiltered. It even tells the agent how to interpret a zero-result answer via the site counts ('0 of 0', '0 of 7, 0 unresolved', '0 of 7, 7 unresolved'), which is exactly the ambiguity an agent would otherwise get stuck on.

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% and the schema already documents all four parameters, including the qualified-key matching rule and the sessionId path fallback, so the baseline is 3. The description mostly restates those rules ('Test-project types are excluded unless includeTests=true') and adds little parameter meaning that isn't already in the 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?

States a specific verb and resource ('Find the TYPES that subscribe to a C# event') and pins the exact syntactic trigger ('a "+=" whose left side resolves to an event'), including external events like 'Button.Click'. It explicitly separates itself from find_usages, which 'lists its (un)subscribing and raising METHODS' for a solution-declared event, so an agent can pick without opening either schema.

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?

Gives concrete use cases ('who listens to this event?', where handlers are wired, leak hint) and names the competing sibling with the condition that selects it (methods vs. subscribing types). It also covers the includeTests tradeoff ('test setup that wires events would drown the signal') and cautions the result is 'a place to look, not a proven leak'.

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