Skip to content

Commit 60b6472

Browse files
authored
feat: Add Agentic MCP support with a new chat/completion endpoint (#6381)
* WIP - add endpoint Signed-off-by: Ettore Di Giacinto <[email protected]> * Rename Signed-off-by: Ettore Di Giacinto <[email protected]> * Wire the Completion API Signed-off-by: Ettore Di Giacinto <[email protected]> * Try to make it functional Signed-off-by: Ettore Di Giacinto <[email protected]> * Almost functional Signed-off-by: Ettore Di Giacinto <[email protected]> * Bump golang versions used in tests Signed-off-by: Ettore Di Giacinto <[email protected]> * Add description of the tool Signed-off-by: Ettore Di Giacinto <[email protected]> * Make it working Signed-off-by: Ettore Di Giacinto <[email protected]> * Small optimizations Signed-off-by: Ettore Di Giacinto <[email protected]> * Cleanup/refactor Signed-off-by: Ettore Di Giacinto <[email protected]> * Update docs Signed-off-by: Ettore Di Giacinto <[email protected]> --------- Signed-off-by: Ettore Di Giacinto <[email protected]>
1 parent 6b2c827 commit 60b6472

File tree

21 files changed

+679
-35
lines changed

21 files changed

+679
-35
lines changed

.github/workflows/build-test.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
- name: Set up Go
1818
uses: actions/setup-go@v5
1919
with:
20-
go-version: 1.23
20+
go-version: 1.25
2121
- name: Run GoReleaser
2222
run: |
2323
make dev-dist
@@ -31,7 +31,7 @@ jobs:
3131
- name: Set up Go
3232
uses: actions/setup-go@v5
3333
with:
34-
go-version: 1.23
34+
go-version: 1.25
3535
- name: Build launcher for macOS ARM64
3636
run: |
3737
make build-launcher-darwin
@@ -53,7 +53,7 @@ jobs:
5353
- name: Set up Go
5454
uses: actions/setup-go@v5
5555
with:
56-
go-version: 1.23
56+
go-version: 1.25
5757
- name: Build launcher for Linux
5858
run: |
5959
sudo apt-get update

.github/workflows/test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
runs-on: ubuntu-latest
2222
strategy:
2323
matrix:
24-
go-version: ['1.21.x']
24+
go-version: ['1.25.x']
2525
steps:
2626
- name: Free Disk Space (Ubuntu)
2727
uses: jlumbroso/free-disk-space@main
@@ -193,7 +193,7 @@ jobs:
193193
runs-on: macOS-14
194194
strategy:
195195
matrix:
196-
go-version: ['1.21.x']
196+
go-version: ['1.25.x']
197197
steps:
198198
- name: Clone
199199
uses: actions/checkout@v5

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,8 @@ For more information, see [💻 Getting started](https://localai.io/basics/getti
197197

198198
## 📰 Latest project news
199199

200+
- October 2025: 🔌 [Model Context Protocol (MCP)](https://localai.io/features/mcp/) support added for agentic capabilities with external tools
201+
- September 2025: New Launcher application for MacOS and Linux, extended support to many backends for Mac and Nvidia L4T devices. Models: Added MLX-Audio, WAN 2.2. WebUI improvements and Python-based backends now ships portable python environments.
200202
- August 2025: MLX, MLX-VLM, Diffusers and llama.cpp are now supported on Mac M1/M2/M3+ chips ( with `development` suffix in the gallery ): https://github.com/mudler/LocalAI/pull/6049 https://github.com/mudler/LocalAI/pull/6119 https://github.com/mudler/LocalAI/pull/6121 https://github.com/mudler/LocalAI/pull/6060
201203
- July/August 2025: 🔍 [Object Detection](https://localai.io/features/object-detection/) added to the API featuring [rf-detr](https://github.com/roboflow/rf-detr)
202204
- July 2025: All backends migrated outside of the main binary. LocalAI is now more lightweight, small, and automatically downloads the required backend to run the model. [Read the release notes](https://github.com/mudler/LocalAI/releases/tag/v3.2.0)
@@ -235,6 +237,7 @@ Roadmap items: [List of issues](https://github.com/mudler/LocalAI/issues?q=is%3A
235237
- 🔍 [Object Detection](https://localai.io/features/object-detection/)
236238
- 📈 [Reranker API](https://localai.io/features/reranker/)
237239
- 🆕🖧 [P2P Inferencing](https://localai.io/features/distribute/)
240+
- 🆕🔌 [Model Context Protocol (MCP)](https://localai.io/features/mcp/) - Agentic capabilities with external tools
238241
- [Agentic capabilities](https://github.com/mudler/LocalAGI)
239242
- 🔊 Voice activity detection (Silero-VAD support)
240243
- 🌍 Integrated WebUI!

core/backend/soundgeneration.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ func SoundGeneration(
6060

6161
// return RPC error if any
6262
if !res.Success {
63-
return "", nil, fmt.Errorf(res.Message)
63+
return "", nil, fmt.Errorf("error during sound generation: %s", res.Message)
6464
}
6565

6666
return filePath, res, err

core/backend/tts.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ func ModelTTS(
7070

7171
// return RPC error if any
7272
if !res.Success {
73-
return "", nil, fmt.Errorf(res.Message)
73+
return "", nil, fmt.Errorf("error during TTS: %s", res.Message)
7474
}
7575

7676
return filePath, res, err

core/cli/run.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ func (r *RunCMD) Run(ctx *cliContext.Context) error {
127127
config.WithP2PNetworkID(r.Peer2PeerNetworkID),
128128
config.WithLoadToMemory(r.LoadToMemory),
129129
config.WithMachineTag(r.MachineTag),
130+
config.WithAPIAddress(r.Address),
130131
}
131132

132133
if r.DisableMetricsEndpoint {

core/config/application_config.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ type ApplicationConfig struct {
6363
WatchDogBusyTimeout, WatchDogIdleTimeout time.Duration
6464

6565
MachineTag string
66+
67+
APIAddress string
6668
}
6769

6870
type AppOption func(*ApplicationConfig)
@@ -343,6 +345,12 @@ func WithDisableApiKeyRequirementForHttpGet(required bool) AppOption {
343345
}
344346
}
345347

348+
func WithAPIAddress(address string) AppOption {
349+
return func(o *ApplicationConfig) {
350+
o.APIAddress = address
351+
}
352+
}
353+
346354
var DisableMetricsEndpoint AppOption = func(o *ApplicationConfig) {
347355
o.DisableMetrics = true
348356
}

core/config/backend_config.go renamed to core/config/model_config.go

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,45 @@ type ModelConfig struct {
7373

7474
Options []string `yaml:"options" json:"options"`
7575
Overrides []string `yaml:"overrides" json:"overrides"`
76+
77+
MCP MCPConfig `yaml:"mcp" json:"mcp"`
78+
}
79+
80+
type MCPConfig struct {
81+
Servers string `yaml:"remote" json:"remote"`
82+
Stdio string `yaml:"stdio" json:"stdio"`
83+
}
84+
85+
func (c *MCPConfig) MCPConfigFromYAML() (MCPGenericConfig[MCPRemoteServers], MCPGenericConfig[MCPSTDIOServers]) {
86+
var remote MCPGenericConfig[MCPRemoteServers]
87+
var stdio MCPGenericConfig[MCPSTDIOServers]
88+
89+
if err := yaml.Unmarshal([]byte(c.Servers), &remote); err != nil {
90+
return remote, stdio
91+
}
92+
93+
if err := yaml.Unmarshal([]byte(c.Stdio), &stdio); err != nil {
94+
return remote, stdio
95+
}
96+
97+
return remote, stdio
98+
}
99+
100+
type MCPGenericConfig[T any] struct {
101+
Servers T `yaml:"mcpServers" json:"mcpServers"`
102+
}
103+
type MCPRemoteServers map[string]MCPRemoteServer
104+
type MCPSTDIOServers map[string]MCPSTDIOServer
105+
106+
type MCPRemoteServer struct {
107+
URL string `json:"url"`
108+
Token string `json:"token"`
109+
}
110+
111+
type MCPSTDIOServer struct {
112+
Args []string `json:"args"`
113+
Env map[string]string `json:"env"`
114+
Command string `json:"command"`
76115
}
77116

78117
// Pipeline defines other models to use for audio-to-audio
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)