Skip to content

Commit 2161e02

Browse files
authored
Merge pull request #11 from FreePeak/feat/switch-mcp-core-server-to-cortex
Feat: switch mcp core server to cortex platform
2 parents e6d6637 + cb2f1c1 commit 2161e02

26 files changed

+2112
-560
lines changed

Diff for: .DS_Store

6 KB
Binary file not shown.

Diff for: .cursor/mcp.json

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
{
22
"mcpServers": {
3-
"cashflow-db-mcp-server-sse": {
3+
"db-mcp-server-sse": {
44
"url": "http://127.0.0.1:9090/sse"
5+
},
6+
"db-mcp-server-stdio": {
7+
"command": "./server -t stdio -c ./config.json"
8+
},
9+
"db-mcp-server-docker-sse": {
10+
"url": "http://127.0.0.1:9092/sse"
511
}
612
}
713
}

Diff for: .golangci.yml

+17-1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,14 @@ linters-settings:
3131
- name: exported
3232
severity: warning
3333
disabled: false
34+
errcheck:
35+
# Report about not checking of errors in type assertions: `a := b.(MyStruct)`.
36+
check-type-assertions: true
37+
# Report about assignment of errors to blank identifier: `num, _ := strconv.Atoi(numStr)`.
38+
check-blank: true
39+
# List of functions to exclude from error checking (useful for os.Setenv)
40+
exclude-functions:
41+
- os.Setenv
3442

3543
issues:
3644
exclude-use-default: false
@@ -39,4 +47,12 @@ issues:
3947
exclude-dirs:
4048
- vendor/
4149
exclude:
42-
- "exported \\w+ (\\S*['.]*)([a-zA-Z'.*]*) should have comment or be unexported"
50+
- "exported \\w+ (\\S*['.]*)([a-zA-Z'.*]*) should have comment or be unexported"
51+
# Excluding the specific errors that are reported but that we can't reproduce locally
52+
exclude-rules:
53+
- path: internal/delivery/mcp/tool_registry.go
54+
text: "Error return value of `tr.registerTool` is not checked"
55+
- path: internal/delivery/mcp/tool_registry.go
56+
text: "Error return value of `tr.createToolAlias` is not checked"
57+
- path: cmd/server/main.go
58+
text: "Error return value of `os.Setenv` is not checked"

Diff for: Dockerfile

+21-9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.22-alpine AS builder
1+
FROM golang:1.24-alpine AS builder
22

33
# Install necessary build tools
44
RUN apk add --no-cache make gcc musl-dev
@@ -22,22 +22,34 @@ RUN make build
2222
FROM alpine:latest
2323

2424
# Add necessary runtime packages
25-
RUN apk add --no-cache ca-certificates tzdata
25+
RUN apk add --no-cache ca-certificates tzdata bash
2626

2727
# Set the working directory
2828
WORKDIR /app
2929

3030
# Copy the built binary from the builder stage
31-
COPY --from=builder /app/mcp-server /app/mcp-server
31+
COPY --from=builder /app/server /app/server
3232

33-
# Copy example .env file (can be overridden with volume mounts)
34-
COPY .env.example /app/.env
33+
# Copy default config file
34+
COPY config.json /app/config.json
3535

36-
# Expose the server port (default in the .env file is 9090)
37-
EXPOSE 9090
36+
# Create data and logs directories
37+
RUN mkdir -p /app/data /app/logs
3838

39-
# Command to run the application in SSE mode
40-
ENTRYPOINT ["/app/mcp-server", "-t", "sse"]
39+
# Set environment variables
40+
ENV SERVER_PORT=9092
41+
ENV TRANSPORT_MODE=sse
42+
ENV CONFIG_PATH=/app/config.json
43+
ENV MCP_TOOL_PREFIX=mcp_cashflow_db_mcp_server_sse_
44+
45+
# Expose server port
46+
EXPOSE 9092
47+
48+
# Provide a volume for configuration and logs
49+
VOLUME ["/app/config.json", "/app/logs"]
50+
51+
# Start the MCP server with proper configuration
52+
CMD ["/bin/bash", "-c", "/app/server -t ${TRANSPORT_MODE} -p ${SERVER_PORT} -c ${CONFIG_PATH}"]
4153

4254
# You can override the port by passing it as a command-line argument
4355
# docker run -p 8080:8080 db-mcp-server -port 8080

Diff for: Makefile

+19-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.PHONY: build run-stdio run-sse clean test client client-simple test-script build-example
1+
.PHONY: build run-stdio run-sse clean test client client-simple test-script build-example docker-build docker-run docker-run-stdio docker-stop
22

33
# Build the server
44
build:
@@ -33,7 +33,7 @@ test-script:
3333

3434
# Run tests
3535
test:
36-
go test ./...
36+
go test ./... -race -cover -count=1
3737

3838
# Clean build artifacts
3939
clean:
@@ -49,5 +49,22 @@ setup:
4949
go mod tidy
5050
go mod download
5151

52+
# Docker targets
53+
docker-build:
54+
docker build -t db-mcp-server:latest .
55+
56+
# Run the Docker container in SSE mode
57+
docker-run:
58+
docker run -d --name db-mcp-server -p 9092:9092 -v $(PWD)/config.json:/app/config.json -v $(PWD)/logs:/app/logs db-mcp-server:latest
59+
60+
# Run Docker container in STDIO mode (for debugging)
61+
docker-run-stdio:
62+
docker run -it --rm --name db-mcp-server-stdio -v $(PWD)/config.json:/app/config.json -e TRANSPORT_MODE=stdio db-mcp-server:latest
63+
64+
# Stop and remove the Docker container
65+
docker-stop:
66+
docker stop db-mcp-server || true
67+
docker rm db-mcp-server || true
68+
5269
# Default target
5370
all: build

0 commit comments

Comments
 (0)