Help us shape the future of Go! Take the 2026 Go Developer Survey

mcpskills

package
v1.9.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 21, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package mcpskills serves Agent Skills over MCP (Skills extension, io.modelcontextprotocol/skills, on protocol 2026-07-28) from a server built on the official go-sdk, which does not support the extension yet. It also holds the format checks the mcp-tester uses to verify skills.

Every file of a skill directory becomes a skill://<skill-path>/<file> resource; skills/list and skills/get return complete manifests with SHA-256 digests; resources/directory/read lists directories.

caps := &mcp.ServerCapabilities{}
mcpskills.Declare(caps, true)
s := mcp.NewServer(impl, &mcp.ServerOptions{Capabilities: caps})
mcpskills.Serve(s, os.DirFS("skills"), nil)

Index

Constants

View Source
const (
	MaxResources = 512
	MaxTotalSize = 16 << 20 // 16 MiB
)

Limits every conforming host supports (Skills extension, "Limits").

View Source
const DirectoryMIMEType = "inode/directory"

DirectoryMIMEType marks a directory resource.

View Source
const Extension = "io.modelcontextprotocol/skills"

Extension is the identifier of the Skills extension.

Variables

This section is empty.

Functions

func Declare

func Declare(caps *mcp.ServerCapabilities, directoryRead bool)

Declare adds the extension (and the resources capability it requires) to the server capabilities. directoryRead announces resources/directory/read.

func Digest

func Digest(data []byte) string

Digest formats the SHA-256 of data as the extension requires: sha256:{hex}.

func ParseFrontmatter

func ParseFrontmatter(skillMD []byte) (map[string]any, error)

ParseFrontmatter returns the YAML frontmatter of a SKILL.md as a JSON-like map (the form the extension puts into a skill entry).

func ValidDigest

func ValidDigest(d string) bool

ValidDigest reports whether d has the form sha256:{64 lowercase hex}.

func ValidateFrontmatter

func ValidateFrontmatter(fm map[string]any) []string

ValidateFrontmatter checks the fields the Agent Skills specification requires or constrains; it returns the problems found.

func ValidateName

func ValidateName(name string) string

ValidateName returns why name violates the Agent Skills naming rules, or "".

Types

type DirectoryResult

type DirectoryResult struct {
	mcp.ResultBase
	ResultType string          `json:"resultType"`
	Resources  []*mcp.Resource `json:"resources"`
	NextCursor string          `json:"nextCursor,omitempty"`
}

DirectoryResult is the result of resources/directory/read.

type GetResult

type GetResult struct {
	mcp.ResultBase
	ResultType string `json:"resultType"`
	Skill      Skill  `json:"skill"`
	TTLMs      int    `json:"ttlMs"`
	CacheScope string `json:"cacheScope"`
}

GetResult is the result of skills/get.

type ListParams

type ListParams struct {
	mcp.ParamsBase
	Cursor string `json:"cursor,omitempty"`
}

ListParams are the params of skills/list.

type ListResult

type ListResult struct {
	mcp.ResultBase
	ResultType string  `json:"resultType"`
	Skills     []Skill `json:"skills"`
	NextCursor string  `json:"nextCursor,omitempty"`
	TTLMs      int     `json:"ttlMs"`
	CacheScope string  `json:"cacheScope"`
}

ListResult is the result of skills/list.

type Options

type Options struct {
	// Scheme of the resource URIs; default "skill".
	Scheme string
	// TTLMs is the cache hint on skills/list and skills/get; default 300000.
	TTLMs int
}

Options configure Serve.

type Skill

type Skill struct {
	URI         string          `json:"uri"`
	Frontmatter map[string]any  `json:"frontmatter"`
	Resources   []SkillResource `json:"resources"`
}

Skill is a skill entry as returned by skills/list and skills/get.

func Serve

func Serve(s *mcp.Server, fsys fs.FS, opts *Options) ([]Skill, error)

Serve publishes every skill (directory with a SKILL.md) in fsys and returns the entries. A skill whose frontmatter name differs from its directory name, or that breaks the Agent Skills rules, is an error.

type SkillResource

type SkillResource struct {
	URI    string `json:"uri"`
	Digest string `json:"digest"`
	Size   int64  `json:"size"`
}

SkillResource is one file of a skill with its digest and size.

type URIParams

type URIParams struct {
	mcp.ParamsBase
	URI    string `json:"uri"`
	Cursor string `json:"cursor,omitempty"`
}

URIParams are the params of skills/get and resources/directory/read.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL