Files
LocalAI/core/services/mcp/remote.go
Ettore Di Giacinto 59108fbe32 feat: add distributed mode (#9124)
* feat: add distributed mode (experimental)

Signed-off-by: Ettore Di Giacinto <mudler@localai.io>

* fix data races, mutexes, transactions

Signed-off-by: Ettore Di Giacinto <mudler@localai.io>

* refactorings

Signed-off-by: Ettore Di Giacinto <mudler@localai.io>

* fixups

Signed-off-by: Ettore Di Giacinto <mudler@localai.io>

* fix events and tool stream in agent chat

Signed-off-by: Ettore Di Giacinto <mudler@localai.io>

* use ginkgo

Signed-off-by: Ettore Di Giacinto <mudler@localai.io>

* refactoring and consolidation

Signed-off-by: Ettore Di Giacinto <mudler@localai.io>

* refactoring and consolidation

Signed-off-by: Ettore Di Giacinto <mudler@localai.io>

* refactoring and consolidation

Signed-off-by: Ettore Di Giacinto <mudler@localai.io>

* refactoring and consolidation

Signed-off-by: Ettore Di Giacinto <mudler@localai.io>

* refactoring and consolidation

Signed-off-by: Ettore Di Giacinto <mudler@localai.io>

* refactoring and consolidation

Signed-off-by: Ettore Di Giacinto <mudler@localai.io>

* refactoring and consolidation

Signed-off-by: Ettore Di Giacinto <mudler@localai.io>

* refactoring and consolidation

Signed-off-by: Ettore Di Giacinto <mudler@localai.io>

* fix(cron): compute correctly time boundaries avoiding re-triggering

Signed-off-by: Ettore Di Giacinto <mudler@localai.io>

* enhancements, refactorings

Signed-off-by: Ettore Di Giacinto <mudler@localai.io>

* do not flood of healthy checks

Signed-off-by: Ettore Di Giacinto <mudler@localai.io>

* do not list obvious backends as text backends

Signed-off-by: Ettore Di Giacinto <mudler@localai.io>

* tests fixups

Signed-off-by: Ettore Di Giacinto <mudler@localai.io>

* refactoring and consolidation

Signed-off-by: Ettore Di Giacinto <mudler@localai.io>

* Drop redundant healthcheck

Signed-off-by: Ettore Di Giacinto <mudler@localai.io>

* enhancements, refactorings

Signed-off-by: Ettore Di Giacinto <mudler@localai.io>

---------

Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
2026-03-30 00:47:27 +02:00

57 lines
2.3 KiB
Go

package mcp
import (
"github.com/mudler/LocalAI/core/config"
"github.com/mudler/LocalAI/pkg/functions"
)
// MCPToolRequest is the NATS request-reply payload for executing an MCP tool
// on an agent worker. The frontend serializes the model's MCP server config
// so the worker can create sessions and execute the tool.
type MCPToolRequest struct {
ModelName string `json:"model_name"`
ToolName string `json:"tool_name"`
Arguments map[string]any `json:"arguments,omitempty"`
RemoteServers config.MCPGenericConfig[config.MCPRemoteServers] `json:"remote_servers"`
StdioServers config.MCPGenericConfig[config.MCPSTDIOServers] `json:"stdio_servers"`
}
// MCPToolResponse is the NATS reply for an MCP tool execution.
type MCPToolResponse struct {
Result string `json:"result,omitempty"`
Error string `json:"error,omitempty"`
}
// MCPDiscoveryRequest is the NATS request-reply payload for discovering
// available MCP tools, prompts, and resources from a model's MCP servers.
type MCPDiscoveryRequest struct {
ModelName string `json:"model_name"`
RemoteServers config.MCPGenericConfig[config.MCPRemoteServers] `json:"remote_servers"`
StdioServers config.MCPGenericConfig[config.MCPSTDIOServers] `json:"stdio_servers"`
}
// MCPDiscoveryResponse is the NATS reply for an MCP discovery request.
type MCPDiscoveryResponse struct {
Servers []MCPServerInfo `json:"servers,omitempty"`
Tools []MCPToolDef `json:"tools,omitempty"` // flattened tool list with functions
Error string `json:"error,omitempty"`
}
// MCPServerInfo describes an MCP server and its available capabilities.
type MCPServerInfo struct {
Name string `json:"name"`
Type string `json:"type"`
Tools []string `json:"tools"`
Prompts []string `json:"prompts,omitempty"`
Resources []string `json:"resources,omitempty"`
}
// MCPToolDef is a serializable tool definition (function schema) that can
// travel over NATS. Unlike MCPToolInfo which holds a live session pointer,
// this is pure data.
type MCPToolDef struct {
ServerName string `json:"server_name"`
ToolName string `json:"tool_name"`
Function functions.Function `json:"function"`
}