Skip to content

refactor(server/sse): rename WithBasePath to WithStaticBasePath #238

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 4, 2025
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