-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmcp_test.go
More file actions
54 lines (49 loc) · 1.44 KB
/
mcp_test.go
File metadata and controls
54 lines (49 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package fantasyextensions
import (
"encoding/json"
"reflect"
"testing"
"charm.land/fantasy"
"github.com/modelcontextprotocol/go-sdk/mcp"
)
func Test_toolInfoFromMCPTool(t *testing.T) {
t.Parallel()
// Given
mcpToolTestData := `{
"name": "Email_me_service",
"description": "Call this tool to send an email to me",
"inputSchema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": true,
"properties": {
"message": { "description": "Message content", "type": "string" },
"title": { "description": "Title of the message", "type": "string" }
},
"required": ["title", "message"],
"type": "object"
}
}`
var mcpTool *mcp.Tool
err := json.Unmarshal([]byte(mcpToolTestData), &mcpTool)
if err != nil {
t.Fatalf("failed to unmarshal tool: %v", err)
}
// When
toolInfo, err := toolInfoFromMCPTool(mcpTool)
if err != nil {
t.Fatalf("failed to get tool info: %v", err)
}
// Then
expectedToolInfo := fantasy.ToolInfo{
Name: "Email_me_service",
Description: "Call this tool to send an email to me",
Parameters: map[string]any{
"message": map[string]any{"description": "Message content", "type": "string"},
"title": map[string]any{"description": "Title of the message", "type": "string"},
},
Required: []string{"title", "message"},
}
if !reflect.DeepEqual(toolInfo, expectedToolInfo) {
t.Fatalf("tool info does not match expected tool info: %v", toolInfo)
}
}