handleGetSkill returns the full body of a specific skill
(ctx context.Context, req *mcp.CallToolRequest, input SkillInput)
| 1052 | |
| 1053 | // handleGetSkill returns the full body of a specific skill |
| 1054 | func handleGetSkill(ctx context.Context, req *mcp.CallToolRequest, input SkillInput) (*mcp.CallToolResult, any, error) { |
| 1055 | path := input.Path |
| 1056 | if strings.HasPrefix(path, "~/") { |
| 1057 | home := os.Getenv("HOME") |
| 1058 | path = filepath.Join(home, path[2:]) |
| 1059 | } |
| 1060 | |
| 1061 | absPath, err := filepath.Abs(path) |
| 1062 | if err != nil { |
| 1063 | return errorResult("Invalid path: " + err.Error()), nil, nil |
| 1064 | } |
| 1065 | |
| 1066 | idx, err := skills.LoadSkills(absPath) |
| 1067 | if err != nil { |
| 1068 | return errorResult("Error loading skills: " + err.Error()), nil, nil |
| 1069 | } |
| 1070 | |
| 1071 | skill, ok := idx.ByName[input.Name] |
| 1072 | if !ok { |
| 1073 | available := make([]string, 0, len(idx.Skills)) |
| 1074 | for _, s := range idx.Skills { |
| 1075 | available = append(available, s.Meta.Name) |
| 1076 | } |
| 1077 | return errorResult(fmt.Sprintf("Skill %q not found.\nAvailable: %s", input.Name, strings.Join(available, ", "))), nil, nil |
| 1078 | } |
| 1079 | |
| 1080 | var sb strings.Builder |
| 1081 | sb.WriteString(fmt.Sprintf("# %s\n\n", skill.Meta.Name)) |
| 1082 | sb.WriteString(fmt.Sprintf("Source: %s | Priority: %d\n", skill.Source, skill.Meta.Priority)) |
| 1083 | if skill.Meta.Description != "" { |
| 1084 | sb.WriteString(fmt.Sprintf("Description: %s\n", skill.Meta.Description)) |
| 1085 | } |
| 1086 | sb.WriteString("\n") |
| 1087 | sb.WriteString(skill.Body) |
| 1088 | return textResult(sb.String()), nil, nil |
| 1089 | } |
nothing calls this directly
no test coverage detected