feat: added new http streamable option instead of deprecated sse

This commit is contained in:
iamatulsingh
2026-03-26 09:09:50 +01:00
parent b136334953
commit f10176ffa7
4 changed files with 24 additions and 27 deletions
+6 -6
View File
@@ -4,7 +4,7 @@ A lightweight, WhatsApp MCP server and bridge — rewritten entirely in Go for s
This project is a reimagining of the original **[whatsapp-mcp](https://github.com/lharries/whatsapp-mcp)** by **lharries**, who created the first WhatsApp MCP bridge using a Python MCP server and a Go WhatsApp client powered by **WhatsMeow**. Their work demonstrated how Claude Desktop could interact with WhatsApp through the MCP protocol, and this project would not exist without that foundation.
Start `whatsapp-bridge` -> then run `whatsapp-mcp-server` in your preferred mode (STDIO or SSE).
Start `whatsapp-bridge` -> then run `whatsapp-mcp-server` in your preferred mode (STDIO or HTTP).
| Connector | Chat |
|------------|----------|
@@ -42,7 +42,7 @@ Start `whatsapp-bridge` -> then run `whatsapp-mcp-server` in your preferred mode
cd whatsapp-mcp-server
go build -o whatsapp-mcp
```
Copy the below json with the appropriate {{PATH}} values:
Copy the below json with the appropriate {{PROJECT_BASE_PATH}} value:
```json
{
"mcpServers": {
@@ -87,7 +87,7 @@ If you're running this project on Windows, be aware that `go-sqlite3` requires *
```bash
cd whatsapp-bridge
go env -w CGO_ENABLED=1
go run main.go
go run main.go # or use this to enabled webhook and http streaming, `WEBHOOK_URL=http://192.168.178.119:5777/sse IS_HTTP=true go run main.go`
```
OR
@@ -220,7 +220,7 @@ Moving all database logic into the bridge
* **SQLite or PostgreSQL — Your Choice**
The original project only supported SQLite.
* **Two Communication Modes: STDIO + SSE** The original project was built only for Claude Desktop (STDIO MCP). This makes the project usable far beyond Claude Desktop.
* **Two Communication Modes: STDIO + HTTP** The original project was built only for Claude Desktop (STDIO MCP). This makes the project usable far beyond Claude Desktop.
* **Docker Support** This makes deployment trivial on:
- servers
@@ -236,7 +236,7 @@ The original project only supported SQLite.
- Pure Go MCP server
- Clean API boundary between MCP and bridge
- SQLite or PostgreSQL support
- STDIO + SSE modes
- STDIO + HTTP modes
- Lightweight Docker image
- Easy deployment with Docker Compose
- No Python dependencies
@@ -273,7 +273,7 @@ Choose this version if you want:
- a portable binary
- Docker support
- PostgreSQL support
- SSE support for automation workflows
- HTTP support for automation workflows
- a more maintainable and extensible project
The goal is not to replace the original project but to offer an alternative that fits different needs — especially for developers who prefer Go or want to deploy MCPbased WhatsApp automation in production environments.
+3 -3
View File
@@ -3,15 +3,15 @@ module whatsapp-mcp-server
go 1.25.0
require (
github.com/golang-jwt/jwt/v5 v5.2.2
github.com/golang-jwt/jwt/v5 v5.3.0
github.com/mattn/go-sqlite3 v1.14.34
github.com/modelcontextprotocol/go-sdk v1.3.1
github.com/modelcontextprotocol/go-sdk v1.4.1
)
require (
github.com/google/jsonschema-go v0.4.2 // indirect
github.com/segmentio/asm v1.2.1 // indirect
github.com/segmentio/encoding v0.5.3 // indirect
github.com/segmentio/encoding v0.5.4 // indirect
github.com/yosida95/uritemplate/v3 v3.0.2 // indirect
golang.org/x/oauth2 v0.35.0 // indirect
golang.org/x/sys v0.41.0 // indirect
+8 -8
View File
@@ -1,22 +1,22 @@
github.com/golang-jwt/jwt/v5 v5.2.2 h1:Rl4B7itRWVtYIHFrSNd7vhTiz9UpLdi6gZhZ3wEeDy8=
github.com/golang-jwt/jwt/v5 v5.2.2/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk=
github.com/golang-jwt/jwt/v5 v5.3.0 h1:pv4AsKCKKZuqlgs5sUmn4x8UlGa0kEVt/puTpKx9vvo=
github.com/golang-jwt/jwt/v5 v5.3.0/go.mod h1:fxCRLWMO43lRc8nhHWY6LGqRcf+1gQWArsqaEUEa5bE=
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
github.com/google/jsonschema-go v0.4.2 h1:tmrUohrwoLZZS/P3x7ex0WAVknEkBZM46iALbcqoRA8=
github.com/google/jsonschema-go v0.4.2/go.mod h1:r5quNTdLOYEz95Ru18zA0ydNbBuYoo9tgaYcxEYhJVE=
github.com/mattn/go-sqlite3 v1.14.34 h1:3NtcvcUnFBPsuRcno8pUtupspG/GM+9nZ88zgJcp6Zk=
github.com/mattn/go-sqlite3 v1.14.34/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=
github.com/modelcontextprotocol/go-sdk v1.3.1 h1:TfqtNKOIWN4Z1oqmPAiWDC2Jq7K9OdJaooe0teoXASI=
github.com/modelcontextprotocol/go-sdk v1.3.1/go.mod h1:DgVX498dMD8UJlseK1S5i1T4tFz2fkBk4xogC3D15nw=
github.com/modelcontextprotocol/go-sdk v1.4.1 h1:M4x9GyIPj+HoIlHNGpK2hq5o3BFhC+78PkEaldQRphc=
github.com/modelcontextprotocol/go-sdk v1.4.1/go.mod h1:Bo/mS87hPQqHSRkMv4dQq1XCu6zv4INdXnFZabkNU6s=
github.com/segmentio/asm v1.2.1 h1:DTNbBqs57ioxAD4PrArqftgypG4/qNpXoJx8TVXxPR0=
github.com/segmentio/asm v1.2.1/go.mod h1:BqMnlJP91P8d+4ibuonYZw9mfnzI9HfxselHZr5aAcs=
github.com/segmentio/encoding v0.5.3 h1:OjMgICtcSFuNvQCdwqMCv9Tg7lEOXGwm1J5RPQccx6w=
github.com/segmentio/encoding v0.5.3/go.mod h1:HS1ZKa3kSN32ZHVZ7ZLPLXWvOVIiZtyJnO1gPH1sKt0=
github.com/segmentio/encoding v0.5.4 h1:OW1VRern8Nw6ITAtwSZ7Idrl3MXCFwXHPgqESYfvNt0=
github.com/segmentio/encoding v0.5.4/go.mod h1:HS1ZKa3kSN32ZHVZ7ZLPLXWvOVIiZtyJnO1gPH1sKt0=
github.com/yosida95/uritemplate/v3 v3.0.2 h1:Ed3Oyj9yrmi9087+NczuL5BwkIc4wvTb5zIM+UJPGz4=
github.com/yosida95/uritemplate/v3 v3.0.2/go.mod h1:ILOh0sOhIJR3+L/8afwt/kE++YT040gmv5BQTMR2HP4=
golang.org/x/oauth2 v0.35.0 h1:Mv2mzuHuZuY2+bkyWXIHMfhNdJAdwW3FuWeCPYN5GVQ=
golang.org/x/oauth2 v0.35.0/go.mod h1:lzm5WQJQwKZ3nwavOZ3IS5Aulzxi68dUSgRHujetwEA=
golang.org/x/sys v0.41.0 h1:Ivj+2Cp/ylzLiEU89QhWblYnOE9zerudt9Ftecq2C6k=
golang.org/x/sys v0.41.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
golang.org/x/tools v0.34.0 h1:qIpSLOxeCYGg9TrcJokLBG4KFA6d795g0xkBkiESGlo=
golang.org/x/tools v0.34.0/go.mod h1:pAP9OwEaY1CAW3HOmg3hLZC5Z0CCmzjAF2UQMSqNARg=
golang.org/x/tools v0.41.0 h1:a9b8iMweWG+S0OBnlU36rzLp20z1Rp10w+IY2czHTQc=
golang.org/x/tools v0.41.0/go.mod h1:XSY6eDqxVNiYgezAVqqCeihT4j1U2CCsqvH3WhQpnlg=
+7 -10
View File
@@ -82,23 +82,20 @@ func InitMcpTool() {
Description: "Download media from a WhatsApp message and return local file path.",
}, downloadMediaHandler)
isSSE := strings.ToLower(ReadEnv("IS_SSE", "false")) == "true" ||
strings.ToLower(ReadEnv("IS_SSE", "0")) == "1"
isHttp := strings.ToLower(ReadEnv("IS_HTTP", "false")) == "true" ||
strings.ToLower(ReadEnv("IS_HTTP", "0")) == "1"
ctx := context.Background()
if isSSE {
addr := ReadEnv("SSE_BASE_URL", "0.0.0.0:5777")
slog.Info("Starting WhatsApp MCP HTTP server (SSE)", "addr", addr)
if isHttp {
addr := ReadEnv("HTTP_BASE_URL", "0.0.0.0:5777")
slog.Info("Starting WhatsApp MCP HTTP streaming", "addr", addr)
handler := mcp.NewSSEHandler(func(request *http.Request) *mcp.Server {
// A logic can be added here to return different servers based on URL path
// For now, it returns the same WhatsApp server for the root/default path
handler := mcp.NewStreamableHTTPHandler(func(req *http.Request) *mcp.Server {
return server
}, nil)
if err := http.ListenAndServe(addr, handler); err != nil {
log.Fatalf("http server failed: %v", err)
log.Fatalf("Server failed: %v", err)
}
} else {
slog.Info("Starting WhatsApp MCP server in stdio mode")