Skip to main content
Glama

Find Instantiation Sites

instantiation_sites
Read-onlyIdempotent

Finds where a type is constructed (new, with) and which types inject it as a constructor parameter. Use it to see who creates X before changing a constructor and whether anything but tests builds it.

Instructions

Find where a type is constructed and where it is injected: the narrow 'who creates or obtains an instance of X?' that find_usages (every reference) cannot answer; resolve_injection answers what is registered for it. Use it before changing a constructor, and to see whether anything but a test builds a type.

'created': a method, constructor, accessor or top-level code that runs 'new X(...)', a target-typed new or a record 'with'; a field or property initializer is attributed to the constructor the compiler runs it in, named '.ctor' ('.cctor' for a static one). 'injected': a type that takes X as a constructor parameter - no container is consulted. A parameter wrapped in another type (Lazy) is recorded under the outer type, and an array of X is not a creation of X.

Returns typeName, optional 'note' and 'generatedCodeNote' (its project, or one it compiles against, lacks generated code), createdByCount, createdByTests, injectedIntoCount, injectedIntoTests, sites - a capped envelope: items (at most 200, each name, declaringType, namespace, kind, isTestProject, 'generated' in generator output; created sites first), count, totalFound, truncated - and optional 'nearest'. The four counts are true totals within scope. Test-project sites are included, not filtered: isTestProject marks each. A type the DI container builds has no recorded production site, so 'every site is a test' is not proof.

The 'note' leads with any unread VB, F# or markup code. With no site at all it names the construction paths this fact cannot see and the markup views naming the type; with injectedIntoCount 0, it names those of its interfaces something is injected under - a DI consumer takes the interface, so query that name; with every site a test (unscoped), it says so and names the markup views. 'nearest': a close declared name when no site was found and the name matches no declaration.

Read-only; works on a recalled session.

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>",
      "typeName": "<typeName>"
    },
    "name": "instantiation_sites"
  }
}

Input Schema

NameRequiredDescriptionDefault
scopeNo'solution' (default) or a namespace prefix of the SITE's namespace (e.g. 'MyApp.Core') to narrow which sites are scanned.solution
typeNameYesThe type whose instantiation/injection sites to find, matched on its simple name: generic args are dropped and namesakes are unioned (e.g. 'OrderService'); an external type such as 'List' is a valid query. A qualified form ('Ns.Type', 'Outer.Inner') is read as its simple name where no solution type of that name lies outside it, otherwise declined (a 'note' says so).
sessionIdYesThe session_id returned by analyze_solution. Also takes an absolute .sln/.slnx/.slnf path, analyzed on first use.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed2 schema fields changedv0.5.46521
    • changedInput schema / properties / scope / description
      Previous value: -"'solution' (default) or a namespace prefix (e.g. 'MyApp.Core') to narrow which sites are scanned."New value: +"'solution' (default) or a namespace prefix of the SITE's namespace (e.g. 'MyApp.Core') to narrow which sites are scanned."
    • changedInput schema / properties / typeName / description
      Previous value: -"The type whose instantiation/injection sites to find (simple name; namespace + generic args are normalized away, e.g. 'OrderService' or 'List')."New value: +"The type whose instantiation/injection sites to find, matched on its simple name: generic args are dropped and namesakes are unioned (e.g. 'OrderService'); an external type such as 'List' is a valid query. A qualified form ('Ns.Type', 'Outer.Inner') is read as its simple name where no solution type of that name lies outside it, otherwise declined (a 'note' says so)."
  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.4/5.0
Behavior4/5

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

Annotations already cover the safety profile (readOnly, idempotent, non-destructive, closed-world), and the description goes well beyond them: what counts as 'created' vs 'injected', .ctor/.cctor attribution for initializers, that no container is consulted, that Lazy<X> is recorded under the outer type, that an array of X is not a creation, and that test sites are included rather than filtered. The only reason it is not a 5 is density — several of these rules are buried mid-paragraph and easy to miss on a quick scan.

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 most valuable content — the sibling differentiation and the use-before-changing-a-constructor trigger — is front-loaded in the first two clauses. The remainder is dense and long, especially the 'note' paragraph and the return-envelope enumeration, but nearly every sentence carries a distinct rule rather than filler.

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?

There is no output schema, so the description must describe the return shape itself, and it does: typeName, note, generatedCodeNote, the four counts, and the capped envelope (items, count, totalFound, truncated, nearest) with the 200-item cap disclosed. It also explains when 'note' and 'nearest' appear, which is exactly the interpretive context a caller needs.

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 schema already documents typeName, scope and sessionId thoroughly, including the qualified-name decline rule. The description adds little parameter-level meaning beyond one passing mention that counts are 'true totals within scope'; the baseline 3 applies when the schema carries the load.

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 opening sentence states a precise verb and resource ('find where a type is constructed and where it is injected') and immediately carves out the narrow question it answers versus find_usages ('every reference') and resolve_injection ('what is registered for it'). An agent can distinguish it from both siblings without opening any 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?

It gives an explicit usage trigger ('use it before changing a constructor') and a decision rule ('to see whether anything but a test builds a type'), plus the negative case: find_usages answers every reference, this answers only construction/obtaining. It also warns that a DI-built type has no recorded production site, so 'every site is a test' is not proof — a real interpretation guard, not boilerplate.

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