Files
LocalAI/pkg/mcp/localaitools/server.go
Owen Adirah 8f74f74b10 feat(mcp): expose scheduling admin tools (#11228)
* feat(mcp): add scheduling client contracts

Assisted-by: Hephaestus:openai/gpt-5.5
Signed-off-by: Owen Adirah <owenadira@gmail.com>

* feat(mcp): add scheduling HTTP client support

Assisted-by: Hephaestus:openai/gpt-5.5
Signed-off-by: Owen Adirah <owenadira@gmail.com>

* feat(mcp): add in-process scheduling stubs

Assisted-by: Hephaestus:openai/gpt-5.5
Signed-off-by: Owen Adirah <owenadira@gmail.com>

* feat(mcp): register scheduling tools

Assisted-by: Hephaestus:openai/gpt-5.5
Signed-off-by: Owen Adirah <owenadira@gmail.com>

* test(mcp): map scheduling tools to REST routes

Assisted-by: Hephaestus:openai/gpt-5.5
Signed-off-by: Owen Adirah <owenadira@gmail.com>

* docs(mcp): document scheduling assistant tools

Assisted-by: Hephaestus:openai/gpt-5.5
Signed-off-by: Owen Adirah <owenadira@gmail.com>

* fix(mcp): wire in-process scheduling

Use an explicit MCP scheduling DTO and route in-process scheduling calls through the distributed node registry so the embedded assistant matches the REST scheduling surface.

Assisted-by: Hephaestus:openai/gpt-5.5
Signed-off-by: Owen Adirah <owenadira@gmail.com>

* fix(mcp): narrow scheduling dto

Assisted-by: Hephaestus:openai/gpt-5.5 [opencode]
Signed-off-by: Owen Adirah <owenadira@gmail.com>

---------

Signed-off-by: Owen Adirah <owenadira@gmail.com>
2026-08-03 15:24:29 +02:00

60 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)
registerSchedulingTools(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
}