forgejo-mcp/operation/resource/doc.go
Christoph Görn 4249374bfe
feat: ✨ MCP resource templates — slices 1+2 (core framework + commit)
Implements the first two slices of the OpenSpec change
mcp-resource-templates (merged via PR #148):

Slice 1 — mcp-resources-core
- server.WithResourceCapabilities(false, false) enabled per design.md D5
- new operation/resource/ package with:
  - parse.go: typed URI parsers for owner/repo/commit/issue/pr/comment/status
    enforcing 40-hex sha, numeric index, kind ∈ {issue, pr}
  - bound.go: EmbeddedListCap = 30 + generic Bounded[T] helper with sentinel
  - errors.go: MapForgejoError maps 403 → -32002, 404 → -32003
  - register.go: thin AddTemplate wrapper over mcp.NewResourceTemplate
- RegisterCoreResources stub wired from Run()

Slice 2 — mcp-resource-commit
- operation/repo/resources_commit.go registers template
  forgejo://repo/{owner}/{repo}/commit/{sha}
- Handler returns application/json metadata + text/markdown sidecar (D9)
- Short-sha rejected at parse layer; SDK 404 surfaces via MapForgejoError
- RegisterCommitResource wired from RegisterCoreResources
- README "Resources" section added with one row for commit

Tests
- 8 new test files across operation/resource/ and operation/repo/
- All passing under go test -count=1 ./...

Tasks
- 17/47 checkboxes ticked in
  openspec/changes/mcp-resource-templates/tasks.md (slice 1+2;
  1.11 manual client check deferred)

Driven by team:dev-loop. Closes the slice 1+2 portion of forgejo-mcp-13x.
2026-05-28 14:31:55 +02:00

3 lines
181 B
Go

// Package resource provides shared URI parsing, template registration helpers,
// embedded-list bounding, and error mapping for forgejo:// MCP resource templates.
package resource