Files
LocalAI/pkg/mcp/localaitools/server.go
LocalAI [bot] 4056283aa4 [voice] feat: add managed voice cloning profiles (#10799)
* feat(ui): add voice library workflow

Give administrators a production-ready flow to record or upload consented reference audio, manage reusable profiles, inspect API usage, discover compatible models, and hand a saved voice directly to text-to-speech.

Assisted-by: Codex:gpt-5

* feat(voice): add managed voice cloning profiles

Make reusable reference voices manageable through the admin API instead of requiring model-directory and YAML edits. Discover compatible installed and gallery models from server-side backend capabilities, retain explicit model configuration controls, and stage saved references for supported backends.

Expose profile management through REST and MCP, document backend-specific behavior, and cover the workflow from profile creation through real Qwen3-TTS synthesis. Harden the agent-job HTTP test against completion racing cancellation.

Assisted-by: Codex:gpt-5

---------

Co-authored-by: Ettore Di Giacinto <mudler@localai.io>
2026-07-13 09:54:46 +02:00

59 lines
1.7 KiB
Go

package localaitools
import (
"github.com/modelcontextprotocol/go-sdk/mcp"
"github.com/mudler/LocalAI/internal"
)
// Options control which tools the server registers and how the embedded
// skill prompts are surfaced.
type Options struct {
// DisableMutating omits all tools that change server state. Used by the
// "--read-only" flavour of the standalone stdio CLI.
DisableMutating bool
// ServerName overrides the MCP server's advertised Implementation.Name.
// Defaults to "localai-admin".
ServerName string
// ServerVersion overrides the advertised version. Defaults to the linked
// internal.PrintableVersion().
ServerVersion string
}
// NewServer builds an MCP server that exposes LocalAI's admin surface as
// tools, backed by the supplied LocalAIClient. The same server type is used
// in-process (paired in-memory transport) and out-of-process (stdio).
func NewServer(client LocalAIClient, opts Options) *mcp.Server {
name := opts.ServerName
if name == "" {
name = DefaultServerName
}
version := opts.ServerVersion
if version == "" {
version = internal.PrintableVersion()
}
srv := mcp.NewServer(&mcp.Implementation{
Name: name,
Version: version,
}, &mcp.ServerOptions{
Instructions: SystemPrompt(opts),
})
registerModelTools(srv, client, opts)
registerAliasTools(srv, client, opts)
registerBackendTools(srv, client, opts)
registerConfigTools(srv, client, opts)
registerSystemTools(srv, client, opts)
registerStateTools(srv, client, opts)
registerBrandingTools(srv, client, opts)
registerVoiceProfileTools(srv, client, opts)
registerUsageTools(srv, client, opts)
registerPIITools(srv, client, opts)
registerMiddlewareTools(srv, client, opts)
return srv
}