Skip to content

Commit 402f798

Browse files
authored
Merge pull request #65 from eaugene/streamableSupport
Adding support for streamable MCP server
2 parents 3d028cc + 6b306e6 commit 402f798

3 files changed

Lines changed: 31 additions & 5 deletions

File tree

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,20 @@ When the threshold is exceeded, the `get_job_logs` tool will:
384384

385385
---
386386

387+
## 🌐 Streamable HTTP / SSE transport
388+
389+
You can also run the MCP server using the Streamable HTTP Transport, and connect to the MCP server at <http://localhost:3000/mcp>.
390+
391+
```sh
392+
buildkite-mcp-server http --listen "localhost:3000" --api-token=${BUILDKITE_API_TOKEN}
393+
```
394+
395+
Or with the legacy HTTP/SSE transport, and connect to the MCP server at <http://localhost:3000/sse>.
396+
397+
```sh
398+
buildkite-mcp-server http --listen "localhost:3000" --use-sse --api-token=${BUILDKITE_API_TOKEN}
399+
```
400+
387401
## 📸 Screenshots
388402

389403
![Get Pipeline Tool](docs/images/get_pipeline.png)

cmd/buildkite-mcp-server/main.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ var (
1818

1919
cli struct {
2020
Stdio commands.StdioCmd `cmd:"" help:"stdio mcp server."`
21-
HTTP commands.HTTPCmd `cmd:"" help:"http mcp server."`
21+
HTTP commands.HTTPCmd `cmd:"" help:"http mcp server. (pass --use-sse to use SSE transport"`
2222
Tools commands.ToolsCmd `cmd:"" help:"list available tools." hidden:""`
2323
APIToken string `help:"The Buildkite API token to use." env:"BUILDKITE_API_TOKEN"`
2424
BaseURL string `help:"The base URL of the Buildkite API to use." env:"BUILDKITE_BASE_URL" default:"https://api.buildkite.com/"`
@@ -47,6 +47,8 @@ func main() {
4747
if cli.Debug {
4848
logger = logger.Level(zerolog.DebugLevel).With().Caller().Logger()
4949
}
50+
log.Logger = logger
51+
zerolog.DefaultContextLogger = &logger
5052

5153
tp, err := trace.NewProvider(ctx, "buildkite-mcp-server", version)
5254
if err != nil {

internal/commands/http.go

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package commands
22

33
import (
44
"context"
5+
"fmt"
56

67
"github.com/buildkite/buildkite-mcp-server/pkg/server"
78
mcpserver "github.com/mark3labs/mcp-go/server"
@@ -10,15 +11,24 @@ import (
1011

1112
type HTTPCmd struct {
1213
Listen string `help:"The address to listen on." default:"localhost:3000"`
14+
UseSSE bool `help:"Use deprecated SSS transport instead of Streamable HTTP." default:"false"`
1315
}
1416

1517
func (c *HTTPCmd) Run(ctx context.Context, globals *Globals) error {
16-
1718
mcpServer := server.NewMCPServer(globals.Version, globals.Client, globals.BuildkiteLogsClient)
19+
logEvent := log.Ctx(ctx).Info().Str("address", c.Listen)
1820

19-
httpServer := mcpserver.NewSSEServer(mcpServer)
21+
if c.UseSSE {
22+
httpServer := mcpserver.NewSSEServer(mcpServer)
23+
endpoint := fmt.Sprintf("http://%s%s", c.Listen, httpServer.CompleteSsePath())
24+
logEvent.Str("transport", "sse").Str("endpoint", endpoint).Msg("Starting SSE HTTP server")
2025

21-
log.Ctx(ctx).Info().Str("address", c.Listen).Msg("Starting HTTP server")
26+
return httpServer.Start(c.Listen)
27+
} else {
28+
httpServer := mcpserver.NewStreamableHTTPServer(mcpServer)
29+
endpoint := fmt.Sprintf("http://%s/mcp", c.Listen)
30+
logEvent.Str("transport", "streamable-http").Str("endpoint", endpoint).Msg("Starting streamable HTTP server")
2231

23-
return httpServer.Start(c.Listen)
32+
return httpServer.Start(c.Listen)
33+
}
2434
}

0 commit comments

Comments
 (0)