@@ -19,7 +19,10 @@ import (
1919 "testing"
2020
2121 "github.com/mark3labs/mcp-go/mcp"
22+ "github.com/streamnative/pulsarctl/pkg/cmdutils"
2223 "github.com/streamnative/streamnative-mcp-server/pkg/mcp/builders"
24+ mcpCtx "github.com/streamnative/streamnative-mcp-server/pkg/mcp/internal/context"
25+ pulsarsession "github.com/streamnative/streamnative-mcp-server/pkg/pulsar"
2326 "github.com/stretchr/testify/assert"
2427 "github.com/stretchr/testify/require"
2528)
@@ -56,4 +59,26 @@ func TestPulsarAdminStatusToolBuilder(t *testing.T) {
5659 require .NotNil (t , result )
5760 assert .True (t , result .IsError )
5861 })
62+
63+ t .Run ("Handler_EmptyWebServiceURL" , func (t * testing.T ) {
64+ tools , err := builder .BuildTools (context .Background (), builders.ToolBuildConfig {
65+ Features : []string {"pulsar-admin-brokers-status" },
66+ })
67+ require .NoError (t , err )
68+ require .Len (t , tools , 1 )
69+
70+ ctx := mcpCtx .WithPulsarSession (context .Background (), & pulsarsession.Session {
71+ PulsarCtlConfig : & cmdutils.ClusterConfig {},
72+ })
73+
74+ result , callErr := tools [0 ].Handler (ctx , mcp.CallToolRequest {})
75+ require .NoError (t , callErr )
76+ require .NotNil (t , result )
77+ assert .True (t , result .IsError )
78+ require .Len (t , result .Content , 1 )
79+
80+ text , ok := result .Content [0 ].(mcp.TextContent )
81+ require .True (t , ok )
82+ assert .Contains (t , text .Text , "Please set the cluster context first" )
83+ })
5984}
0 commit comments