@Provider, inject them into tools, resources, prompts, and agents with this.get().
Defining Providers
Create a provider with a token and scope:Provider Scopes
| Scope | Lifetime | Use Case |
|---|---|---|
singleton | One instance per server | Configuration, database connections |
request | One instance per MCP request | Request-scoped caches, loggers |
context | One instance per execution context | Per-tool state |
Injecting Providers
Usethis.get() or this.tryGet() inside any context class:
Registering Providers
Register providers at the server or app level:Server-level providers are shared across all apps. App-level providers are isolated to their app.
Learn More
Providers Guide
Full guide to defining, scoping, and composing providers
@Provider Reference
Complete decorator API reference