Skip to content

Commit 86daa78

Browse files
authored
Fix: Add health endpoint, use port 9000 (#750)
Signed-off-by: Daishan Peng <daishan@acorn.io>
1 parent d65f6d8 commit 86daa78

File tree

10 files changed

+114
-49
lines changed

10 files changed

+114
-49
lines changed

microsoft365/calendar-mcp-go/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ WORKDIR /root/
1717

1818
COPY --from=builder /app/calendar-mcp-go .
1919

20-
EXPOSE 3000
20+
EXPOSE 9000
2121

2222
CMD ["./calendar-mcp-go"]

microsoft365/calendar-mcp-go/main.go

Lines changed: 42 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import (
2727
"github.com/modelcontextprotocol/go-sdk/mcp"
2828
)
2929

30-
var httpAddr = flag.String("http", ":3000", "HTTP address to listen on for streamable HTTP server")
30+
var httpAddr = flag.String("http", ":9000", "HTTP address to listen on for streamable HTTP server")
3131

3232
// StaticTokenCredential implements azcore.TokenCredential
3333
type StaticTokenCredential struct {
@@ -131,24 +131,24 @@ const (
131131

132132
// Event detail types for GetEventDetails response
133133
type DetailedEventInfo struct {
134-
ID string `json:"id"`
135-
Subject string `json:"subject"`
136-
Start string `json:"start"`
137-
End string `json:"end"`
138-
Location string `json:"location,omitempty"`
139-
IsOnline bool `json:"is_online"`
140-
Body string `json:"body,omitempty"`
141-
BodyPreview string `json:"body_preview,omitempty"`
142-
Attendees []DetailedAttendeeInfo `json:"attendees,omitempty"`
143-
Organizer *DetailedOrganizerInfo `json:"organizer,omitempty"`
144-
IsAllDay bool `json:"is_all_day"`
145-
ShowAs string `json:"show_as,omitempty"`
146-
Sensitivity string `json:"sensitivity,omitempty"`
147-
Importance string `json:"importance,omitempty"`
148-
Categories []string `json:"categories,omitempty"`
149-
Recurrence map[string]interface{} `json:"recurrence,omitempty"`
150-
Attachments []DetailedAttachmentInfo `json:"attachments,omitempty"`
151-
OnlineMeetingUrl string `json:"online_meeting_url,omitempty"`
134+
ID string `json:"id"`
135+
Subject string `json:"subject"`
136+
Start string `json:"start"`
137+
End string `json:"end"`
138+
Location string `json:"location,omitempty"`
139+
IsOnline bool `json:"is_online"`
140+
Body string `json:"body,omitempty"`
141+
BodyPreview string `json:"body_preview,omitempty"`
142+
Attendees []DetailedAttendeeInfo `json:"attendees,omitempty"`
143+
Organizer *DetailedOrganizerInfo `json:"organizer,omitempty"`
144+
IsAllDay bool `json:"is_all_day"`
145+
ShowAs string `json:"show_as,omitempty"`
146+
Sensitivity string `json:"sensitivity,omitempty"`
147+
Importance string `json:"importance,omitempty"`
148+
Categories []string `json:"categories,omitempty"`
149+
Recurrence map[string]interface{} `json:"recurrence,omitempty"`
150+
Attachments []DetailedAttachmentInfo `json:"attachments,omitempty"`
151+
OnlineMeetingUrl string `json:"online_meeting_url,omitempty"`
152152
}
153153

154154
type DetailedAttendeeInfo struct {
@@ -275,13 +275,13 @@ func (c *CalendarMCPServer) ListEvents(ctx context.Context, req *mcp.CallToolReq
275275
}
276276

277277
type EventInfo struct {
278-
ID string `json:"id"`
279-
Subject string `json:"subject"`
280-
Start string `json:"start"`
281-
End string `json:"end"`
282-
Location string `json:"location,omitempty"`
283-
IsOnline bool `json:"is_online"`
284-
Body string `json:"body,omitempty"`
278+
ID string `json:"id"`
279+
Subject string `json:"subject"`
280+
Start string `json:"start"`
281+
End string `json:"end"`
282+
Location string `json:"location,omitempty"`
283+
IsOnline bool `json:"is_online"`
284+
Body string `json:"body,omitempty"`
285285
Attendees []string `json:"attendees,omitempty"`
286286
}
287287

@@ -1456,12 +1456,25 @@ func main() {
14561456
}
14571457

14581458
if *httpAddr != "" {
1459-
handler := mcp.NewStreamableHTTPHandler(serverFactory, nil)
1459+
mcpHandler := mcp.NewStreamableHTTPHandler(serverFactory, nil)
14601460
log.Printf("Calendar MCP server listening at %s", *httpAddr)
1461-
if err := http.ListenAndServe(*httpAddr, handler); err != nil {
1461+
1462+
// Create a custom multiplexer
1463+
mux := http.NewServeMux()
1464+
1465+
// Handle /health with custom handler
1466+
mux.HandleFunc("/health", func(w http.ResponseWriter, r *http.Request) {
1467+
w.WriteHeader(http.StatusOK)
1468+
w.Write([]byte("OK"))
1469+
})
1470+
1471+
// Handle all other paths with MCP handler
1472+
mux.Handle("/", mcpHandler)
1473+
1474+
if err := http.ListenAndServe(*httpAddr, mux); err != nil {
14621475
log.Fatal(err)
14631476
}
14641477
} else {
14651478
log.Fatal("HTTP address is required")
14661479
}
1467-
}
1480+
}

microsoft365/contact-mcp-go/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ WORKDIR /root/
1717

1818
COPY --from=builder /app/contact-mcp-go .
1919

20-
EXPOSE 3000
20+
EXPOSE 9000
2121

2222
CMD ["./contact-mcp-go"]

microsoft365/contact-mcp-go/main.go

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121
"github.com/modelcontextprotocol/go-sdk/mcp"
2222
)
2323

24-
var httpAddr = flag.String("http", ":3000", "HTTP address to listen on for streamable HTTP server")
24+
var httpAddr = flag.String("http", ":9000", "HTTP address to listen on for streamable HTTP server")
2525

2626
// StaticTokenCredential implements azcore.TokenCredential
2727
type StaticTokenCredential struct {
@@ -183,9 +183,9 @@ func (c *ContactMCPServer) CreateContact(ctx context.Context, req *mcp.CallToolR
183183
}
184184

185185
// Validate that at least one field is provided
186-
if (args.GivenName == nil || *args.GivenName == "") &&
187-
(args.Surname == nil || *args.Surname == "") &&
188-
len(emails) == 0 && len(phones) == 0 {
186+
if (args.GivenName == nil || *args.GivenName == "") &&
187+
(args.Surname == nil || *args.Surname == "") &&
188+
len(emails) == 0 && len(phones) == 0 {
189189
return &mcp.CallToolResult{
190190
Content: []mcp.Content{
191191
&mcp.TextContent{
@@ -458,9 +458,22 @@ func main() {
458458
}
459459

460460
if *httpAddr != "" {
461-
handler := mcp.NewStreamableHTTPHandler(serverFactory, nil)
461+
mcpHandler := mcp.NewStreamableHTTPHandler(serverFactory, nil)
462462
log.Printf("Contact MCP server listening at %s", *httpAddr)
463-
if err := http.ListenAndServe(*httpAddr, handler); err != nil {
463+
464+
// Create a custom multiplexer
465+
mux := http.NewServeMux()
466+
467+
// Handle /health with custom handler
468+
mux.HandleFunc("/health", func(w http.ResponseWriter, r *http.Request) {
469+
w.WriteHeader(http.StatusOK)
470+
w.Write([]byte("OK"))
471+
})
472+
473+
// Handle all other paths with MCP handler
474+
mux.Handle("/", mcpHandler)
475+
476+
if err := http.ListenAndServe(*httpAddr, mux); err != nil {
464477
log.Fatal(err)
465478
}
466479
} else {

microsoft365/excel-mcp-go/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ WORKDIR /root/
1717

1818
COPY --from=builder /app/excel-mcp-go .
1919

20-
EXPOSE 3000
20+
EXPOSE 9000
2121

2222
CMD ["./excel-mcp-go"]

microsoft365/excel-mcp-go/main.go

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
util "github.com/obot-platform/tools/microsoft365/excel-mcp-go/utils"
2525
)
2626

27-
var httpAddr = flag.String("http", ":3000", "HTTP address to listen on for streamable HTTP server")
27+
var httpAddr = flag.String("http", ":9000", "HTTP address to listen on for streamable HTTP server")
2828

2929
// StaticTokenCredential implements azcore.TokenCredential
3030
type StaticTokenCredential struct {
@@ -736,9 +736,22 @@ func main() {
736736
}
737737

738738
if *httpAddr != "" {
739-
handler := mcp.NewStreamableHTTPHandler(serverFactory, nil)
739+
mcpHandler := mcp.NewStreamableHTTPHandler(serverFactory, nil)
740740
log.Printf("Excel MCP server listening at %s", *httpAddr)
741-
if err := http.ListenAndServe(*httpAddr, handler); err != nil {
741+
742+
// Create a custom multiplexer
743+
mux := http.NewServeMux()
744+
745+
// Handle /health with custom handler
746+
mux.HandleFunc("/health", func(w http.ResponseWriter, r *http.Request) {
747+
w.WriteHeader(http.StatusOK)
748+
w.Write([]byte("OK"))
749+
})
750+
751+
// Handle all other paths with MCP handler
752+
mux.Handle("/", mcpHandler)
753+
754+
if err := http.ListenAndServe(*httpAddr, mux); err != nil {
742755
log.Fatal(err)
743756
}
744757
} else {

microsoft365/onedrive-mcp-go/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ WORKDIR /root/
1717

1818
COPY --from=builder /app/onedrive-mcp-go .
1919

20-
EXPOSE 3000
20+
EXPOSE 9000
2121

2222
CMD ["./onedrive-mcp-go"]

microsoft365/onedrive-mcp-go/main.go

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import (
2323
"github.com/modelcontextprotocol/go-sdk/mcp"
2424
)
2525

26-
var httpAddr = flag.String("http", ":3000", "HTTP address to listen on for streamable HTTP server")
26+
var httpAddr = flag.String("http", ":9000", "HTTP address to listen on for streamable HTTP server")
2727

2828
// StaticTokenCredential implements azcore.TokenCredential
2929
type StaticTokenCredential struct {
@@ -860,9 +860,22 @@ func main() {
860860
}
861861

862862
if *httpAddr != "" {
863-
handler := mcp.NewStreamableHTTPHandler(serverFactory, nil)
863+
mcpHandler := mcp.NewStreamableHTTPHandler(serverFactory, nil)
864864
log.Printf("OneDrive MCP server listening at %s", *httpAddr)
865-
if err := http.ListenAndServe(*httpAddr, handler); err != nil {
865+
866+
// Create a custom multiplexer
867+
mux := http.NewServeMux()
868+
869+
// Handle /health with custom handler
870+
mux.HandleFunc("/health", func(w http.ResponseWriter, r *http.Request) {
871+
w.WriteHeader(http.StatusOK)
872+
w.Write([]byte("OK"))
873+
})
874+
875+
// Handle all other paths with MCP handler
876+
mux.Handle("/", mcpHandler)
877+
878+
if err := http.ListenAndServe(*httpAddr, mux); err != nil {
866879
log.Fatal(err)
867880
}
868881
} else {

microsoft365/word-mcp-go/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ RUN chmod +x word-mcp-go
4343
# Switch to non-root user (but keep as root for now due to temp file access needs)
4444
# USER appuser
4545

46-
EXPOSE 3000
46+
EXPOSE 9000
4747

4848
# Set environment variables for LibreOffice
4949
ENV HOME=/tmp

microsoft365/word-mcp-go/main.go

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import (
2727
"github.com/modelcontextprotocol/go-sdk/mcp"
2828
)
2929

30-
var httpAddr = flag.String("http", ":3000", "HTTP address to listen on for streamable HTTP server")
30+
var httpAddr = flag.String("http", ":9000", "HTTP address to listen on for streamable HTTP server")
3131

3232
// StaticTokenCredential implements azcore.TokenCredential
3333
type StaticTokenCredential struct {
@@ -628,9 +628,22 @@ func main() {
628628
}
629629

630630
if *httpAddr != "" {
631-
handler := mcp.NewStreamableHTTPHandler(serverFactory, nil)
631+
mcpHandler := mcp.NewStreamableHTTPHandler(serverFactory, nil)
632632
log.Printf("Word MCP server listening at %s", *httpAddr)
633-
if err := http.ListenAndServe(*httpAddr, handler); err != nil {
633+
634+
// Create a custom multiplexer
635+
mux := http.NewServeMux()
636+
637+
// Handle /health with custom handler
638+
mux.HandleFunc("/health", func(w http.ResponseWriter, r *http.Request) {
639+
w.WriteHeader(http.StatusOK)
640+
w.Write([]byte("OK"))
641+
})
642+
643+
// Handle all other paths with MCP handler
644+
mux.Handle("/", mcpHandler)
645+
646+
if err := http.ListenAndServe(*httpAddr, mux); err != nil {
634647
log.Fatal(err)
635648
}
636649
} else {

0 commit comments

Comments
 (0)