Package Exports
- @frontmcp/di
- @frontmcp/di/esm
- @frontmcp/di/package.json
Readme
@frontmcp/di
Dependency injection container and registry utilities for FrontMCP.
Internal package. Used by
@frontmcp/sdk— most users do not need to install this directly.
Install
npm install @frontmcp/di reflect-metadata zodFeatures
- Type-safe DI — class tokens with configurable prefixes (docs)
- Scoped providers — GLOBAL and CONTEXT scopes
- Hierarchical registries — parent/child container adoption
- Indexed lookups — O(1) registry queries via
IndexedRegistry - Change events — subscribe to registry mutations
- Token factory —
createTokenFactory({ prefix })for Symbol-based tokens
Quick Example
import 'reflect-metadata';
import { DiContainer, createTokenFactory, ProviderScope } from '@frontmcp/di';
const tokens = createTokenFactory({ prefix: 'MyApp' });
class DatabaseService {
static metadata = { name: 'Database', scope: ProviderScope.GLOBAL };
}
const container = new DiContainer([DatabaseService]);
await container.ready;
const db = container.get(DatabaseService);Docs
| Topic | Link |
|---|---|
| Providers & DI | Providers |
Related Packages
@frontmcp/sdk— consumes DI for server-level injection
License
Apache-2.0 — see LICENSE.