@@ -4,12 +4,14 @@ import (
44 "context"
55 "testing"
66
7+ ghcontext "github.com/github/github-mcp-server/pkg/context"
78 "github.com/modelcontextprotocol/go-sdk/mcp"
89 "github.com/stretchr/testify/assert"
910)
1011
1112func Test_clientSupportsUI (t * testing.T ) {
1213 t .Parallel ()
14+ ctx := context .Background ()
1315
1416 tests := []struct {
1517 name string
@@ -25,22 +27,23 @@ func Test_clientSupportsUI(t *testing.T) {
2527 for _ , tt := range tests {
2628 t .Run (tt .name , func (t * testing.T ) {
2729 req := createMCPRequestWithSession (t , tt .clientName , nil )
28- assert .Equal (t , tt .want , clientSupportsUI (& req ))
30+ assert .Equal (t , tt .want , clientSupportsUI (ctx , & req ))
2931 })
3032 }
3133
3234 t .Run ("nil request" , func (t * testing.T ) {
33- assert .False (t , clientSupportsUI (nil ))
35+ assert .False (t , clientSupportsUI (ctx , nil ))
3436 })
3537
3638 t .Run ("nil session" , func (t * testing.T ) {
3739 req := createMCPRequest (nil )
38- assert .False (t , clientSupportsUI (& req ))
40+ assert .False (t , clientSupportsUI (ctx , & req ))
3941 })
4042}
4143
4244func Test_clientSupportsUI_nilClientInfo (t * testing.T ) {
4345 t .Parallel ()
46+ ctx := context .Background ()
4447
4548 srv := mcp .NewServer (& mcp.Implementation {Name : "test" }, nil )
4649 st , _ := mcp .NewInMemoryTransports ()
@@ -57,5 +60,23 @@ func Test_clientSupportsUI_nilClientInfo(t *testing.T) {
5760 t .Cleanup (func () { _ = session .Close () })
5861
5962 req := mcp.CallToolRequest {Session : session }
60- assert .False (t , clientSupportsUI (& req ))
63+ assert .False (t , clientSupportsUI (ctx , & req ))
64+ }
65+
66+ func Test_clientSupportsUI_fromContext (t * testing.T ) {
67+ t .Parallel ()
68+
69+ t .Run ("supported client in context" , func (t * testing.T ) {
70+ ctx := ghcontext .WithClientName (context .Background (), "Visual Studio Code - Insiders" )
71+ assert .True (t , clientSupportsUI (ctx , nil ))
72+ })
73+
74+ t .Run ("unsupported client in context" , func (t * testing.T ) {
75+ ctx := ghcontext .WithClientName (context .Background (), "some-other-client" )
76+ assert .False (t , clientSupportsUI (ctx , nil ))
77+ })
78+
79+ t .Run ("no client in context or session" , func (t * testing.T ) {
80+ assert .False (t , clientSupportsUI (context .Background (), nil ))
81+ })
6182}
0 commit comments