Files
github--github-mcp-server/pkg/github/skill_resources_test.go
Sam Morrow 209f851c87 fix: register all tools from all toolsets when skills are enabled
When skills handle progressive disclosure, the server should expose
all tools via tools/list regardless of toolset configuration. The
client decides tool visibility through skill allowedTools, not the
server.

This replaces the previous filtering approach — now inv.AllTools()
registers every tool with the MCP server, and skills reference the
full tool surface.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-24 12:35:22 +02:00

85 lines
2.3 KiB
Go

package github
import (
"testing"
"github.com/modelcontextprotocol/go-sdk/mcp"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestAllSkillsCoverAllToolsets(t *testing.T) {
// Collect all tool names from AllTools
allToolNames := make(map[string]bool)
for _, tool := range AllTools(stubTranslator) {
allToolNames[tool.Tool.Name] = true
}
// Collect all tool names covered by skills
coveredTools := make(map[string]bool)
for _, skill := range allSkills() {
for _, toolName := range skill.allowedTools {
coveredTools[toolName] = true
}
}
// Every tool should be covered by at least one skill
for toolName := range allToolNames {
assert.True(t, coveredTools[toolName], "tool %q is not covered by any skill", toolName)
}
}
func TestBuildSkillContent(t *testing.T) {
skill := skillDefinition{
name: "test-skill",
description: "A test skill",
allowedTools: []string{"tool_a", "tool_b"},
body: "# Test\n\nUse these tools.\n",
}
content := buildSkillContent(skill)
assert.Contains(t, content, "---\n")
assert.Contains(t, content, "name: test-skill\n")
assert.Contains(t, content, "description: A test skill\n")
assert.Contains(t, content, " - tool_a\n")
assert.Contains(t, content, " - tool_b\n")
assert.Contains(t, content, "# Test\n")
}
func TestSkillResourceURIs(t *testing.T) {
skills := allSkills()
require.NotEmpty(t, skills)
uris := make(map[string]bool)
names := make(map[string]bool)
for _, skill := range skills {
uri := "skill://github/" + skill.name + "/SKILL.md"
assert.False(t, uris[uri], "duplicate skill URI: %s", uri)
uris[uri] = true
assert.False(t, names[skill.name], "duplicate skill name: %s", skill.name)
names[skill.name] = true
assert.NotEmpty(t, skill.description, "skill %s has empty description", skill.name)
assert.NotEmpty(t, skill.allowedTools, "skill %s has no allowed tools", skill.name)
assert.NotEmpty(t, skill.body, "skill %s has empty body", skill.name)
}
}
func TestRegisterSkillResources(t *testing.T) {
server := mcp.NewServer(&mcp.Implementation{
Name: "test-server",
Version: "0.0.1",
}, nil)
// Should not panic
RegisterSkillResources(server)
// Verify the expected number of skills were registered by counting definitions
skills := allSkills()
assert.Equal(t, 27, len(skills), "expected 27 workflow-oriented skills")
}