FastestMCP.Provider (fastest_mcp v0.2.0)

Copy Markdown View Source

Shared wrapper for provider-backed component sources.

Providers are how a server exposes components that do not live directly on the %FastestMCP.Server{} struct. Common examples are:

This module wraps provider implementations so the runtime can ask every provider the same questions:

  • what components do you expose?
  • can you return a bounded keyset page for wire list operations?
  • can you resolve this identifier directly?
  • for a concrete resource URI, what is the backing target?
  • do you expose extra HTTP routes?

Transforms

A provider can also be wrapped with transforms. Transforms rewrite component identifiers on the way out and translate them back on the way in. That is how namespacing and tool renaming are applied without changing the underlying provider implementation.

Summary

Functions

Adds a transform to the current definition.

Returns whether this provider can perform a bounded source-level component page lookup.

Resolves one component by type and identifier.

Resolves the backing resource target for a concrete URI.

Returns additional HTTP routes exposed by this provider.

Lists the components exposed by this module.

Builds a new value for this module from the supplied options.

Returns the component or provider type.

Types

inner()

@type inner() :: struct()

t()

@type t() :: %FastestMCP.Provider{inner: inner(), transforms: [struct()]}

Functions

add_transform(provider, transform)

Adds a transform to the current definition.

component_page_callback?(provider)

Returns whether this provider can perform a bounded source-level component page lookup.

get_component(provider, component_type, identifier, operation)

Resolves one component by type and identifier.

get_resource_target(provider, uri, operation)

Resolves the backing resource target for a concrete URI.

http_routes(provider)

Returns additional HTTP routes exposed by this provider.

list_component_page(provider, component_type, after_key, limit, operation)

Reads one source-level component page.

The optional provider callback is list_component_page/5 and receives the provider value, component type, normalized stable after-key, requested limit, and current operation. It must return {:ok, %{items: components, next_after: key_or_nil}} (the outer {:ok, ...} may be omitted). Components use FastestMCP.Pagination.default_key/1 ordering. A non-nil next_after declares that another source page is available. The callback returns source candidates only; the shared pipeline still owns component transforms, visibility, and authorization.

Provider transforms intentionally disable this callback because an arbitrary rename can change ordering. Those providers retain the correct streaming keyset fallback in FastestMCP.OperationPipeline.

list_components(provider, component_type, operation)

Lists the components exposed by this module.

new(provider)

Builds a new value for this module from the supplied options.

type(provider)

Returns the component or provider type.