Skip to content

Commit 4e8d4bf

Browse files
authored
Improvements (#12)
This pull request includes several enhancements and refactorings to the `Makefile`, `cmd/server.go`, and other files to improve the development workflow and codebase maintainability. The most important changes include updating dependencies, adding new commands to the `Makefile`, and refactoring the tool setup in `cmd/server.go`. ### Makefile Enhancements: * Updated the `go install` command to use the new repository for `air` in `dev-api` and `dev-server` targets. [[1]](diffhunk://#diff-76ed074a9305c04054cdebb9e9aad2d818052b07091de1f20cad0bbac34ffb52L56-R56) [[2]](diffhunk://#diff-76ed074a9305c04054cdebb9e9aad2d818052b07091de1f20cad0bbac34ffb52L66-R83) * Added `run-frontend` command to run the MCP Kit Frontend using Docker. * Added `load-env` command to load environment variables from `.env.local`. * Updated the `help` target to reflect new commands. ### Codebase Refactoring: * Refactored `cmd/server.go` to use a new `setupTools` function for setting up tools, improving code organization and maintainability. [[1]](diffhunk://#diff-ee2560d627cd77f1563972217a33ac39a4bf56fbf30d7f560fbb4199b9f70197R72-R79) [[2]](diffhunk://#diff-ee2560d627cd77f1563972217a33ac39a4bf56fbf30d7f560fbb4199b9f70197R96-R134) * Removed redundant `curl` tool implementations from `internal/tools/curl.go` and replaced them with tools from the `mcptools` package. ### Dependency Updates: * Updated `go.mod` to include new dependencies and replace local paths for `mcp-tools` and `goai`. [[1]](diffhunk://#diff-33ef32bf6c23acb95f5902d7097b7a1d5128ca061167ec0716715b0b9eeaa5f6R5-R6) [[2]](diffhunk://#diff-33ef32bf6c23acb95f5902d7097b7a1d5128ca061167ec0716715b0b9eeaa5f6L14-R24) [[3]](diffhunk://#diff-33ef32bf6c23acb95f5902d7097b7a1d5128ca061167ec0716715b0b9eeaa5f6R53) [[4]](diffhunk://#diff-33ef32bf6c23acb95f5902d7097b7a1d5128ca061167ec0716715b0b9eeaa5f6R65-R71) [[5]](diffhunk://#diff-33ef32bf6c23acb95f5902d7097b7a1d5128ca061167ec0716715b0b9eeaa5f6R91-R96) ### Documentation Updates: * Added instructions for running the MCP Kit Frontend and using Docker Compose in `README.md`. These changes collectively enhance the development experience, improve code organization, and update dependencies for better compatibility and functionality.
1 parent af60da3 commit 4e8d4bf

File tree

19 files changed

+123
-6005
lines changed

19 files changed

+123
-6005
lines changed

.github/workflows/CI.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
- name: Set up Go
2323
uses: actions/setup-go@v4
2424
with:
25-
go-version: '1.23'
25+
go-version: '1.24'
2626

2727
- name: Run Backend Tests
2828
run: make test
@@ -47,7 +47,7 @@ jobs:
4747

4848
- uses: actions/setup-go@v5
4949
with:
50-
go-version: '^1.23'
50+
go-version: '^1.24'
5151
check-latest: true
5252
cache: true
5353
go-version-file: 'go.mod'
@@ -121,7 +121,7 @@ jobs:
121121

122122
- uses: actions/setup-go@v3
123123
with:
124-
go-version: '^1.23'
124+
go-version: '^1.24'
125125

126126
- uses: docker/login-action@v1
127127
with:

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919

2020
- uses: actions/setup-go@v3
2121
with:
22-
go-version: '^1.23'
22+
go-version: '^1.24'
2323

2424
- uses: docker/login-action@v1
2525
with:

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.23-alpine AS builder
1+
FROM golang:1.24-alpine AS builder
22
RUN apk add --no-cache git make
33

44
WORKDIR /app

Makefile

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ dev-api:
5353
air -- api; \
5454
else \
5555
echo "Air is not installed. Installing air for hot reload..."; \
56-
go install github.com/cosmtrek/air@latest; \
56+
go install github.com/air-verse/air@latest; \
5757
air -- api; \
5858
fi
5959

@@ -63,10 +63,24 @@ dev-server:
6363
air -- server; \
6464
else \
6565
echo "Air is not installed. Installing air for hot reload..."; \
66-
go install github.com/cosmtrek/air@latest; \
66+
go install github.com/air-verse/air@latest; \
6767
air -- server; \
6868
fi
6969

70+
# Run the MCP Kit Frontend
71+
run-frontend:
72+
@echo "Running MCP Kit Frontend..."
73+
@if [ $$(docker ps -a -q -f name=mcp-frontend) ]; then \
74+
echo "Stopping and removing existing container..."; \
75+
docker stop mcp-frontend; \
76+
docker rm mcp-frontend; \
77+
fi
78+
@docker run -d \
79+
--name mcp-frontend \
80+
-p 3001:80 \
81+
-e VITE_MCP_BACKEND_API_ENDPOINT=http://localhost:8081 \
82+
ghcr.io/shaharia-lab/mcp-frontend:latest
83+
7084
# Run all components in development mode
7185
dev-all:
7286
@echo "Starting all components in development mode..."
@@ -97,6 +111,11 @@ build-dev: wire
97111
@echo "Building development binary for $(APP_NAME)..."
98112
@go build -o $(BUILD_DIR)/$(APP_NAME)
99113

114+
# Load environment variables
115+
load-env:
116+
@echo "Loading environment variables from .env.local..."
117+
@export $(grep -v '^#' .env.local | xargs)
118+
100119
# Clean build artifacts
101120
clean:
102121
@echo "Cleaning..."
@@ -160,8 +179,8 @@ help:
160179
@echo " docker-build - Build docker image"
161180
@echo " run - Run the backend application"
162181
@echo " dev - Run backend in development mode with hot reload"
163-
@echo " frontend-install- Install frontend dependencies"
164-
@echo " frontend-dev - Run frontend in development mode"
182+
@echo " load-env - Load environment variables from .env.local"
183+
@echo " run-frontend - Run frontend docker"
165184
@echo " dev-all - Run both frontend and backend in development mode"
166185
@echo " build-all - Build both frontend and backend for production"
167186
@echo " help - Show this help message"

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,29 @@ docker run -d \
123123
-e AUTH_AUDIENCE=$AUTH_AUDIENCE \
124124
-p 8081:8081 \
125125
ghcr.io/shaharia-lab/mcp-kit:$VERSION api
126+
127+
## Running the MCP Kit Frontend
128+
129+
docker run -d \
130+
--name mcp-frontend \
131+
-p 3001:80 \
132+
-e VITE_MCP_BACKEND_API_ENDPOINT=http://localhost:8081 \
133+
ghcr.io/shaharia-lab/mcp-frontend:latest
134+
```
135+
136+
### Using Docker Compose
137+
138+
```bash
139+
docker plugin install grafana/loki-docker-driver:latest --alias loki --grant-all-permissions
126140
```
127141

142+
```bash
143+
docker-compose up -d
144+
```
145+
146+
### Accessing the UI
147+
http://localhost:3001
148+
128149
Visit `http://localhost:8081` to access the UI interface to interact with the AI model.
129150

130151
### Interacting with the API

cmd/server.go

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package cmd
33
import (
44
"context"
55
"fmt"
6+
mcptools "github.com/shaharia-lab/mcp-tools"
67
"log"
78

89
"github.com/shaharia-lab/goai/mcp"
@@ -68,12 +69,14 @@ func NewServerCmd(logger *log.Logger) *cobra.Command {
6869
return fmt.Errorf("failed to create base server: %w", err)
6970
}
7071

72+
toolsLists := setupTools(l)
73+
7174
err = baseServer.AddPrompts(prompt.MCPPromptsRegistry...)
7275
if err != nil {
7376
return fmt.Errorf("failed to add prompts: %w", err)
7477
}
7578

76-
err = baseServer.AddTools(tools.MCPToolsRegistry...)
79+
err = baseServer.AddTools(toolsLists...)
7780
if err != nil {
7881
return fmt.Errorf("failed to add tools: %w", err)
7982
}
@@ -90,3 +93,42 @@ func NewServerCmd(logger *log.Logger) *cobra.Command {
9093
},
9194
}
9295
}
96+
97+
func setupTools(logger goaiObs.Logger) []mcp.Tool {
98+
ts := tools.MCPToolsRegistry
99+
100+
ghConfig := mcptools.NewGitHubTool(logger, mcptools.GitHubConfig{})
101+
fileSystem := mcptools.NewFileSystem(logger, mcptools.FileSystemConfig{})
102+
docker := mcptools.NewDocker(logger)
103+
git := mcptools.NewGit(logger, mcptools.GitConfig{})
104+
curl := mcptools.NewCurl(logger, mcptools.CurlConfig{})
105+
postgres := mcptools.NewPostgreSQL(logger, mcptools.PostgreSQLConfig{})
106+
107+
ts = append(
108+
ts,
109+
110+
// Curl tools
111+
curl.CurlAllInOneTool(),
112+
113+
// Git tools
114+
git.GitAllInOneTool(),
115+
116+
// Docker tools
117+
docker.DockerAllInOneTool(),
118+
119+
// File system tools
120+
fileSystem.FileSystemAllInOneTool(),
121+
122+
// GitHub tools
123+
ghConfig.GetIssuesTool(),
124+
ghConfig.GetIssuesTool(),
125+
ghConfig.GetPullRequestsTool(),
126+
ghConfig.GetRepositoryTool(),
127+
ghConfig.GetSearchTool(),
128+
129+
// PostgreSQL tools
130+
postgres.PostgreSQLAllInOneTool(),
131+
)
132+
133+
return ts
134+
}

cmd/wire_gen.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

go.mod

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
module github.com/shaharia-lab/mcp-kit
22

3-
go 1.23.0
3+
go 1.24
4+
5+
toolchain go1.24.1
46

57
require (
68
github.com/anthropics/anthropic-sdk-go v0.2.0-alpha.13
@@ -11,23 +13,21 @@ require (
1113
github.com/fatih/color v1.18.0
1214
github.com/go-chi/chi/v5 v5.2.1
1315
github.com/go-chi/cors v1.2.1
14-
github.com/golang-jwt/jwt/v4 v4.5.1
15-
github.com/google/go-github/v60 v60.0.0
1616
github.com/google/uuid v1.6.0
1717
github.com/google/wire v0.6.0
1818
github.com/kelseyhightower/envconfig v1.4.0
19-
github.com/lib/pq v1.10.9
2019
github.com/openai/openai-go v0.1.0-alpha.61
2120
github.com/prometheus/client_golang v1.21.0
22-
github.com/shaharia-lab/goai v0.11.0
21+
github.com/shaharia-lab/goai v0.11.1
22+
github.com/shaharia-lab/mcp-tools v0.0.2
2323
github.com/sirupsen/logrus v1.9.3
2424
github.com/spf13/cobra v1.9.1
2525
go.opentelemetry.io/otel v1.34.0
2626
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.34.0
2727
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.34.0
2828
go.opentelemetry.io/otel/sdk v1.34.0
2929
go.opentelemetry.io/otel/trace v1.34.0
30-
golang.org/x/oauth2 v0.27.0
30+
golang.org/x/oauth2 v0.28.0
3131
google.golang.org/grpc v1.70.0
3232
)
3333

@@ -48,21 +48,27 @@ require (
4848
github.com/beorn7/perks v1.0.1 // indirect
4949
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
5050
github.com/cespare/xxhash/v2 v2.3.0 // indirect
51+
github.com/davecgh/go-spew v1.1.1 // indirect
5152
github.com/go-jose/go-jose/v4 v4.0.2 // indirect
5253
github.com/go-logr/logr v1.4.2 // indirect
5354
github.com/go-logr/stdr v1.2.2 // indirect
55+
github.com/google/go-github/v60 v60.0.0 // indirect
5456
github.com/google/go-querystring v1.1.0 // indirect
5557
github.com/grpc-ecosystem/grpc-gateway/v2 v2.25.1 // indirect
5658
github.com/inconshreveable/mousetrap v1.1.0 // indirect
5759
github.com/klauspost/compress v1.17.11 // indirect
60+
github.com/lib/pq v1.10.9 // indirect
5861
github.com/mattn/go-colorable v0.1.13 // indirect
5962
github.com/mattn/go-isatty v0.0.20 // indirect
6063
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
6164
github.com/pgvector/pgvector-go v0.2.2 // indirect
65+
github.com/pmezard/go-difflib v1.0.0 // indirect
6266
github.com/prometheus/client_model v0.6.1 // indirect
6367
github.com/prometheus/common v0.62.0 // indirect
6468
github.com/prometheus/procfs v0.15.1 // indirect
6569
github.com/spf13/pflag v1.0.6 // indirect
70+
github.com/stretchr/objx v0.5.2 // indirect
71+
github.com/stretchr/testify v1.10.0 // indirect
6672
github.com/tidwall/gjson v1.14.4 // indirect
6773
github.com/tidwall/match v1.1.1 // indirect
6874
github.com/tidwall/pretty v1.2.1 // indirect
@@ -82,4 +88,5 @@ require (
8288
google.golang.org/genproto/googleapis/rpc v0.0.0-20250115164207-1a7da9e5054f // indirect
8389
google.golang.org/protobuf v1.36.3 // indirect
8490
gopkg.in/go-jose/go-jose.v2 v2.6.3 // indirect
91+
gopkg.in/yaml.v3 v3.0.1 // indirect
8592
)

go.sum

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,6 @@ github.com/go-pg/pg/v10 v10.11.0 h1:CMKJqLgTrfpE/aOVeLdybezR2om071Vh38OLZjsyMI0=
6565
github.com/go-pg/pg/v10 v10.11.0/go.mod h1:4BpHRoxE61y4Onpof3x1a2SQvi9c+q1dJnrNdMjsroA=
6666
github.com/go-pg/zerochecker v0.2.0 h1:pp7f72c3DobMWOb2ErtZsnrPaSvHd2W4o9//8HtF4mU=
6767
github.com/go-pg/zerochecker v0.2.0/go.mod h1:NJZ4wKL0NmTtz0GKCoJ8kym6Xn/EQzXRl2OnAe7MmDo=
68-
github.com/golang-jwt/jwt/v4 v4.5.1 h1:JdqV9zKUdtaa9gdPlywC3aeoEsR681PlKC+4F5gQgeo=
69-
github.com/golang-jwt/jwt/v4 v4.5.1/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0=
7068
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
7169
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
7270
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
@@ -104,6 +102,10 @@ github.com/kelseyhightower/envconfig v1.4.0 h1:Im6hONhd3pLkfDFsbRgu68RDNkGF1r3dv
104102
github.com/kelseyhightower/envconfig v1.4.0/go.mod h1:cccZRl6mQpaq41TPp5QxidR+Sa3axMbJDNb//FQX6Gg=
105103
github.com/klauspost/compress v1.17.11 h1:In6xLpyWOi1+C7tXUUWv2ot1QvBjxevKAaI6IXrJmUc=
106104
github.com/klauspost/compress v1.17.11/go.mod h1:pMDklpSncoRMuLFrf1W9Ss9KT+0rH90U12bZKk7uwG0=
105+
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
106+
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
107+
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
108+
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
107109
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
108110
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
109111
github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw=
@@ -129,9 +131,13 @@ github.com/prometheus/common v0.62.0 h1:xasJaQlnWAeyHdUBeGjXmutelfJHWMRr+Fg4QszZ
129131
github.com/prometheus/common v0.62.0/go.mod h1:vyBcEuLSvWos9B1+CyL7JZ2up+uFzXhkqml0W5zIY1I=
130132
github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc=
131133
github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk=
134+
github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII=
135+
github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o=
132136
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
133-
github.com/shaharia-lab/goai v0.11.0 h1:jaR3UVv2UUHM/u3T+v7oW/OxC7AQvPuCgft4dAGylk4=
134-
github.com/shaharia-lab/goai v0.11.0/go.mod h1:EKzvGwFBTL8eLUIw3pTA+X18IMjfy5mncFQXhvQCnAo=
137+
github.com/shaharia-lab/goai v0.11.1 h1:DeUTmNu+pEju+ZtbPzLvoXscRegbiA5aTensngZDpC4=
138+
github.com/shaharia-lab/goai v0.11.1/go.mod h1:EKzvGwFBTL8eLUIw3pTA+X18IMjfy5mncFQXhvQCnAo=
139+
github.com/shaharia-lab/mcp-tools v0.0.2 h1:CwBbn9PS+xhHPpMtpikGwaeoIPlHrCvQqIZZVXzUPEU=
140+
github.com/shaharia-lab/mcp-tools v0.0.2/go.mod h1:cU+z3YZwPITH9FdsbFYddHE6ldjlS5PJpa3F7curt/E=
135141
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
136142
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
137143
github.com/spf13/cobra v1.9.1 h1:CXSaggrXdbHK9CF+8ywj8Amf7PBRmPCOJugH954Nnlo=
@@ -217,8 +223,8 @@ golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk=
217223
golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY=
218224
golang.org/x/net v0.34.0 h1:Mb7Mrk043xzHgnRM88suvJFwzVrRfHEHJEl5/71CKw0=
219225
golang.org/x/net v0.34.0/go.mod h1:di0qlW3YNM5oh6GqDGQr92MyTozJPmybPK4Ev/Gm31k=
220-
golang.org/x/oauth2 v0.27.0 h1:da9Vo7/tDv5RH/7nZDz1eMGS/q1Vv1N/7FCrBhI9I3M=
221-
golang.org/x/oauth2 v0.27.0/go.mod h1:onh5ek6nERTohokkhCD/y2cV4Do3fxFHFuAejCkRWT8=
226+
golang.org/x/oauth2 v0.28.0 h1:CrgCKl8PPAVtLnU3c+EDw6x11699EWlsDeWNWKdIOkc=
227+
golang.org/x/oauth2 v0.28.0/go.mod h1:onh5ek6nERTohokkhCD/y2cV4Do3fxFHFuAejCkRWT8=
222228
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
223229
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
224230
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
@@ -274,6 +280,8 @@ google.golang.org/grpc v1.70.0/go.mod h1:ofIJqVKDXx/JiXrwr2IG4/zwdH9txy3IlF40Rmc
274280
google.golang.org/protobuf v1.36.3 h1:82DV7MYdb8anAVi3qge1wSnMDrnKK7ebr+I0hHRN1BU=
275281
google.golang.org/protobuf v1.36.3/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
276282
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
283+
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
284+
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
277285
gopkg.in/go-jose/go-jose.v2 v2.6.3 h1:nt80fvSDlhKWQgSWyHyy5CfmlQr+asih51R8PTWNKKs=
278286
gopkg.in/go-jose/go-jose.v2 v2.6.3/go.mod h1:zzZDPkNNw/c9IE7Z9jr11mBZQhKQTMzoEEIoEdZlFBI=
279287
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

0 commit comments

Comments
 (0)