Skip to main content
Glama

Find Instantiation Sites

instantiation_sites
Read-onlyIdempotent

Find where a type is constructed and injected to see who creates or obtains instances before changing a constructor.

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 the other half - what is registered for a type.

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, so such a site is 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, a 'note' when there is one, createdByCount, createdByTests, injectedIntoCount, injectedIntoTests, sites - at most 200 items (name, declaringType, namespace, kind, isTestProject), created sites first - and '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.

A 'note' covers two zeros and a test-only answer: 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' gives a close declared name when no site was found and the name matches no declaration.

Read-only; works on a recalled session. typeName is matched on its simple name: namespace and generic arguments are dropped, namesakes are unioned, and an external type ('List', 'HttpClient') is a valid query. scope is 'solution' or a namespace prefix on the SITE's namespace.

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 (e.g. 'MyApp.Core') to narrow which sites are scanned.solution
typeNameYesThe type whose instantiation/injection sites to find (simple name; namespace + generic args are normalized away, e.g. 'OrderService' or 'List').
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. 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."
  2. First observed

TDQS

A4.5/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 adds substantial context beyond them: .ctor/.cctor attribution, Lazy<X> recorded under the outer type, a 200-item cap with created sites first, counts being true totals within scope, and test sites included rather than filtered. It stops short of describing pagination or how to page past the 200 cap, which is the one operational gap.

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

Conciseness3/5

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

Purpose and alternatives are front-loaded and strong, but the body is dense and long, packing classification rules, return-shape enumeration, and 'note'/'nearest' semantics into multi-clause paragraphs that reward re-reading. The content earns its place, yet the density and lack of structural separation cost clarity.

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?

With no output schema, the description carries the full return-value burden and does so: it names typeName, note, the four counts, sites fields and ordering, the nearest field, and explains exactly when a 'note' appears. For an analytical query tool of this complexity, an agent has everything needed to call it and interpret the result.

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%, so baseline is 3. The description still adds real meaning: typeName matches on simple name with namespace and generic arguments dropped, namesakes unioned, external types like 'List' valid, and scope is a prefix on the SITE's namespace rather than the type's. That last distinction is not obvious from the schema text alone.

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+resource ('Find where a type is constructed and where it is injected') and immediately scopes it against siblings: the narrow 'who creates or obtains an instance of X?' that find_usages cannot answer, and resolve_injection as the other half. An agent can distinguish it from find_usages and resolve_injection 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?

Explicit when-to-use ('before changing a constructor', 'to see whether anything but a test builds a type') plus named alternatives and the condition that selects them. It also states the negative case (array of X is not a creation) and the caveat that a DI-built type has no production site, so 'every site is a test' is not proof.

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