Skip to content

Commit 6fa7326

Browse files
authored
feat: switch to official MCP SDK (#318)
* feat: switch to official MCP SDK Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * Drop MCP Box Signed-off-by: Ettore Di Giacinto <mudler@localai.io> --------- Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
1 parent 558fa39 commit 6fa7326

File tree

21 files changed

+164
-1494
lines changed

21 files changed

+164
-1494
lines changed

.github/workflows/image.yml

Lines changed: 1 addition & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -83,79 +83,7 @@ jobs:
8383
#tags: ${{ steps.prep.outputs.tags }}
8484
tags: ${{ steps.meta.outputs.tags }}
8585
labels: ${{ steps.meta.outputs.labels }}
86-
mcpbox-build:
87-
runs-on: ubuntu-latest
88-
steps:
89-
- name: Checkout
90-
uses: actions/checkout@v4
91-
92-
- name: Prepare
93-
id: prep
94-
run: |
95-
DOCKER_IMAGE=quay.io/mudler/localagi-mcpbox
96-
# Use branch name as default
97-
VERSION=${GITHUB_REF#refs/heads/}
98-
BINARY_VERSION=$(git describe --always --tags --dirty)
99-
SHORTREF=${GITHUB_SHA::8}
100-
# If this is git tag, use the tag name as a docker tag
101-
if [[ $GITHUB_REF == refs/tags/* ]]; then
102-
VERSION=${GITHUB_REF#refs/tags/}
103-
fi
104-
TAGS="${DOCKER_IMAGE}:${VERSION},${DOCKER_IMAGE}:${SHORTREF}"
105-
# If the VERSION looks like a version number, assume that
106-
# this is the most recent version of the image and also
107-
# tag it 'latest'.
108-
if [[ $VERSION =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
109-
TAGS="$TAGS,${DOCKER_IMAGE}:latest"
110-
fi
111-
# Set output parameters.
112-
echo ::set-output name=binary_version::${BINARY_VERSION}
113-
echo ::set-output name=tags::${TAGS}
114-
echo ::set-output name=docker_image::${DOCKER_IMAGE}
115-
- name: Set up QEMU
116-
uses: docker/setup-qemu-action@master
117-
with:
118-
platforms: all
119-
120-
- name: Set up Docker Buildx
121-
id: buildx
122-
uses: docker/setup-buildx-action@master
123-
124-
- name: Login to DockerHub
125-
if: github.event_name != 'pull_request'
126-
uses: docker/login-action@v3
127-
with:
128-
registry: quay.io
129-
username: ${{ secrets.DOCKER_USERNAME }}
130-
password: ${{ secrets.DOCKER_PASSWORD }}
131-
- name: Extract metadata (tags, labels) for Docker
132-
id: meta
133-
uses: docker/metadata-action@902fa8ec7d6ecbf8d84d538b9b233a880e428804
134-
with:
135-
images: quay.io/mudler/localagi-mcpbox
136-
tags: |
137-
type=ref,event=branch,suffix=-{{date 'YYYYMMDDHHmmss'}}
138-
type=semver,pattern={{raw}}
139-
type=sha,suffix=-{{date 'YYYYMMDDHHmmss'}}
140-
type=ref,event=branch
141-
flavor: |
142-
latest=auto
143-
prefix=
144-
suffix=
145-
146-
- name: Build
147-
uses: docker/build-push-action@v6
148-
with:
149-
builder: ${{ steps.buildx.outputs.name }}
150-
build-args: |
151-
VERSION=${{ steps.prep.outputs.binary_version }}
152-
context: ./
153-
file: ./Dockerfile.mcpbox
154-
platforms: linux/amd64,linux/arm64
155-
push: true
156-
#tags: ${{ steps.prep.outputs.tags }}
157-
tags: ${{ steps.meta.outputs.tags }}
158-
labels: ${{ steps.meta.outputs.labels }}
86+
15987
sshbox-build:
16088
runs-on: ubuntu-latest
16189
steps:

Dockerfile.mcpbox

Lines changed: 0 additions & 49 deletions
This file was deleted.

Dockerfile.webui

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,21 @@ COPY --from=ui-builder /app/dist /work/webui/react-ui/dist
4444
# Build the application
4545
RUN CGO_ENABLED=0 go build -ldflags="$LDFLAGS" -o localagi ./
4646

47-
FROM scratch
47+
FROM ubuntu:24.04
48+
49+
ENV DEBIAN_FRONTEND=noninteractive
50+
51+
# Install runtime dependencies
52+
RUN apt-get update && apt-get install -y \
53+
ca-certificates \
54+
tzdata \
55+
docker.io \
56+
bash \
57+
wget \
58+
curl
4859

4960
# Copy the webui binary from the builder stage to the final image
5061
COPY --from=builder /work/localagi /localagi
51-
COPY --from=builder /etc/ssl/ /etc/ssl/
52-
COPY --from=builder /tmp /tmp
5362

5463
# Define the command that will be run when the container is started
5564
ENTRYPOINT ["/localagi"]

Makefile

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
GOCMD?=go
22
IMAGE_NAME?=webui
3-
MCPBOX_IMAGE_NAME?=mcpbox
43
ROOT_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
54

6-
prepare-tests: build-mcpbox
5+
prepare-tests:
76
docker compose up -d --build
8-
docker run -d -v /var/run/docker.sock:/var/run/docker.sock --privileged -p 9090:8080 --rm -ti $(MCPBOX_IMAGE_NAME)
97

108
cleanup-tests:
119
docker compose down
1210

1311
tests: prepare-tests
14-
LOCALAGI_MCPBOX_URL="http://localhost:9090" LOCALAGI_MODEL="gemma-3-4b-it-qat" LOCALAI_API_URL="http://localhost:8081" LOCALAGI_API_URL="http://localhost:8080" $(GOCMD) run github.com/onsi/ginkgo/v2/ginkgo --fail-fast -v -r ./...
12+
LOCALAGI_MODEL="gemma-3-4b-it-qat" LOCALAI_API_URL="http://localhost:8081" LOCALAGI_API_URL="http://localhost:8080" $(GOCMD) run github.com/onsi/ginkgo/v2/ginkgo --fail-fast -v -r ./...
1513

1614
run-nokb:
1715
$(MAKE) run KBDISABLEINDEX=true
@@ -25,16 +23,10 @@ build: webui/react-ui/dist
2523

2624
.PHONY: run
2725
run: webui/react-ui/dist
28-
LOCALAGI_MCPBOX_URL="http://localhost:9090" $(GOCMD) run ./
26+
$(GOCMD) run ./
2927

3028
build-image:
3129
docker build -t $(IMAGE_NAME) -f Dockerfile.webui .
3230

3331
image-push:
34-
docker push $(IMAGE_NAME)
35-
36-
build-mcpbox:
37-
docker build -t $(MCPBOX_IMAGE_NAME) -f Dockerfile.mcpbox .
38-
39-
run-mcpbox:
40-
docker run -v /var/run/docker.sock:/var/run/docker.sock --privileged -p 9090:8080 -ti mcpbox
32+
docker push $(IMAGE_NAME)

README.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,6 @@ pool, err := state.NewAgentPool(
343343
"http://localhost:8080", // API URL
344344
"your-api-key", // API key
345345
"./state", // state directory
346-
"", // MCP box URL (optional)
347346
"http://localhost:8081", // LocalRAG API URL
348347
func(config *AgentConfig) func(ctx context.Context, pool *AgentPool) []types.Action {
349348
// Define available actions for agents
@@ -732,7 +731,6 @@ export LOCALAGI_LOCALRAG_URL=http://localrecall:8080
732731
export LOCALAGI_STATE_DIR=./pool
733732
export LOCALAGI_TIMEOUT=5m
734733
export LOCALAGI_ENABLE_CONVERSATIONS_LOGGING=false
735-
export LOCALAGI_MCPBOX_URL=http://mcpbox:8080
736734
export LOCALAGI_SSHBOX_URL=root:root@sshbox:22
737735

738736
# Start development server
@@ -1035,7 +1033,6 @@ LocalAGI supports environment configurations. Note that these environment variab
10351033
| `LOCALAGI_STATE_DIR` | Where state gets stored |
10361034
| `LOCALAGI_LOCALRAG_URL` | LocalRecall connection |
10371035
| `LOCALAGI_SSHBOX_URL` | LocalAGI SSHBox URL, e.g. user:pass@ip:port |
1038-
| `LOCALAGI_MCPBOX_URL` | LocalAGI MCPBox URL, e.g. http://mcpbox:8080 |
10391036
| `LOCALAGI_ENABLE_CONVERSATIONS_LOGGING` | Toggle conversation logs |
10401037
| `LOCALAGI_API_KEYS` | A comma separated list of api keys used for authentication |
10411038
| `LOCALAGI_CUSTOM_ACTIONS_DIR` | Directory containing custom Go action files to be automatically loaded |

cmd/mcpbox/main.go

Lines changed: 0 additions & 38 deletions
This file was deleted.

core/agent/agent.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"sync"
1313
"time"
1414

15+
"github.com/modelcontextprotocol/go-sdk/mcp"
1516
"github.com/mudler/LocalAGI/pkg/xlog"
1617

1718
"github.com/mudler/LocalAGI/core/action"
@@ -43,7 +44,8 @@ type Agent struct {
4344

4445
newConversations chan openai.ChatCompletionMessage
4546

46-
mcpActions types.Actions
47+
mcpActions types.Actions
48+
mcpSessions []*mcp.ClientSession
4749

4850
subscriberMutex sync.Mutex
4951
newMessagesSubscribers []func(openai.ChatCompletionMessage)

0 commit comments

Comments
 (0)