@@ -7,14 +7,14 @@ import (
7
7
8
8
"github.com/eat-pray-ai/yutu/cmd"
9
9
"github.com/eat-pray-ai/yutu/pkg/i18nLanguage"
10
+ "github.com/eat-pray-ai/yutu/pkg/utils"
10
11
"github.com/mark3labs/mcp-go/mcp"
11
12
"github.com/spf13/cobra"
12
13
)
13
14
14
15
func init () {
15
- // cmd.MCP.AddTool(listTool, listHandler)
16
- cmd .MCP .AddResource (langsResource , langsHandler )
17
16
cmd .MCP .AddResource (hlResource , hlHandler )
17
+ cmd .MCP .AddResourceTemplate (langsResource , langsHandler )
18
18
i18nLanguageCmd .AddCommand (listCmd )
19
19
listCmd .Flags ().StringVarP (& hl , "hl" , "l" , "" , hlUsage )
20
20
listCmd .Flags ().StringSliceVarP (
@@ -41,6 +41,7 @@ var hlResource = mcp.NewResource(
41
41
hlURI , hlName ,
42
42
mcp .WithMIMEType (cmd .JsonMIME ),
43
43
mcp .WithResourceDescription (hlDesc ),
44
+ mcp .WithAnnotations ([]mcp.Role {"user" , "assistant" }, 0.51 ),
44
45
)
45
46
46
47
func hlHandler (
@@ -65,16 +66,18 @@ func hlHandler(
65
66
return contents , nil
66
67
}
67
68
68
- var langsResource = mcp .NewResource (
69
+ var langsResource = mcp .NewResourceTemplate (
69
70
langURI , langName ,
70
- mcp .WithMIMEType (cmd .JsonMIME ),
71
- mcp .WithResourceDescription (long ),
71
+ mcp .WithTemplateMIMEType (cmd .JsonMIME ),
72
+ mcp .WithTemplateDescription (long ),
73
+ mcp .WithTemplateAnnotations ([]mcp.Role {"user" , "assistant" }, 0.51 ),
72
74
)
73
75
74
76
func langsHandler (
75
77
ctx context.Context , request mcp.ReadResourceRequest ,
76
78
) ([]mcp.ResourceContents , error ) {
77
79
parts = defaultParts
80
+ hl = utils .ExtractHl (request .Params .URI )
78
81
output = "json"
79
82
var writer bytes.Buffer
80
83
err := list (& writer )
@@ -84,7 +87,7 @@ func langsHandler(
84
87
85
88
contents := []mcp.ResourceContents {
86
89
mcp.TextResourceContents {
87
- URI : langURI ,
90
+ URI : request . Params . URI ,
88
91
MIMEType : cmd .JsonMIME ,
89
92
Text : writer .String (),
90
93
},
0 commit comments