Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions server/sse.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,22 @@ func WithBaseURL(baseURL string) SSEOption {
}
}

// WithBasePath adds a new option for setting a static base path
func WithBasePath(basePath string) SSEOption {
// WithStaticBasePath adds a new option for setting a static base path
func WithStaticBasePath(basePath string) SSEOption {
return func(s *SSEServer) {
s.basePath = normalizeURLPath(basePath)
}
}

// WithBasePath adds a new option for setting a static base path.
//
// Deprecated: Use WithStaticBasePath instead. This will be removed in a future version.
//
//go:deprecated
func WithBasePath(basePath string) SSEOption {
return WithStaticBasePath(basePath)
}

// WithDynamicBasePath accepts a function for generating the base path. This is
// useful for cases where the base path is not known at the time of SSE server
// creation, such as when using a reverse proxy or when the server is mounted
Expand Down
6 changes: 3 additions & 3 deletions server/sse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func TestSSEServer(t *testing.T) {
mcpServer := NewMCPServer("test", "1.0.0")
sseServer := NewSSEServer(mcpServer,
WithBaseURL("http://localhost:8080"),
WithBasePath("/mcp"),
WithStaticBasePath("/mcp"),
)

if sseServer == nil {
Expand Down Expand Up @@ -499,7 +499,7 @@ func TestSSEServer(t *testing.T) {

t.Run("works as http.Handler with custom basePath", func(t *testing.T) {
mcpServer := NewMCPServer("test", "1.0.0")
sseServer := NewSSEServer(mcpServer, WithBasePath("/mcp"))
sseServer := NewSSEServer(mcpServer, WithStaticBasePath("/mcp"))

ts := httptest.NewServer(sseServer)
defer ts.Close()
Expand Down Expand Up @@ -717,7 +717,7 @@ func TestSSEServer(t *testing.T) {
useFullURLForMessageEndpoint := false
srv := &http.Server{}
rands := []SSEOption{
WithBasePath(basePath),
WithStaticBasePath(basePath),
WithBaseURL(baseURL),
WithMessageEndpoint(messageEndpoint),
WithUseFullURLForMessageEndpoint(useFullURLForMessageEndpoint),
Expand Down