diff --git a/server/sse.go b/server/sse.go index 90fde667..8467b02f 100644 --- a/server/sse.go +++ b/server/sse.go @@ -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 diff --git a/server/sse_test.go b/server/sse_test.go index 937dc274..9196c8fe 100644 --- a/server/sse_test.go +++ b/server/sse_test.go @@ -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 { @@ -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() @@ -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),