@@ -7,14 +7,14 @@ import (
77
88 "github.com/eat-pray-ai/yutu/cmd"
99 "github.com/eat-pray-ai/yutu/pkg/i18nLanguage"
10+ "github.com/eat-pray-ai/yutu/pkg/utils"
1011 "github.com/mark3labs/mcp-go/mcp"
1112 "github.com/spf13/cobra"
1213)
1314
1415func init () {
15- // cmd.MCP.AddTool(listTool, listHandler)
16- cmd .MCP .AddResource (langsResource , langsHandler )
1716 cmd .MCP .AddResource (hlResource , hlHandler )
17+ cmd .MCP .AddResourceTemplate (langsResource , langsHandler )
1818 i18nLanguageCmd .AddCommand (listCmd )
1919 listCmd .Flags ().StringVarP (& hl , "hl" , "l" , "" , hlUsage )
2020 listCmd .Flags ().StringSliceVarP (
@@ -41,6 +41,7 @@ var hlResource = mcp.NewResource(
4141 hlURI , hlName ,
4242 mcp .WithMIMEType (cmd .JsonMIME ),
4343 mcp .WithResourceDescription (hlDesc ),
44+ mcp .WithAnnotations ([]mcp.Role {"user" , "assistant" }, 0.51 ),
4445)
4546
4647func hlHandler (
@@ -65,16 +66,18 @@ func hlHandler(
6566 return contents , nil
6667}
6768
68- var langsResource = mcp .NewResource (
69+ var langsResource = mcp .NewResourceTemplate (
6970 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 ),
7274)
7375
7476func langsHandler (
7577 ctx context.Context , request mcp.ReadResourceRequest ,
7678) ([]mcp.ResourceContents , error ) {
7779 parts = defaultParts
80+ hl = utils .ExtractHl (request .Params .URI )
7881 output = "json"
7982 var writer bytes.Buffer
8083 err := list (& writer )
@@ -84,7 +87,7 @@ func langsHandler(
8487
8588 contents := []mcp.ResourceContents {
8689 mcp.TextResourceContents {
87- URI : langURI ,
90+ URI : request . Params . URI ,
8891 MIMEType : cmd .JsonMIME ,
8992 Text : writer .String (),
9093 },
0 commit comments