Skip to main content

Class Definition

runId, activeStage, and logger are protected — accessible inside subclasses but not from outside. The provider registry is private; use get(token) / tryGet(token) to resolve dependencies.

Constructor

Properties (protected — visible to subclasses)

Methods

Dependency Injection

get<T>(token)

Get a required dependency from the provider registry.
Throws: ProviderNotAvailableError (PROVIDER_NOT_AVAILABLE) when no registry up the hierarchy provides the token. Its message names a class token; a string or symbol token shows as [ref] (Provider "[ref]" is not available: not found in local or parent registries). Use tryGet() to get undefined instead.

tryGet<T>(token)

Try to get an optional dependency.

Context Access

get context()

Get the current request context.
Throws: RequestContextNotAvailableError if not in request scope.

tryGetContext()

Try to get request context without throwing.

Scope Access

get scope

Get the current scope with all registries.

Authentication

getAuthInfo()

Get authentication information for the current request.
this.auth reads roles and permissions through the server’s authorities.claimsMapping when one is configured, the same mapping the authorities engine uses, on every transport (including MCP 2026-07-28 requests).

Execution Tracking

mark(stage)

Mark the current execution stage for debugging and profiling.

Error Handling

fail(err)

Fail the execution with an error.

get error

Get the current error, if any.

HTTP Requests

fetch(input, init?)

Make HTTP requests with auto-injected headers.
Automatically injects:
  • Trace context headers (traceparent, x-request-id)
  • The caller’s Authorization token and the request’s x-frontmcp-* headers, only for origins listed in @FrontMcp({ fetch })

Configuration

get config

Get typed configuration access (requires ConfigPlugin).

Protected Logger

get contextLogger

Get a child logger with request context.

Usage Example

ToolContext

Tool-specific context

ResourceContext

Resource-specific context

AgentContext

Agent-specific context

ProviderRegistry

Dependency injection