ADR 0001: Keep the core framework-neutral through an instance resolver

Context

The desired developer experience is decorator-first while remaining useful in applications with different construction and dependency-management conventions. Directly importing an application framework in the package would couple every TypeScript consumer to that framework's container, reflection conventions, and lifecycle semantics. Conversely, always constructing a decorated class with new would make dependency-aware application integration impossible.

Decision

type-mcp stores class/method definitions and exposes an async-capable InstanceResolver interface. The default resolver directly constructs the decorated class. The compiler depends only on the interface.

Implementation status: InstanceResolver<T>, defaultInstanceResolver, and resolveMcpServerInstance() are implemented. Direct construction is type-restricted to zero-argument server classes; a custom resolver supports dependency-requiring constructors. MCP SDK compilation consumes this seam.

export interface InstanceResolver<T> {
  resolve<Arguments extends readonly unknown[]>(
    serverClass: new (...args: Arguments) => T,
  ): T | Promise<T>;
}

Consumers can implement this interface with their own construction mechanism without coupling TypeMCP to a particular container or discovery API.

Consequences

Positive

Trade-offs

Rejected alternatives