MCPcopy
hub / github.com/mudler/LocalAI / LocalAIClient

Interface LocalAIClient

pkg/mcp/localaitools/client.go:26–104  ·  view source on GitHub ↗

LocalAIClient is the surface tools depend on. It has two implementations: - inproc.Client (in-process; calls LocalAI services directly) - httpapi.Client (out-of-process; calls the LocalAI REST API) Tool handlers and the embedded skill prompts are agnostic to which implementation backs the client.

Source from the content-addressed store, hash-verified

24// a parallel DTO — keeping the LLM-visible wire format aligned with the
25// rest of LocalAI by construction.
26type LocalAIClient interface {
27 // ---- Models / gallery (read) ----
28 GallerySearch(ctx context.Context, q GallerySearchQuery) ([]gallery.Metadata, error)
29 ListInstalledModels(ctx context.Context, capability Capability) ([]InstalledModel, error)
30 ListGalleries(ctx context.Context) ([]config.Gallery, error)
31 GetJobStatus(ctx context.Context, jobID string) (*JobStatus, error)
32 GetModelConfig(ctx context.Context, name string) (*ModelConfigView, error)
33
34 // ---- Models / gallery (write) ----
35 InstallModel(ctx context.Context, req InstallModelRequest) (jobID string, err error)
36 DeleteModel(ctx context.Context, name string) error
37 EditModelConfig(ctx context.Context, name string, patch map[string]any) error
38 ReloadModels(ctx context.Context) error
39 ImportModelURI(ctx context.Context, req ImportModelURIRequest) (*ImportModelURIResponse, error)
40
41 // ---- Model aliases ----
42 // SetAlias creates the alias `name` pointing at `target`, or swaps an
43 // existing alias's target. The server validates that `target` is an
44 // existing, non-alias, enabled model. Deletion reuses DeleteModel.
45 SetAlias(ctx context.Context, name, target string) error
46 // ListAliases returns every configured alias and its target.
47 ListAliases(ctx context.Context) ([]AliasInfo, error)
48
49 // ---- Backends ----
50 // ListBackends returns installed backends. The shape stays a thin
51 // localaitools.Backend rather than gallery.SystemBackend because the
52 // latter carries filesystem paths (RunFile, Metadata) the LLM
53 // shouldn't see.
54 ListBackends(ctx context.Context) ([]Backend, error)
55 // ListKnownBackends returns the same shape as REST /backends/known.
56 ListKnownBackends(ctx context.Context) ([]schema.KnownBackend, error)
57 InstallBackend(ctx context.Context, req InstallBackendRequest) (jobID string, err error)
58 UpgradeBackend(ctx context.Context, name string) (jobID string, err error)
59
60 // ---- System ----
61 SystemInfo(ctx context.Context) (*SystemInfo, error)
62 ListNodes(ctx context.Context) ([]Node, error)
63 VRAMEstimate(ctx context.Context, req VRAMEstimateRequest) (*vram.EstimateResult, error)
64
65 // ---- State ----
66 // ToggleModelState accepts modeladmin.ActionEnable / ActionDisable.
67 ToggleModelState(ctx context.Context, name string, action modeladmin.Action) error
68 // ToggleModelPinned accepts modeladmin.ActionPin / ActionUnpin.
69 ToggleModelPinned(ctx context.Context, name string, action modeladmin.Action) error
70
71 // ---- Branding / whitelabeling ----
72 // GetBranding returns the configured instance branding (name, tagline,
73 // asset URLs).
74 GetBranding(ctx context.Context) (*Branding, error)
75 // SetBranding updates the text branding fields. Asset uploads are not
76 // exposed over MCP — admins use the Settings UI for binary files.
77 SetBranding(ctx context.Context, req SetBrandingRequest) (*Branding, error)
78
79 // ---- Usage / billing ----
80
81 // GetUsageStats returns aggregated token usage. In single-user
82 // no-auth mode this reports the synthetic local user's usage. The
83 // implementation enforces "admin required to query other users".

Callers 47

registerModelToolsFunction · 0.65
parity_test.goFile · 0.65
client_test.goFile · 0.65
registerModelToolsFunction · 0.65
registerModelToolsFunction · 0.65
parity_test.goFile · 0.65
client_test.goFile · 0.65
registerModelToolsFunction · 0.65
client_test.goFile · 0.65
registerConfigToolsFunction · 0.65
tokenClassifyFunction · 0.65
registerModelToolsFunction · 0.65

Implementers 4

stubClientcore/http/endpoints/mcp/localai_assist
fakeClientpkg/mcp/localaitools/fakes_test.go
Clientpkg/mcp/localaitools/httpapi/client.go
Clientpkg/mcp/localaitools/inproc/client.go

Calls

no outgoing calls

Tested by

no test coverage detected