Skip to main content
Glama

Resolve Dependency Injection

resolve_injection
Read-onlyIdempotent

Resolve Microsoft DI registrations for a service: returns implementation, lifetime, site, ambiguity, and collection consumption, so you can answer what gets injected.

Instructions

Resolve a Microsoft DI registration: what is registered for a service, with lifetime and site. Not usage (find_usages), implementers (find_implementations), construction (instantiation_sites).

It reads Add{Singleton,Scoped,Transient}, TryAdd*, descriptor adds built at the call, AddHostedService, project-local helpers registering their own type arguments (note 'via '), and a foreach over a static new(typeof(Service), typeof(Impl)) table. A key, and a closing, is a service of its own (IRepo, IRepo); open IRepo<> is read. Not read: a descriptor built elsewhere, AddHttpClient-style helpers, Scrutor, other containers.

Returns JSON: registrations (serviceType, implementationType [= its service for a self/instance form], lifetime, note, location, project, declaringMethod, key; note 'inferred, not read' = from a package helper's call shape AddSingletonAs().As(): lifetime from its name, body unseen; not in ambiguous or a winner) and: multiRegistration / registrationSites; ambiguous (ONE site registers several implementations of one service, not consumed as a collection); effectiveRegistration (2+ calls: the winner a single-service resolve gets, read only in ONE straight-line site; else null + reason); consumedAsCollection; constructorConsumerCount (plain constructor parameters; not a usage verdict); optionalDependencies (optional constructor parameters, each judged yes/no/unknown).

An empty list says why: resolvedKind 'not_found' plus 'nearest' = nothing in the solution names it; else a 'note' names the forms not read and which of them the solution holds (package helpers, conventions, runtime types) - empty means 'not statically visible', never 'not registered'.

Needs a live session. Test-project registrations and consumers count only with includeTests=true; testRegistrationsFiltered counts what that hid. interface is the SERVICE type (an interface, or a class registered as itself); a closed form (IRepo) lists that closing and IRepo<> (typeArgumentFilter: the rest); site narrows by file path.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
siteNoOptional: narrow to registrations whose file path contains this substring.
interfaceYesThe interface simple or fully-qualified name, e.g. 'ICodeAnalyzer'. A closed generic form ('IHandler<Saved>') lists only the registrations serving that closing; 'IHandler' or 'IHandler<T>' lists every closing.
sessionIdYesThe session_id returned by analyze_solution. Also takes an absolute .sln/.slnx/.slnf path, analyzed on first use.
includeTestsNoInclude registrations declared in test projects (default false - production focus).

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv0.5.46514
    • changedInput schema / properties / interface / description
      Previous value: -"The interface simple or fully-qualified name, e.g. 'ICodeAnalyzer'."New value: +"The interface simple or fully-qualified name, e.g. 'ICodeAnalyzer'. A closed generic form ('IHandler<Saved>') lists only the registrations serving that closing; 'IHandler' or 'IHandler<T>' lists every closing."
  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.8/5.0
Behavior5/5

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

Annotations only declare read-only/idempotent/non-destructive; the description goes far beyond, enumerating exactly which registration forms are read (Add{Singleton,Scoped,Transient}, TryAdd*, AddHostedService, foreach static table) and which are not (Scrutor, other containers, AddHttpClient-style). It also discloses the 'inferred, not read' provenance, the 'needs a live session' requirement, and the 'never not registered' caveat for empty results.

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?

Front-loaded correctly (purpose first, exclusions second), and given there is no output schema nearly every clause earns its place. It is, however, extremely dense—the return-shape enumeration is a run-on separated by semicolons that is hard to parse on a first read.

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 burden and does so: it documents the JSON keys (registrations, ambiguous, effectiveRegistration, consumedAsCollection, constructorConsumerCount, optionalDependencies), the empty-list semantics, session requirements, and test filtering. An agent has what it needs to call and interpret it.

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 the baseline is 3, but the description adds semantics the schema does not: 'interface is the SERVICE type (an interface, or a class registered as itself)' and the typeArgumentFilter distinction for closed vs open generics. Some of the site/includeTests text duplicates the schema, keeping it below 5.

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?

Opens with a specific verb and resource: 'Resolve a Microsoft DI registration: what is registered for a service, with lifetime and site.' It then explicitly names the sibling tools it is NOT (find_usages, find_implementations, instantiation_sites), so an agent can route correctly 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?

States when to use it versus three named alternatives, defines the empty-result case ('not_found' + 'nearest' vs a note naming unread forms), and specifies the includeTests=true condition with testRegistrationsFiltered. Both when-to-use and when-not-to-use are covered.

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