Files
LocalAI/core/services/mcp/remote.go
T
Richard Palethorpe 5c63969760 fix: Show MCP connection errors in the UI (#11495)
* fix(mcp): surface configured server failures

Keep model-configured MCP servers visible when discovery or connection setup fails, propagate status through distributed discovery, and let the Chat UI show actionable errors while retrying unavailable servers.

Add model-editor metadata for remote and stdio configuration and document the expected format, deployment networking boundary, and alternate MCP scopes.

Assisted-by: Codex:gpt-5 Ordino golangci-lint
Signed-off-by: Richard Palethorpe <io@richiejp.com>

* build(compose): match CUDA development image

Configure the API image with the cublas, CUDA 13, auth-tagged build settings used by the local development Makefile invocation, including the 24-way Docker build.

Assisted-by: Codex:gpt-5 Ordino
Signed-off-by: Richard Palethorpe <io@richiejp.com>

* revert: keep host build settings out of compose

The CUDA development deployment is managed from ~/docker/localai, not the repository example Compose file. Restore the generic example and keep machine-specific build settings in the host deployment.

Assisted-by: Codex:gpt-5 Ordino
Signed-off-by: Richard Palethorpe <io@richiejp.com>

* fix(docker): exclude local agent artifacts

Keep Claude worktrees and locally installed verification tools out of the Docker build context. These host-only directories added roughly 1.9 GB to every root image build.

Assisted-by: Codex:gpt-5 Ordino
Signed-off-by: Richard Palethorpe <io@richiejp.com>

---------

Signed-off-by: Richard Palethorpe <io@richiejp.com>
2026-08-13 22:25:58 +02:00

58 lines
2.4 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"`
Error string `json:"error,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"`
}