FastestMCP.ComponentManager (fastest_mcp v0.1.2)

Copy Markdown View Source

Runtime-owned mutable component store.

FastestMCP.ComponentManager is the answer to a specific design problem: components sometimes need to change after the server has already started, but the source of truth should still live inside the runtime, not in a parallel management API.

The manager keeps those mutations inside one GenServer and also exposes itself as a provider. That means normal list, resolve, call, and read paths all see the same add/remove/enable/disable state as the public management functions in this module.

Typical Use

Fetch the live manager from a running server:

manager = FastestMCP.component_manager(server_name)
FastestMCP.ComponentManager.add_tool(manager, "dynamic", fn _args, _ctx -> :ok end)

From that point on, the added component is visible through the same runtime paths as components declared on the original server definition.

Duplicate Registration Policy

The manager supports on_duplicate: on both startup and individual add calls:

  • :error - raise
  • :warn - log and replace
  • :ignore - keep the current component
  • :replace - replace silently

That gives runtime mutations the same explicit duplicate semantics as FastestMCP.Server and the local in-memory provider implementation.

Summary

Functions

Adds a prompt component to the current definition.

Adds a resource component to the current definition.

Adds a resource-template component to the current value.

Adds a tool component to the current definition.

Returns a specification to start this module under a supervisor.

Disables the named prompt.

Marks the resource identified by the given URI as disabled.

Disables the named resource template.

Marks the named tool as disabled.

Marks the named prompt as enabled.

Enables the named resource.

Marks the named resource template as enabled.

Marks the named tool as enabled.

Fetches the live component manager for the named running server.

Reads a value from the backing store.

Resolves one component by type and identifier.

Resolves the backing resource target for a concrete URI.

Processes synchronous GenServer calls for the state owned by this module.

Initializes the state used by this module before it starts processing work.

Lists the values owned by this module.

Lists the components exposed by this module.

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

Returns the provider type label.

Removes the named prompt.

Removes the resource identified by the given URI.

Removes the resource template identified by the given URI template.

Removes the named tool.

Starts the process owned by this module.

Functions

add_prompt(target, name, handler, opts \\ [])

Adds a prompt component to the current definition.

add_resource(target, uri, handler, opts \\ [])

Adds a resource component to the current definition.

add_resource_template(target, uri_template, handler, opts \\ [])

Adds a resource-template component to the current value.

add_tool(target, name, handler, opts \\ [])

Adds a tool component to the current definition.

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

disable_prompt(target, name, opts \\ [])

Disables the named prompt.

disable_resource(target, uri, opts \\ [])

Marks the resource identified by the given URI as disabled.

disable_resource_template(target, uri_template, opts \\ [])

Disables the named resource template.

disable_tool(target, name, opts \\ [])

Marks the named tool as disabled.

enable_prompt(target, name, opts \\ [])

Marks the named prompt as enabled.

enable_resource(target, uri, opts \\ [])

Enables the named resource.

enable_resource_template(target, uri_template, opts \\ [])

Marks the named resource template as enabled.

enable_tool(target, name, opts \\ [])

Marks the named tool as enabled.

fetch(server_name)

Fetches the live component manager for the named running server.

get(target, component_type, identifier, opts \\ [])

Reads a value from the backing store.

get_component(manager, component_type, identifier, operation)

Resolves one component by type and identifier.

get_resource_target(manager, uri, operation)

Resolves the backing resource target for a concrete URI.

handle_call(msg, from, state)

Processes synchronous GenServer calls for the state owned by this module.

init(map)

Initializes the state used by this module before it starts processing work.

list(target, component_type, opts \\ [])

Lists the values owned by this module.

list_components(manager, component_type, operation)

Lists the components exposed by this module.

new(server_name, pid)

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

provider_type(manager)

Returns the provider type label.

remove_prompt(target, name, opts \\ [])

Removes the named prompt.

remove_resource(target, uri, opts \\ [])

Removes the resource identified by the given URI.

remove_resource_template(target, uri_template, opts \\ [])

Removes the resource template identified by the given URI template.

remove_tool(target, name, opts \\ [])

Removes the named tool.

start_link(opts)

Starts the process owned by this module.