1
1
package filesystemserver_test
2
2
3
3
import (
4
- "context"
5
4
"testing"
6
5
7
6
"github.com/mark3labs/mcp-filesystem-server/filesystemserver"
8
- "github.com/mark3labs/mcp-go/client"
9
- "github.com/mark3labs/mcp-go/mcp"
10
7
"github.com/stretchr/testify/assert"
11
8
"github.com/stretchr/testify/require"
12
9
)
@@ -15,37 +12,9 @@ func TestInProcess(t *testing.T) {
15
12
fss , err := filesystemserver .NewFilesystemServer ([]string {"." })
16
13
require .NoError (t , err )
17
14
18
- mcpClient , err := client .NewInProcessClient (fss )
19
- require .NoError (t , err )
20
-
21
- err = mcpClient .Start (context .Background ())
22
- require .NoError (t , err )
23
-
24
- // Initialize the client
25
- initRequest := mcp.InitializeRequest {}
26
- initRequest .Params .ProtocolVersion = mcp .LATEST_PROTOCOL_VERSION
27
- initRequest .Params .ClientInfo = mcp.Implementation {
28
- Name : "test-client" ,
29
- Version : "1.0.0" ,
30
- }
31
- result , err := mcpClient .Initialize (context .Background (), initRequest )
32
- require .NoError (t , err )
33
- assert .Equal (t , "secure-filesystem-server" , result .ServerInfo .Name )
34
- assert .Equal (t , filesystemserver .Version , result .ServerInfo .Version )
15
+ mcpClient := startTestClient (t , fss )
35
16
36
17
// just check for a specific tool
37
- toolListResult , err := mcpClient .ListTools (context .Background (), mcp.ListToolsRequest {})
38
- require .NoError (t , err )
39
- assert .NotEmpty (t , toolListResult .Tools )
40
- found := false
41
- for _ , tool := range toolListResult .Tools {
42
- if tool .Name == "read_file" {
43
- found = true
44
- break
45
- }
46
- }
47
- assert .True (t , found , "read_file tool not found in the list of tools" )
48
-
49
- err = mcpClient .Close ()
50
- require .NoError (t , err )
18
+ tool := getTool (t , mcpClient , "read_file" )
19
+ assert .NotNil (t , tool , "read_file tool not found in the list of tools" )
51
20
}
0 commit comments