tools

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 16, 2026 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Overview

Package tools defines the MCP tools exposed by embyfin-mcp, split by the resource they act on (server.go, libraries.go, items.go, ...). Tools are named resource-first (library_*, item_*, audit_*) so they group by what they act on.

Every tool is registered through add with a kind: read tools never change server state, write tools do (and are dropped under --read-only), and delete tools remove library records or media files (and are only registered with --enable-delete). --toolsets picks the groups a session needs, and --allow-tools / --deny-tools narrow the set further.

Index

Constants

This section is empty.

Variables

View Source
var EssentialTools = []string{
	"library_list",
	"library_search",
	"item_get",
	"user_next_up",
	"item_set_watched",
}

EssentialTools is the curated preset selected by --allow-tools essential: enough to find things, read them, and keep watch state in sync.

View Source
var Toolsets = map[string][]string{

	"core": {
		"server_info", "library_list", "library_get", "library_search", "library_items", "item_get", "item_find_by_metadata_id",
	},

	"curation": {
		"audit_all", "audit_missing_metadata_provider", "audit_missing_poster", "audit_missing_overview",
		"audit_year_mismatch", "audit_duplicates", "audit_multiple_versions", "audit_runtime",
		"audit_quality", "audit_missing_episodes", "audit_spelling", "audit_unwatched",
		"item_identify", "item_identify_apply", "item_refresh", "item_edit", "item_batch_edit", "metadata_rename",
		"item_artwork", "item_artwork_set", "item_subtitle_search", "item_subtitle_download",
		"item_similar", "show_seasons", "show_episodes", "show_missing",
		"library_recent", "library_genres", "library_filters", "library_people", "person_get",
	},

	"watching": {
		"user_list", "user_get", "user_history", "user_next_up", "user_in_progress", "user_favourites", "user_stats",
		"item_watch_history", "item_last_watched", "item_set_watched", "item_set_progress", "item_set_favourite",
		"item_instant_mix",
	},

	"organise": {
		"collection_list", "collection_get", "collection_create", "collection_edit", "collection_add", "collection_remove", "collection_delete",
		"playlist_list", "playlist_get", "playlist_create", "playlist_edit", "playlist_add", "playlist_remove", "playlist_delete",
	},

	"remote": {
		"session_list", "session_play", "session_command", "session_message",
	},

	"admin": {
		"server_stats", "server_activity", "server_devices", "server_logs", "server_log",
		"task_list", "task_run", "library_scan", "library_create", "library_edit", "library_delete", "item_delete",
	},
}

Toolsets group the tools by the job someone is doing, so a client can load a working subset instead of all of them. The whole surface is several thousand tokens of tool definitions (name, description, input schema) before anyone has asked a question; core alone is a fraction of that.

"all" is every tool, which is what the library does when no toolset is asked for; the embyfin-mcp binary defaults to core instead (see cli.FlagData.ToolOptions).

--toolsets also takes a resource family - library, item, audit, show, user, person, metadata, session, playlist, collection, server, task - which is every tool with that prefix. Those are derived from the registered names rather than listed here, so they cannot go stale.

Every tool belongs to exactly one set (TestToolsetsPartition proves it), and core is added to whatever else is asked for, because none of the other sets can find a library or open an item on their own.

Functions

func FamilyNames

func FamilyNames() []string

FamilyNames lists the resource prefixes accepted by --toolsets, for help output.

func RegisterAll

func RegisterAll(server *mcp.Server, client *embyfin.Client, opts Options) ([]string, error)

RegisterAll adds every tool permitted by opts to the MCP server and returns the names registered. It fails when an allow/deny pattern matches no tool, so a typo cannot silently hide one.

func ToolsetNames

func ToolsetNames() []string

ToolsetNames lists the curated toolsets, for help output.

Types

type Options

type Options struct {
	// ReadOnly registers only tools that never change server state.
	ReadOnly bool
	// EnableDelete registers the tools that delete media files and
	// libraries. Off unless the operator opts in.
	EnableDelete bool
	// Toolsets, when set, restricts registration to the named groups (see
	// Toolsets). "core" is always included, so a set can be asked for on its
	// own. Allow and Deny narrow whatever is left.
	Toolsets []string
	// Allow, when set, restricts registration to matching tools: exact names,
	// prefix/suffix globs (library_*, *_delete) or the "essential" preset.
	Allow []string
	// Deny removes matching tools from whatever Allow left.
	Deny []string
	// TMDBKey enables audits that need the metadata provider's own facts
	// (audit_runtime for movies). Empty disables them.
	TMDBKey string
	// ProviderTransport, when set, carries the calls embyfin-mcp itself
	// makes to metadata providers (TMDB). The tests point it at a
	// record/replay proxy; nil is the default transport.
	ProviderTransport http.RoundTripper
}

Options controls which tools are registered.

type ToolInfo

type ToolInfo struct {
	Name        string
	Kind        string // read, write or delete
	Toolset     string // the curated set it belongs to
	Description string
}

ToolInfo describes a registered tool without a server to register it on.

func Describe

func Describe(opts Options) ([]ToolInfo, error)

Describe lists the tools opts would register, for `embyfin-mcp tools`. It needs no connectivity: registration never calls the client, only the handlers do.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL