Skip to main content
Glama

Resolve Dependency Injection

resolve_injection
Read-onlyIdempotent

Resolve Microsoft DI or MEF registrations for a service and report implementation, lifetime, and source site.

Instructions

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

Read: Add{Singleton,Scoped,Transient}, TryAdd*, descriptor adds built at the call, AddHostedService, project-local helpers registering their own type arguments, 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. Umbraco collection builders: collectionBuilders.

Returns registrations (serviceType, implementationType [= service if self/instance], lifetime, note, location, project, declaringMethod, key, targetFrameworks: a multi-targeted project's call is one row; note 'inferred, not read' = from a package helper's call shape AddSingletonAs().As(): lifetime from its name, never ambiguous or a winner) and: multiRegistration / registrationSites; ambiguous (possible conflict: ONE site registers several implementations of one service, receivers not compared, not consumed as a collection); effectiveRegistration (2+ calls: the winner a single-service resolve gets, read in ONE straight-line site; else null + reason); consumedAsCollection; constructorConsumerCount (plain ctor parameters); otherConsumers (GetService outside a registration factory, [Inject], @inject: per form); optionalDependencies (optional ctor parameters: yes/no/unknown).

An empty list says why: resolvedKind 'not_found' + 'nearest' = no such name; else a 'note' names the unread forms and which the solution holds - empty means 'not statically visible', never 'not registered'.

Test projects count only with includeTests=true (testRegistrationsFiltered: what that hid). A closed form (IRepo) lists that closing and IRepo<> (typeArgumentFilter: the rest).

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>",
      "interface": "<interface>"
    },
    "name": "resolve_injection"
  }
}

Input Schema

NameRequiredDescriptionDefault
siteNoOptional: narrow to registrations whose file path contains this substring.
interfaceYesThe SERVICE type's simple or fully-qualified name (an interface, or a self-registered class), e.g. 'ICodeAnalyzer'. A simple name lists every type of that name; a qualified one ('App.Settings.IPanel') leaves out same-named types of other namespaces and says how many. 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.46521
    • changedInput schema / properties / interface / description
      Previous value: -"The interface simple or fully-qualified name, e.g. 'ICodeAnalyzer'. A simple name lists every type of that name; a qualified one ('App.Settings.IPanel') leaves out same-named types of other namespaces and says how many. A closed generic form ('IHandler<Saved>') lists only the registrations serving that closing; 'IHandler' or 'IHandler<T>' lists every closing."New value: +"The SERVICE type's simple or fully-qualified name (an interface, or a self-registered class), e.g. 'ICodeAnalyzer'. A simple name lists every type of that name; a qualified one ('App.Settings.IPanel') leaves out same-named types of other namespaces and says how many. 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.46517
    • changedInput schema / properties / interface / description
      Previous 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."New value: +"The interface simple or fully-qualified name, e.g. 'ICodeAnalyzer'. A simple name lists every type of that name; a qualified one ('App.Settings.IPanel') leaves out same-named types of other namespaces and says how many. A closed generic form ('IHandler<Saved>') lists only the registrations serving that closing; 'IHandler' or 'IHandler<T>' lists every closing."
  3. 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."
  4. 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."
  5. First observed

TDQS

A4.3/5.0
Behavior4/5

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

Annotations already carry readOnly/idempotent/closed-world, but the description adds substantial behaviour of its own: empty results mean "not statically visible" rather than "not registered", inferred rows are labelled, and ambiguous/effectiveRegistration semantics are spelled out. The density and notation ('not consumed as a collection', 'never ambiguous or a winner') make parts of it hard to act on, which holds it below a 5.

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?

It is front-loaded with purpose and organised into read / not-read / returns, so nothing is pure filler. But the prose is a dense wall of parenthetical notation and run-on clauses ("Add{Singleton,Scoped,Transient}, TryAdd*, descriptor adds built at the call...") that costs more parsing effort than the information justifies in that form.

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 takes full responsibility for the return shape and does so field by field (serviceType, lifetime, note, targetFrameworks, ambiguous, effectiveRegistration, constructorConsumerCount), including the empty-result and filtering edge cases. Nothing an agent needs to interpret the response is missing.

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 explains the simple-vs-qualified name behaviour, closed generic forms, and sessionId path fallback in detail. The description adds only the point that a key and a closing each count as their own service, which is marginal on top of the schema's own treatment of generics.

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?

"Resolve a Microsoft DI or MEF registration: what is registered for a service, with lifetime and site" gives a specific verb, resource, and output scope, then explicitly negates three sibling tools by name (find_usages, find_implementations, instantiation_sites). An agent can place this tool against its neighbours 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 names the alternative tools and the exact question each answers, then adds explicit in/out coverage lists (reads Add*/TryAdd*/AddHostedService, does not read Scrutor, other containers, or descriptors built elsewhere). It also states the test-project default and that Umbraco collection builders are a separate tool, which is the routing information an agent needs.

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