From 0a7b7861a7da44d5571cafb90b0f5656dd5c201d Mon Sep 17 00:00:00 2001 From: Aaron LaBrie Date: Wed, 2 Dec 2026 11:04:21 -0600 Subject: [PATCH 1/2] number API --- docs/feature-flags.md | 75 ++++---- ...tifact_read_ff_pull_request_artifacts.snap | 111 +++++++++++- ...ifact_write_ff_pull_request_artifacts.snap | 50 ++++-- .../pull_request_artifact_approval_test.go | 30 ++-- .../pull_request_artifact_names_test.go | 24 ++- pkg/github/pull_request_artifact_types.go | 50 +++--- pkg/github/pull_request_artifacts.go | 135 +++++++++----- pkg/github/pull_request_artifacts_test.go | 170 +++++++++++------- 8 files changed, 423 insertions(+), 222 deletions(-) diff --git a/docs/feature-flags.md b/docs/feature-flags.md index 59dd6173a3..aadca5030a 100644 --- a/docs/feature-flags.md +++ b/docs/feature-flags.md @@ -150,8 +150,8 @@ containing `issue_number`, `artifact_number`, and a confirmation message. Enable `--features=pull_request_artifacts` (or `GITHUB_FEATURES=pull_request_artifacts`) to expose -`pull_request_artifact_read` (`method: list`) and -`pull_request_artifact_write` (`method: upsert | delete`) in the +`pull_request_artifact_read` (`method: list | get`) and +`pull_request_artifact_write` (`method: upsert | update | delete`) in the `pull_requests` toolset. This flag is **off by default**, including in Insiders mode. Read-only mode exposes only the read tool. Both tools reject calls in lockdown mode. @@ -159,44 +159,50 @@ lockdown mode. All operations require `owner`, `repo`, and `pull_number`. The tools resolve the repository's numeric ID and use the configured authenticated GitHub client and API base URL. They declare `repo` in OAuth challenge metadata; -the API separately enforces pull request read access for list and artifact -write access for upsert/delete, including repository writeability and storage -availability. No endpoint-specific preview header is added. - -Upsert and delete address artifacts by **name**, not artifact number or global -ID. Supply exactly one of `name` (the exact original name) or `name_key` (the -lossless key returned by reads and writes). Returned `name` values are sanitized -for display and must not be used as mutation keys: distinct original names can -have the same display name. Pass `name_key` verbatim to update or delete an -artifact discovered through a read. Keys use unpadded URL-safe Base64 encoding -of the original name and are not authorization tokens. -Upsert requires `body` and optionally accepts `commit_oid`. -The body is sent unchanged, including an empty string; the API validates its -content and constraints. Upsert accepts both creation (201) and replacement -(200) responses. Delete rejects `body` and `commit_oid`. +the API separately enforces pull request read access for list/get and artifact +write access for upsert/update/delete, including repository writeability and +storage availability. No endpoint-specific preview header is added. + +Get, update, and delete use the positive PR-scoped `artifact_number` returned +as `number`, not the global ID or sanitized name. Upsert uses exactly one of +`name` (the exact original name) or `name_key` (the lossless key returned by +reads and writes). Returned names are sanitized for display; pass `name_key` +verbatim to upsert an artifact discovered through a read. Keys use unpadded +URL-safe Base64 encoding and are not authorization tokens. + +Upsert requires `body` and optionally accepts `type` and `commit_oid`. Type +defaults to `generic` on creation and update; use `embedded_html` on every +upsert of an HTML artifact, whose type cannot be changed. Upsert accepts both +creation (201) and replacement (200) responses. Update requires `body` and +`commit_oid`: supply a full OID or an empty string to clear the association. +Bodies are sent unchanged and the API validates their content and constraints. +Delete accepts neither body nor commit association. Before deletion, the client must obtain explicit user confirmation of the exact -repository, PR number, and artifact name through form elicitation. Confirmation +repository, PR number, and artifact number through form elicitation. Confirmation requires MCP protocol `2026-07-28` or later and configured request-state protection. The protected state binds approval to the target repository ID, PR, and artifact -name and expires after ten minutes. Missing, invalid, expired, declined, or +number and expires after ten minutes. Missing, invalid, expired, declined, or canceled confirmation prevents deletion, as does a changed repository identity. Clients without the required protocol or form-elicitation support cannot delete; -list and upsert remain available. This relies on the client to present the -confirmation to the user rather than answer on the model's behalf. +list, get, upsert, and update remain available. This relies on the client to +present the confirmation to the user rather than answer on the model's behalf. Writes are not automatically retried; API errors, including conflicts, validation failures, throttling, and storage failures, are returned explicitly. List includes artifact bodies and accepts `commit_oid`: omit it or use -`current` for the PR's current head, use `all` for every commit, or supply an -explicit commit OID. For a stable commit selection across pages, use an -explicit OID instead of a moving PR head. List returns one requested page -(`page` defaults to 1, `perPage` defaults to 30 and is limited to 100). +`current` for the PR's current head, use `all` for the newest retained version +of each artifact regardless of commit, or supply a full commit OID. Commit +selection falls back to the newest version without a commit association when +there is no match; artifacts with neither are omitted. For a stable commit +selection across pages, use an explicit OID instead of a moving PR head. List +returns one requested page (`page` defaults to 1, `perPage` defaults to 30 and +is limited to 100). Request `next_page` when present; its value comes from the API's REST Link header, not the number of returned artifacts. -Upsert returns an `artifact` object. List returns a `list` object containing -`artifacts`, `page`, `perPage`, and optional `next_page`. Delete returns a -`deleted` object containing `pull_number`, display `name`, lossless `name_key`, +Get, upsert, and update return an `artifact` object. List returns a `list` +object containing `artifacts`, `page`, `perPage`, and optional `next_page`. Delete returns a +`deleted` object containing `pull_number`, `artifact_number`, and a confirmation message. Artifact IDs are opaque JSON strings or integers and are never mutation identifiers. Results preserve nullable commit, creator, and timestamp @@ -601,7 +607,8 @@ as output formatting) won't appear here. - **pull_request_artifact_read** - Read pull request artifacts - **OAuth Challenge Scopes**: `repo` - - `commit_oid`: Commit selection: omitted or current for the current PR head, all for every commit, or an explicit commit OID (string, optional) + - `artifact_number`: Positive PR-scoped artifact number; required for get (integer, optional) + - `commit_oid`: List commit selection: omitted or current for the PR head, all for the newest version regardless of commit, or an explicit commit OID (string, optional) - `method`: (string, required) - `owner`: Repository owner (string, required) - `page`: Page number, starting at 1 (default 1) (integer, optional) @@ -611,14 +618,16 @@ as output formatting) won't appear here. - **pull_request_artifact_write** - Write pull request artifacts - **OAuth Challenge Scopes**: `repo` - - `body`: Required for upsert: artifact content; an empty string is sent unchanged. Not supported for delete (string, optional) - - `commit_oid`: Optional commit OID for upsert only; omission preserves the API default (string, optional) + - `artifact_number`: Positive PR-scoped artifact number; required for update and delete (integer, optional) + - `body`: Required for upsert and update: artifact content (string, optional) + - `commit_oid`: Optional for upsert; required for update, with an empty string clearing the association (string, optional) - `method`: (string, required) - - `name`: Exact artifact name for creation or addressing; mutually exclusive with name_key. Do not copy sanitized display names from read results (string, optional) - - `name_key`: Lossless addressing key returned by artifact reads or writes; mutually exclusive with name. Pass verbatim without decoding (string, optional) + - `name`: Exact artifact name for upsert; mutually exclusive with name_key. Do not copy sanitized display names from read results (string, optional) + - `name_key`: Lossless name key returned by artifact reads or writes for upsert; mutually exclusive with name (string, optional) - `owner`: Repository owner (string, required) - `pull_number`: Positive pull request number (integer, required) - `repo`: Repository name (string, required) + - `type`: Artifact type for upsert: generic or embedded_html; omission defaults to generic (string, optional) ### `agent_automations` diff --git a/pkg/github/__toolsnaps__/pull_request_artifact_read_ff_pull_request_artifacts.snap b/pkg/github/__toolsnaps__/pull_request_artifact_read_ff_pull_request_artifacts.snap index 2641e58969..f37975b59d 100644 --- a/pkg/github/__toolsnaps__/pull_request_artifact_read_ff_pull_request_artifacts.snap +++ b/pkg/github/__toolsnaps__/pull_request_artifact_read_ff_pull_request_artifacts.snap @@ -5,7 +5,7 @@ "readOnlyHint": true, "title": "Read pull request artifacts" }, - "description": "List GitHub pull request artifact versions including their bodies. Names are sanitized for display; use the returned name_key, not name, for subsequent writes. commit_oid defaults to the current PR head; use all or an explicit commit OID to change the selection. Returns one page; request next_page when present. Repository access and the repository's pull_request_artifacts_api rollout are enforced by GitHub. Unavailable in lockdown mode.", + "description": "List GitHub pull request artifact versions or get the current version by PR-scoped artifact_number, including bodies. Names are sanitized for display; use number for get, update, and delete, or name_key for upsert. List commit_oid defaults to the current PR head; use all or an explicit commit OID to change the selection. List returns one page; request next_page when present. Repository access and the repository's pull_request_artifacts_api rollout are enforced by GitHub. Unavailable in lockdown mode.", "icons": [ { "mimeType": "image/png", @@ -21,13 +21,19 @@ "inputSchema": { "additionalProperties": false, "properties": { + "artifact_number": { + "description": "Positive PR-scoped artifact number; required for get", + "minimum": 1, + "type": "integer" + }, "commit_oid": { - "description": "Commit selection: omitted or current for the current PR head, all for every commit, or an explicit commit OID", + "description": "List commit selection: omitted or current for the PR head, all for the newest version regardless of commit, or an explicit commit OID", "type": "string" }, "method": { "enum": [ - "list" + "list", + "get" ], "type": "string" }, @@ -72,6 +78,90 @@ "outputSchema": { "additionalProperties": false, "properties": { + "artifact": { + "additionalProperties": false, + "properties": { + "body": { + "type": "string" + }, + "commit_oid": { + "type": [ + "null", + "string" + ] + }, + "created_at": { + "type": [ + "null", + "string" + ] + }, + "creator": { + "additionalProperties": false, + "properties": { + "id": { + "type": "integer" + }, + "login": { + "type": "string" + } + }, + "required": [ + "login", + "id" + ], + "type": [ + "null", + "object" + ] + }, + "id": { + "description": "Opaque global artifact ID; use number to address an artifact", + "type": [ + "string", + "integer" + ] + }, + "name": { + "description": "Sanitized display name", + "type": "string" + }, + "name_key": { + "description": "Lossless base64url-encoded artifact name; pass verbatim as name_key for upsert", + "type": "string" + }, + "number": { + "description": "Artifact number within the pull request", + "type": "integer" + }, + "type": { + "description": "Artifact type, such as generic or embedded_html", + "type": "string" + }, + "updated_at": { + "type": [ + "null", + "string" + ] + } + }, + "required": [ + "id", + "number", + "name", + "name_key", + "type", + "body", + "commit_oid", + "creator", + "created_at", + "updated_at" + ], + "type": [ + "null", + "object" + ] + }, "list": { "additionalProperties": false, "properties": { @@ -114,23 +204,28 @@ ] }, "id": { - "description": "Opaque artifact ID; mutations use name or name_key instead", + "description": "Opaque global artifact ID; use number to address an artifact", "type": [ "string", "integer" ] }, "name": { - "description": "Sanitized display name; use name_key when addressing this artifact", + "description": "Sanitized display name", "type": "string" }, "name_key": { - "description": "Lossless base64url-encoded artifact name; pass verbatim as name_key to write operations", + "description": "Lossless base64url-encoded artifact name; pass verbatim as name_key for upsert", "type": "string" }, "number": { + "description": "Artifact number within the pull request", "type": "integer" }, + "type": { + "description": "Artifact type, such as generic or embedded_html", + "type": "string" + }, "updated_at": { "type": [ "null", @@ -143,6 +238,7 @@ "number", "name", "name_key", + "type", "body", "commit_oid", "creator", @@ -178,9 +274,6 @@ ] } }, - "required": [ - "list" - ], "type": [ "null", "object" diff --git a/pkg/github/__toolsnaps__/pull_request_artifact_write_ff_pull_request_artifacts.snap b/pkg/github/__toolsnaps__/pull_request_artifact_write_ff_pull_request_artifacts.snap index 7e266ddaab..10d2ecea9d 100644 --- a/pkg/github/__toolsnaps__/pull_request_artifact_write_ff_pull_request_artifacts.snap +++ b/pkg/github/__toolsnaps__/pull_request_artifact_write_ff_pull_request_artifacts.snap @@ -5,7 +5,7 @@ "readOnlyHint": false, "title": "Write pull request artifacts" }, - "description": "Upsert or delete a GitHub pull request artifact using exactly one of name (the exact original name) or name_key (the lossless key returned by reads or writes), not its number or global ID. Never use a sanitized display name to address an existing artifact. Upsert requires body and optionally accepts commit_oid; creates a new artifact or replaces the named artifact's content. Delete requires explicit user confirmation through form elicitation with MCP protocol 2026-07-28 or later, and does not accept body or commit_oid. Writes are not automatically retried. Repository access and the repository's pull_request_artifacts_api rollout are enforced by GitHub. Unavailable in lockdown mode.", + "description": "Upsert a GitHub pull request artifact by exact name or lossless name_key, or update or delete it by PR-scoped artifact_number. Upsert requires body and optionally accepts type and commit_oid; omitted type defaults to generic, so specify embedded_html when upserting HTML artifacts. Update requires body and commit_oid; an empty commit_oid clears the association. Delete requires explicit user confirmation through form elicitation with MCP protocol 2026-07-28 or later. Writes are not automatically retried. Repository access and the repository's pull_request_artifacts_api rollout are enforced by GitHub. Unavailable in lockdown mode.", "icons": [ { "mimeType": "image/png", @@ -21,28 +21,34 @@ "inputSchema": { "additionalProperties": false, "properties": { + "artifact_number": { + "description": "Positive PR-scoped artifact number; required for update and delete", + "minimum": 1, + "type": "integer" + }, "body": { - "description": "Required for upsert: artifact content; an empty string is sent unchanged. Not supported for delete", + "description": "Required for upsert and update: artifact content", "type": "string" }, "commit_oid": { - "description": "Optional commit OID for upsert only; omission preserves the API default", + "description": "Optional for upsert; required for update, with an empty string clearing the association", "type": "string" }, "method": { "enum": [ "upsert", + "update", "delete" ], "type": "string" }, "name": { - "description": "Exact artifact name for creation or addressing; mutually exclusive with name_key. Do not copy sanitized display names from read results", + "description": "Exact artifact name for upsert; mutually exclusive with name_key. Do not copy sanitized display names from read results", "minLength": 1, "type": "string" }, "name_key": { - "description": "Lossless addressing key returned by artifact reads or writes; mutually exclusive with name. Pass verbatim without decoding", + "description": "Lossless name key returned by artifact reads or writes for upsert; mutually exclusive with name", "minLength": 1, "type": "string" }, @@ -62,6 +68,14 @@ "minLength": 1, "type": "string", "x-mcp-header": "repo" + }, + "type": { + "description": "Artifact type for upsert: generic or embedded_html; omission defaults to generic", + "enum": [ + "generic", + "embedded_html" + ], + "type": "string" } }, "required": [ @@ -114,23 +128,28 @@ ] }, "id": { - "description": "Opaque artifact ID; mutations use name or name_key instead", + "description": "Opaque global artifact ID; use number to address an artifact", "type": [ "string", "integer" ] }, "name": { - "description": "Sanitized display name; use name_key when addressing this artifact", + "description": "Sanitized display name", "type": "string" }, "name_key": { - "description": "Lossless base64url-encoded artifact name; pass verbatim as name_key to write operations", + "description": "Lossless base64url-encoded artifact name; pass verbatim as name_key for upsert", "type": "string" }, "number": { + "description": "Artifact number within the pull request", "type": "integer" }, + "type": { + "description": "Artifact type, such as generic or embedded_html", + "type": "string" + }, "updated_at": { "type": [ "null", @@ -143,6 +162,7 @@ "number", "name", "name_key", + "type", "body", "commit_oid", "creator", @@ -157,15 +177,10 @@ "deleted": { "additionalProperties": false, "properties": { - "message": { - "type": "string" - }, - "name": { - "description": "Sanitized display name of the deleted artifact", - "type": "string" + "artifact_number": { + "type": "integer" }, - "name_key": { - "description": "Lossless addressing key of the deleted artifact", + "message": { "type": "string" }, "pull_number": { @@ -174,8 +189,7 @@ }, "required": [ "pull_number", - "name", - "name_key", + "artifact_number", "message" ], "type": [ diff --git a/pkg/github/pull_request_artifact_approval_test.go b/pkg/github/pull_request_artifact_approval_test.go index 4540359c52..751109703b 100644 --- a/pkg/github/pull_request_artifact_approval_test.go +++ b/pkg/github/pull_request_artifact_approval_test.go @@ -2,7 +2,6 @@ package github import ( "context" - "encoding/base64" "encoding/json" "fmt" "net/http" @@ -58,12 +57,7 @@ func invokePullRequestArtifactWithApproval(ctx context.Context, t *testing.T, de } func artifactApprovalTarget(args map[string]any) string { - name, _ := args["name"].(string) - if key, ok := args["name_key"].(string); ok { - decoded, _ := base64.RawURLEncoding.DecodeString(key) - name = string(decoded) - } - return fmt.Sprintf("%s/%s#%d artifact %q", args["owner"], args["repo"], args["pull_number"], name) + return fmt.Sprintf("%s/%s#%d artifact #%d", args["owner"], args["repo"], args["pull_number"], args["artifact_number"]) } func TestPullRequestArtifactDeleteApproval(t *testing.T) { @@ -79,7 +73,7 @@ func TestPullRequestArtifactDeleteApproval(t *testing.T) { case http.MethodDelete: deletes++ assert.Equal(t, 1, prompts, "approval must precede DELETE") - assert.Equal(t, "/api/v3/repositories/42/pulls/12/artifacts/report", r.URL.Path) + assert.Equal(t, "/api/v3/repositories/42/pulls/12/artifacts/3", r.URL.Path) w.WriteHeader(http.StatusNoContent) default: t.Errorf("unexpected method %s", r.Method) @@ -93,18 +87,18 @@ func TestPullRequestArtifactDeleteApproval(t *testing.T) { prompts++ assert.Zero(t, deletes) assert.Equal(t, "form", req.Params.Mode) - assert.Contains(t, req.Params.Message, `o/r#12 artifact \"report\"`) + assert.Contains(t, req.Params.Message, `o/r#12 artifact #3`) return &mcp.ElicitResult{ Action: action, Content: map[string]any{ - deletePullRequestArtifactConfirmationField: `o/r#12 artifact "report"`, + deletePullRequestArtifactConfirmationField: `o/r#12 artifact #3`, }, }, nil }, }) result, err := session.CallTool(context.Background(), &mcp.CallToolParams{ Name: "pull_request_artifact_write", - Arguments: map[string]any{"owner": "o", "repo": "r", "pull_number": 12, "method": "delete", "name": "report"}, + Arguments: map[string]any{"owner": "o", "repo": "r", "pull_number": 12, "method": "delete", "artifact_number": 3}, }) require.NoError(t, err) assert.Equal(t, 1, prompts) @@ -112,7 +106,7 @@ func TestPullRequestArtifactDeleteApproval(t *testing.T) { require.False(t, result.IsError, mustMarshalJSON(t, result)) assert.Equal(t, 2, lookups, "repository identity must be rechecked") assert.Equal(t, 1, deletes) - assert.JSONEq(t, `{"deleted":{"pull_number":12,"name":"report","name_key":"cmVwb3J0","message":"artifact deleted"}}`, getTextResult(t, result).Text) + assert.JSONEq(t, `{"deleted":{"pull_number":12,"artifact_number":3,"message":"artifact deleted"}}`, getTextResult(t, result).Text) assert.JSONEq(t, getTextResult(t, result).Text, mustMarshalJSON(t, result.StructuredContent)) } else { require.True(t, result.IsError) @@ -126,7 +120,7 @@ func TestPullRequestArtifactDeleteApproval(t *testing.T) { func TestPullRequestArtifactDeleteInvalidApproval(t *testing.T) { for _, name := range []string{ "missing state", "tampered state", "invalid state JSON", "expired state", - "changed owner", "changed repo", "changed PR", "changed name", "changed operation", + "changed owner", "changed repo", "changed PR", "changed artifact number", "changed operation", "invalid repository ID", "recreated repository", "wrong confirmation", "missing confirmation", "invalid response", "lockdown after confirmation", } { @@ -146,7 +140,7 @@ func TestPullRequestArtifactDeleteInvalidApproval(t *testing.T) { deps := BaseDeps{Client: client, StateSealer: sealer} tool := PullRequestArtifactWrite(translations.NullTranslationHelper) handler := tool.Handler(deps) - args := map[string]any{"owner": "o", "repo": "r", "pull_number": 12, "method": "delete", "name": "report"} + args := map[string]any{"owner": "o", "repo": "r", "pull_number": 12, "method": "delete", "artifact_number": 3} request := pullRequestArtifactApprovalRequest(args) ctx := ContextWithDeps(context.Background(), deps) first, err := handler(ctx, &request) @@ -162,7 +156,7 @@ func TestPullRequestArtifactDeleteInvalidApproval(t *testing.T) { require.NoError(t, json.Unmarshal(stateJSON, &state)) assert.Equal(t, int64(42), state.RepositoryID) assert.Equal(t, 12, state.PullNumber) - assert.Equal(t, "report", state.Name) + assert.Equal(t, 3, state.ArtifactNumber) assert.InDelta(t, time.Now().Add(10*time.Minute).Unix(), state.ExpiresAt, 2) confirmation := &mcp.ElicitResult{ Action: "accept", @@ -175,8 +169,8 @@ func TestPullRequestArtifactDeleteInvalidApproval(t *testing.T) { args["repo"] = "other" case "changed PR": args["pull_number"] = 13 - case "changed name": - args["name"] = "other" + case "changed artifact number": + args["artifact_number"] = 4 case "changed operation": state.Operation = "another_tool:delete" case "invalid repository ID": @@ -236,7 +230,7 @@ func TestPullRequestArtifactDeleteUnsupportedClient(t *testing.T) { coordinates := PullRequestArtifactCoordinates{Owner: "o", Repo: "r", PullNumber: 12} input := PullRequestArtifactWriteInput{ PullRequestArtifactCoordinates: coordinates, - Method: "delete", Name: "report", + Method: "delete", ArtifactNumber: 3, } request := pullRequestArtifactApprovalRequest(nil) switch name { diff --git a/pkg/github/pull_request_artifact_names_test.go b/pkg/github/pull_request_artifact_names_test.go index 921025af49..b5ece551da 100644 --- a/pkg/github/pull_request_artifact_names_test.go +++ b/pkg/github/pull_request_artifact_names_test.go @@ -2,11 +2,9 @@ package github import ( "context" - "encoding/base64" "encoding/json" "fmt" "net/http" - "net/url" "testing" "github.com/github/github-mcp-server/v2/internal/requeststate" @@ -16,7 +14,7 @@ import ( "github.com/stretchr/testify/require" ) -func TestPullRequestArtifactNameRoundTrip(t *testing.T) { +func TestPullRequestArtifactNumberRoundTrip(t *testing.T) { for _, names := range [][2]string{ {"AT&T", "AT&T"}, {"report", "report"}, @@ -44,11 +42,11 @@ func TestPullRequestArtifactNameRoundTrip(t *testing.T) { require.NoError(t, json.NewEncoder(w).Encode(artifacts)) return } - assert.Equal(t, "/api/v3/repositories/42/pulls/12/artifacts/"+url.PathEscape(names[0]), r.URL.EscapedPath()) + assert.Equal(t, "/api/v3/repositories/42/pulls/12/artifacts/1", r.URL.Path) assert.Empty(t, r.URL.RawQuery) mutations = append(mutations, r.Method) switch r.Method { - case http.MethodPut: + case http.MethodPatch: var payload struct { Body string `json:"body"` } @@ -67,7 +65,7 @@ func TestPullRequestArtifactNameRoundTrip(t *testing.T) { sealer, err := requeststate.NewRandom() require.NoError(t, err) deps := BaseDeps{Client: client, StateSealer: sealer} - target := fmt.Sprintf("o/r#12 artifact %q", names[0]) + target := "o/r#12 artifact #1" session := pullRequestArtifactTestSession(t, deps, inventory.ProtocolVersionMultiRoundTrip, &mcp.ClientOptions{ ElicitationHandler: func(_ context.Context, req *mcp.ElicitRequest) (*mcp.ElicitResult, error) { assert.Contains(t, req.Params.Message, fmt.Sprintf("%q", target)) @@ -90,14 +88,13 @@ func TestPullRequestArtifactNameRoundTrip(t *testing.T) { require.Len(t, listed.List.Artifacts, 2) first, second := listed.List.Artifacts[0], listed.List.Artifacts[1] assert.Equal(t, first.Name, second.Name, "distinct names collide after display sanitization") - assert.NotEqual(t, first.NameKey, second.NameKey) - assert.Equal(t, base64.RawURLEncoding.EncodeToString([]byte(names[0])), first.NameKey) + assert.NotEqual(t, first.Number, second.Number) updated, err := session.CallTool(context.Background(), &mcp.CallToolParams{ Name: "pull_request_artifact_write", Arguments: map[string]any{ "owner": "o", "repo": "r", "pull_number": 12, - "method": "upsert", "name_key": first.NameKey, "body": "updated", + "method": "update", "artifact_number": first.Number, "body": "updated", "commit_oid": "", }, }) require.NoError(t, err) @@ -105,7 +102,7 @@ func TestPullRequestArtifactNameRoundTrip(t *testing.T) { var written PullRequestArtifactWriteOutput require.NoError(t, json.Unmarshal([]byte(getTextResult(t, updated).Text), &written)) require.NotNil(t, written.Artifact) - assert.Equal(t, first.NameKey, written.Artifact.NameKey) + assert.Equal(t, first.Number, written.Artifact.Number) assert.Equal(t, "updated", bodies[names[0]]) assert.Equal(t, "do not change", bodies[names[1]]) @@ -113,7 +110,7 @@ func TestPullRequestArtifactNameRoundTrip(t *testing.T) { Name: "pull_request_artifact_write", Arguments: map[string]any{ "owner": "o", "repo": "r", "pull_number": 12, - "method": "delete", "name_key": written.Artifact.NameKey, + "method": "delete", "artifact_number": written.Artifact.Number, }, }) require.NoError(t, err) @@ -121,11 +118,10 @@ func TestPullRequestArtifactNameRoundTrip(t *testing.T) { var confirmation PullRequestArtifactWriteOutput require.NoError(t, json.Unmarshal([]byte(getTextResult(t, deleted).Text), &confirmation)) require.NotNil(t, confirmation.Deleted) - assert.Equal(t, first.NameKey, confirmation.Deleted.NameKey) - assert.Equal(t, first.Name, confirmation.Deleted.Name) + assert.Equal(t, first.Number, confirmation.Deleted.ArtifactNumber) assert.NotContains(t, bodies, names[0]) assert.Equal(t, "do not change", bodies[names[1]]) - assert.Equal(t, []string{http.MethodPut, http.MethodDelete}, mutations) + assert.Equal(t, []string{http.MethodPatch, http.MethodDelete}, mutations) }) } } diff --git a/pkg/github/pull_request_artifact_types.go b/pkg/github/pull_request_artifact_types.go index b44a80dfdb..d1f7eba43f 100644 --- a/pkg/github/pull_request_artifact_types.go +++ b/pkg/github/pull_request_artifact_types.go @@ -4,10 +4,11 @@ import "encoding/json" // PullRequestArtifact is an artifact or artifact version returned by the PR API. type PullRequestArtifact struct { - ID json.RawMessage `json:"id" jsonschema:"Opaque artifact ID; mutations use name or name_key instead"` - Number int `json:"number"` - Name string `json:"name" jsonschema:"Sanitized display name; use name_key when addressing this artifact"` - NameKey string `json:"name_key" jsonschema:"Lossless base64url-encoded artifact name; pass verbatim as name_key to write operations"` + ID json.RawMessage `json:"id" jsonschema:"Opaque global artifact ID; use number to address an artifact"` + Number int `json:"number" jsonschema:"Artifact number within the pull request"` + Name string `json:"name" jsonschema:"Sanitized display name"` + NameKey string `json:"name_key" jsonschema:"Lossless base64url-encoded artifact name; pass verbatim as name_key for upsert"` + Type string `json:"type" jsonschema:"Artifact type, such as generic or embedded_html"` Body string `json:"body"` CommitOID *string `json:"commit_oid"` Creator *PullRequestArtifactCreator `json:"creator"` @@ -28,28 +29,32 @@ type PullRequestArtifactCoordinates struct { PullNumber int `json:"pull_number" jsonschema:"Positive pull request number"` } -// PullRequestArtifactReadInput selects a page of pull request artifact versions. +// PullRequestArtifactReadInput selects a page or an individual pull request artifact. type PullRequestArtifactReadInput struct { PullRequestArtifactCoordinates - Method string `json:"method" jsonschema:"Read operation: list"` - CommitOID string `json:"commit_oid,omitempty" jsonschema:"Commit selection: omitted or current for the current PR head, all for every commit, or an explicit commit OID"` - Page int `json:"page,omitempty" jsonschema:"Page number, starting at 1 (default 1)"` - PerPage int `json:"perPage,omitempty" jsonschema:"Results per page, from 1 to 100 (default 30)"` + Method string `json:"method" jsonschema:"Read operation: list or get"` + ArtifactNumber int `json:"artifact_number,omitempty" jsonschema:"Positive PR-scoped artifact number; required for get"` + CommitOID string `json:"commit_oid,omitempty" jsonschema:"List commit selection: omitted or current for the PR head, all for the newest version regardless of commit, or an explicit commit OID"` + Page int `json:"page,omitempty" jsonschema:"Page number, starting at 1 (default 1)"` + PerPage int `json:"perPage,omitempty" jsonschema:"Results per page, from 1 to 100 (default 30)"` } -// PullRequestArtifactWriteInput upserts or deletes an artifact by name. +// PullRequestArtifactWriteInput upserts by name or updates or deletes by number. type PullRequestArtifactWriteInput struct { PullRequestArtifactCoordinates - Method string `json:"method" jsonschema:"Write operation: upsert or delete"` - Name string `json:"name,omitempty" jsonschema:"Exact artifact name for creation or addressing; mutually exclusive with name_key. Do not copy sanitized display names from read results"` - NameKey string `json:"name_key,omitempty" jsonschema:"Lossless addressing key returned by artifact reads or writes; mutually exclusive with name. Pass verbatim without decoding"` - Body *string `json:"body,omitempty" jsonschema:"Required for upsert: artifact content; an empty string is sent unchanged. Not supported for delete"` - CommitOID *string `json:"commit_oid,omitempty" jsonschema:"Optional commit OID for upsert only; omission preserves the API default"` + Method string `json:"method" jsonschema:"Write operation: upsert, update, or delete"` + ArtifactNumber int `json:"artifact_number,omitempty" jsonschema:"Positive PR-scoped artifact number; required for update and delete"` + Name string `json:"name,omitempty" jsonschema:"Exact artifact name for upsert; mutually exclusive with name_key. Do not copy sanitized display names from read results"` + NameKey string `json:"name_key,omitempty" jsonschema:"Lossless name key returned by artifact reads or writes for upsert; mutually exclusive with name"` + Type string `json:"type,omitempty" jsonschema:"Artifact type for upsert: generic or embedded_html; omission defaults to generic"` + Body *string `json:"body,omitempty" jsonschema:"Required for upsert and update: artifact content"` + CommitOID *string `json:"commit_oid,omitempty" jsonschema:"Optional for upsert; required for update, with an empty string clearing the association"` } -// PullRequestArtifactReadOutput contains a page of artifact versions. +// PullRequestArtifactReadOutput contains a page of artifacts or an individual artifact. type PullRequestArtifactReadOutput struct { - List *ListPullRequestArtifactsOutput `json:"list"` + List *ListPullRequestArtifactsOutput `json:"list,omitempty"` + Artifact *PullRequestArtifact `json:"artifact,omitempty"` } // ListPullRequestArtifactsOutput includes REST Link-based pagination. @@ -60,16 +65,15 @@ type ListPullRequestArtifactsOutput struct { NextPage int `json:"next_page,omitempty" jsonschema:"Next page from the API Link header; absent when there is no next page"` } -// PullRequestArtifactWriteOutput contains an upsert result or delete confirmation. +// PullRequestArtifactWriteOutput contains a write result or delete confirmation. type PullRequestArtifactWriteOutput struct { Artifact *PullRequestArtifact `json:"artifact,omitempty"` Deleted *DeletePullRequestArtifactOutput `json:"deleted,omitempty"` } -// DeletePullRequestArtifactOutput confirms the named artifact that was deleted. +// DeletePullRequestArtifactOutput confirms the numbered artifact that was deleted. type DeletePullRequestArtifactOutput struct { - PullNumber int `json:"pull_number"` - Name string `json:"name" jsonschema:"Sanitized display name of the deleted artifact"` - NameKey string `json:"name_key" jsonschema:"Lossless addressing key of the deleted artifact"` - Message string `json:"message"` + PullNumber int `json:"pull_number"` + ArtifactNumber int `json:"artifact_number"` + Message string `json:"message"` } diff --git a/pkg/github/pull_request_artifacts.go b/pkg/github/pull_request_artifacts.go index 3316567d4d..14e8ceb507 100644 --- a/pkg/github/pull_request_artifacts.go +++ b/pkg/github/pull_request_artifacts.go @@ -34,10 +34,10 @@ const ( type deletePullRequestArtifactState struct { PullRequestArtifactCoordinates - Operation string `json:"operation"` - Name string `json:"name"` - RepositoryID int64 `json:"repository_id"` - ExpiresAt int64 `json:"expires_at"` + Operation string `json:"operation"` + ArtifactNumber int `json:"artifact_number"` + RepositoryID int64 `json:"repository_id"` + ExpiresAt int64 `json:"expires_at"` } func newPullRequestArtifactTool[In, Out any](t translations.TranslationHelperFunc, name, title, description string, readOnly bool, methods []string, @@ -46,7 +46,7 @@ func newPullRequestArtifactTool[In, Out any](t translations.TranslationHelperFun key := "TOOL_" + strings.ToUpper(name) schema := issueDTOschema[In]() schema.Properties["method"] = inventory.EnumSchema(methods...) - for _, field := range []string{"pull_number", "page", "perPage"} { + for _, field := range []string{"pull_number", "artifact_number", "page", "perPage"} { if property := schema.Properties[field]; property != nil { property.Minimum = new(1.0) } @@ -64,6 +64,9 @@ func newPullRequestArtifactTool[In, Out any](t translations.TranslationHelperFun if property := schema.Properties["perPage"]; property != nil { property.Maximum = new(100.0) } + if property := schema.Properties["type"]; property != nil { + property.Enum = []any{"generic", "embedded_html"} + } st := NewToolWithSchemaOptions(ToolsetMetadataPullRequests, mcp.Tool{ Name: name, Description: t(key+"_DESCRIPTION", description), InputSchema: schema, @@ -81,14 +84,36 @@ func newPullRequestArtifactTool[In, Out any](t translations.TranslationHelperFun return st } -// PullRequestArtifactRead lists pull request artifact versions, including bodies. +// PullRequestArtifactRead lists or gets pull request artifact versions, including bodies. func PullRequestArtifactRead(t translations.TranslationHelperFunc) inventory.ServerTool { return newPullRequestArtifactTool(t, "pull_request_artifact_read", "Read pull request artifacts", - "List GitHub pull request artifact versions including their bodies. Names are sanitized for display; use the returned name_key, not name, for subsequent writes. commit_oid defaults to the current PR head; use all or an explicit commit OID to change the selection. Returns one page; request next_page when present. Repository access and the repository's pull_request_artifacts_api rollout are enforced by GitHub. Unavailable in lockdown mode.", - true, []string{"list"}, + "List GitHub pull request artifact versions or get the current version by PR-scoped artifact_number, including bodies. Names are sanitized for display; use number for get, update, and delete, or name_key for upsert. List commit_oid defaults to the current PR head; use all or an explicit commit OID to change the selection. List returns one page; request next_page when present. Repository access and the repository's pull_request_artifacts_api rollout are enforced by GitHub. Unavailable in lockdown mode.", + true, []string{"list", "get"}, func(ctx context.Context, deps ToolDependencies, _ *mcp.CallToolRequest, input PullRequestArtifactReadInput) (*mcp.CallToolResult, *PullRequestArtifactReadOutput, error) { + if input.Method == "get" { + if input.ArtifactNumber <= 0 || input.CommitOID != "" || input.Page != 0 || input.PerPage != 0 { + return utils.NewToolResultError("get requires a positive artifact_number and does not support commit_oid, page, or perPage"), nil, nil + } + var artifact PullRequestArtifact + _, repository, failure := pullRequestArtifactRequest(ctx, deps, input.PullRequestArtifactCoordinates, input.ArtifactNumber, http.MethodGet, nil, nil, &artifact, 0, http.StatusOK) + if failure != nil { + return failure, nil, nil + } + if err := validatePullRequestArtifact(&artifact); err != nil { + return utils.NewToolResultErrorFromErr("invalid pull request artifact response", err), nil, nil + } + if artifact.Number != input.ArtifactNumber { + return utils.NewToolResultError("response artifact number does not match requested number"), nil, nil + } + sanitizePullRequestArtifact(&artifact) + output := &PullRequestArtifactReadOutput{Artifact: &artifact} + return pullRequestArtifactResult(ctx, deps, repository, output), output, nil + } if input.Method != "list" { - return utils.NewToolResultError("method must be list"), nil, nil + return utils.NewToolResultError("method must be list or get"), nil, nil + } + if input.ArtifactNumber != 0 { + return utils.NewToolResultError("artifact_number is not supported for list"), nil, nil } if input.Page < 0 || input.PerPage < 0 || input.PerPage > 100 { return utils.NewToolResultError("page must be positive and perPage must be between 1 and 100"), nil, nil @@ -104,7 +129,7 @@ func PullRequestArtifactRead(t translations.TranslationHelperFunc) inventory.Ser query.Set("commit_oid", input.CommitOID) } var artifacts []PullRequestArtifact - response, repository, failure := pullRequestArtifactRequest(ctx, deps, input.PullRequestArtifactCoordinates, "", http.MethodGet, query, nil, &artifacts, 0, http.StatusOK) + response, repository, failure := pullRequestArtifactRequest(ctx, deps, input.PullRequestArtifactCoordinates, 0, http.MethodGet, query, nil, &artifacts, 0, http.StatusOK) if failure != nil { return failure, nil, nil } @@ -124,36 +149,44 @@ func PullRequestArtifactRead(t translations.TranslationHelperFunc) inventory.Ser }) } -// PullRequestArtifactWrite upserts or deletes a pull request artifact by name. +// PullRequestArtifactWrite upserts by name or updates or deletes by number. func PullRequestArtifactWrite(t translations.TranslationHelperFunc) inventory.ServerTool { return newPullRequestArtifactTool(t, "pull_request_artifact_write", "Write pull request artifacts", - "Upsert or delete a GitHub pull request artifact using exactly one of name (the exact original name) or name_key (the lossless key returned by reads or writes), not its number or global ID. Never use a sanitized display name to address an existing artifact. Upsert requires body and optionally accepts commit_oid; creates a new artifact or replaces the named artifact's content. Delete requires explicit user confirmation through form elicitation with MCP protocol 2026-07-28 or later, and does not accept body or commit_oid. Writes are not automatically retried. Repository access and the repository's pull_request_artifacts_api rollout are enforced by GitHub. Unavailable in lockdown mode.", - false, []string{"upsert", "delete"}, + "Upsert a GitHub pull request artifact by exact name or lossless name_key, or update or delete it by PR-scoped artifact_number. Upsert requires body and optionally accepts type and commit_oid; omitted type defaults to generic, so specify embedded_html when upserting HTML artifacts. Update requires body and commit_oid; an empty commit_oid clears the association. Delete requires explicit user confirmation through form elicitation with MCP protocol 2026-07-28 or later. Writes are not automatically retried. Repository access and the repository's pull_request_artifacts_api rollout are enforced by GitHub. Unavailable in lockdown mode.", + false, []string{"upsert", "update", "delete"}, func(ctx context.Context, deps ToolDependencies, req *mcp.CallToolRequest, input PullRequestArtifactWriteInput) (*mcp.CallToolResult, *PullRequestArtifactWriteOutput, error) { - if input.NameKey != "" { - if input.Name != "" { - return utils.NewToolResultError("provide exactly one of name or name_key"), nil, nil - } - name, err := base64.RawURLEncoding.DecodeString(input.NameKey) - if err != nil || !utf8.Valid(name) || base64.RawURLEncoding.EncodeToString(name) != input.NameKey { - return utils.NewToolResultError("name_key must be a valid lossless key returned by artifact reads or writes"), nil, nil - } - input.Name = string(name) - } - if strings.TrimSpace(input.Name) == "" || input.Name == "." || input.Name == ".." || strings.ContainsAny(input.Name, "/\\") { - return utils.NewToolResultError("name must be a nonempty artifact path segment"), nil, nil - } switch input.Method { case "upsert": + if input.ArtifactNumber != 0 { + return utils.NewToolResultError("artifact_number is not supported for upsert"), nil, nil + } + if input.Type != "" && input.Type != "generic" && input.Type != "embedded_html" { + return utils.NewToolResultError("type must be generic or embedded_html"), nil, nil + } + if input.NameKey != "" { + if input.Name != "" { + return utils.NewToolResultError("provide exactly one of name or name_key"), nil, nil + } + name, err := base64.RawURLEncoding.DecodeString(input.NameKey) + if err != nil || !utf8.Valid(name) || base64.RawURLEncoding.EncodeToString(name) != input.NameKey { + return utils.NewToolResultError("name_key must be a valid lossless key returned by artifact reads or writes"), nil, nil + } + input.Name = string(name) + } + if strings.TrimSpace(input.Name) == "" || input.Name == "." || input.Name == ".." || strings.ContainsAny(input.Name, "/\\") { + return utils.NewToolResultError("name must be nonempty, cannot be . or .., and cannot contain slashes"), nil, nil + } if input.Body == nil { return utils.NewToolResultError("body is required for upsert"), nil, nil } body := struct { + Name string `json:"name"` + Type string `json:"type,omitempty"` Body string `json:"body"` CommitOID *string `json:"commit_oid,omitempty"` - }{*input.Body, input.CommitOID} + }{input.Name, input.Type, *input.Body, input.CommitOID} var artifact PullRequestArtifact - _, repository, failure := pullRequestArtifactRequest(ctx, deps, input.PullRequestArtifactCoordinates, input.Name, http.MethodPut, nil, body, &artifact, 0, http.StatusOK, http.StatusCreated) + _, repository, failure := pullRequestArtifactRequest(ctx, deps, input.PullRequestArtifactCoordinates, 0, http.MethodPut, nil, body, &artifact, 0, http.StatusOK, http.StatusCreated) if failure != nil { return failure, nil, nil } @@ -166,24 +199,45 @@ func PullRequestArtifactWrite(t translations.TranslationHelperFunc) inventory.Se sanitizePullRequestArtifact(&artifact) output := &PullRequestArtifactWriteOutput{Artifact: &artifact} return pullRequestArtifactResult(ctx, deps, repository, output), output, nil + case "update": + if input.ArtifactNumber <= 0 || input.Name != "" || input.NameKey != "" || input.Type != "" || input.Body == nil || input.CommitOID == nil { + return utils.NewToolResultError("update requires a positive artifact_number, body, and commit_oid; name, name_key, and type are not supported"), nil, nil + } + body := struct { + Body string `json:"body"` + CommitOID string `json:"commit_oid"` + }{*input.Body, *input.CommitOID} + var artifact PullRequestArtifact + _, repository, failure := pullRequestArtifactRequest(ctx, deps, input.PullRequestArtifactCoordinates, input.ArtifactNumber, http.MethodPatch, nil, body, &artifact, 0, http.StatusOK) + if failure != nil { + return failure, nil, nil + } + if err := validatePullRequestArtifact(&artifact); err != nil { + return utils.NewToolResultErrorFromErr("invalid pull request artifact response", err), nil, nil + } + if artifact.Number != input.ArtifactNumber { + return utils.NewToolResultError("response artifact number does not match requested number"), nil, nil + } + sanitizePullRequestArtifact(&artifact) + output := &PullRequestArtifactWriteOutput{Artifact: &artifact} + return pullRequestArtifactResult(ctx, deps, repository, output), output, nil case "delete": - if input.Body != nil || input.CommitOID != nil { - return utils.NewToolResultError("body and commit_oid are not supported for delete"), nil, nil + if input.ArtifactNumber <= 0 || input.Name != "" || input.NameKey != "" || input.Type != "" || input.Body != nil || input.CommitOID != nil { + return utils.NewToolResultError("delete requires a positive artifact_number and does not support name, name_key, type, body, or commit_oid"), nil, nil } repositoryID, confirmation := confirmPullRequestArtifactDeletion(ctx, deps, req, input) if confirmation != nil { return confirmation, nil, nil } - if _, _, failure := pullRequestArtifactRequest(ctx, deps, input.PullRequestArtifactCoordinates, input.Name, http.MethodDelete, nil, nil, nil, repositoryID, http.StatusNoContent); failure != nil { + if _, _, failure := pullRequestArtifactRequest(ctx, deps, input.PullRequestArtifactCoordinates, input.ArtifactNumber, http.MethodDelete, nil, nil, nil, repositoryID, http.StatusNoContent); failure != nil { return failure, nil, nil } output := &PullRequestArtifactWriteOutput{Deleted: &DeletePullRequestArtifactOutput{ - PullNumber: input.PullNumber, Name: sanitize.PlainText(input.Name), - NameKey: base64.RawURLEncoding.EncodeToString([]byte(input.Name)), Message: "artifact deleted", + PullNumber: input.PullNumber, ArtifactNumber: input.ArtifactNumber, Message: "artifact deleted", }} return MarshalledTextResult(output), output, nil default: - return utils.NewToolResultError("method must be upsert or delete"), nil, nil + return utils.NewToolResultError("method must be upsert, update, or delete"), nil, nil } }) } @@ -203,7 +257,7 @@ func confirmPullRequestArtifactDeletion(ctx context.Context, deps ToolDependenci if sealer == nil { return 0, utils.NewToolResultError("Artifact deletion is unavailable because request-state protection is not configured.") } - target := fmt.Sprintf("%s/%s#%d artifact %q", input.Owner, input.Repo, input.PullNumber, input.Name) + target := fmt.Sprintf("%s/%s#%d artifact #%d", input.Owner, input.Repo, input.PullNumber, input.ArtifactNumber) response, ok := req.Params.InputResponses[deletePullRequestArtifactConfirmationID] if !ok { _, repository, failure := resolvePullRequestArtifactRepository(ctx, deps, input.PullRequestArtifactCoordinates) @@ -213,7 +267,7 @@ func confirmPullRequestArtifactDeletion(ctx context.Context, deps ToolDependenci state, err := json.Marshal(deletePullRequestArtifactState{ PullRequestArtifactCoordinates: input.PullRequestArtifactCoordinates, Operation: "pull_request_artifact_write:delete", - Name: input.Name, RepositoryID: repository.GetID(), + ArtifactNumber: input.ArtifactNumber, RepositoryID: repository.GetID(), ExpiresAt: time.Now().Add(deletePullRequestArtifactConfirmationTTL).Unix(), }) if err != nil { @@ -251,7 +305,7 @@ func confirmPullRequestArtifactDeletion(ctx context.Context, deps ToolDependenci if err := json.Unmarshal(stateJSON, &state); err != nil { return 0, utils.NewToolResultError("Artifact deletion confirmation state was invalid. The artifact was not deleted.") } - if state.Operation != "pull_request_artifact_write:delete" || state.PullRequestArtifactCoordinates != input.PullRequestArtifactCoordinates || state.Name != input.Name || state.RepositoryID <= 0 { + if state.Operation != "pull_request_artifact_write:delete" || state.PullRequestArtifactCoordinates != input.PullRequestArtifactCoordinates || state.ArtifactNumber != input.ArtifactNumber || state.RepositoryID <= 0 { return 0, utils.NewToolResultError("Artifact deletion target changed or confirmation state was invalid. The artifact was not deleted.") } if state.ExpiresAt <= time.Now().Unix() { @@ -303,7 +357,7 @@ func resolvePullRequestArtifactRepository(ctx context.Context, deps ToolDependen return client, repository, nil } -func pullRequestArtifactRequest(ctx context.Context, deps ToolDependencies, coordinates PullRequestArtifactCoordinates, name, method string, query url.Values, body, output any, expectedRepositoryID int64, statuses ...int) (*gogithub.Response, *gogithub.Repository, *mcp.CallToolResult) { +func pullRequestArtifactRequest(ctx context.Context, deps ToolDependencies, coordinates PullRequestArtifactCoordinates, artifactNumber int, method string, query url.Values, body, output any, expectedRepositoryID int64, statuses ...int) (*gogithub.Response, *gogithub.Repository, *mcp.CallToolResult) { client, repository, failure := resolvePullRequestArtifactRepository(ctx, deps, coordinates) if failure != nil { return nil, nil, failure @@ -312,8 +366,8 @@ func pullRequestArtifactRequest(ctx context.Context, deps ToolDependencies, coor return nil, nil, utils.NewToolResultError("Repository identity changed after artifact deletion confirmation was requested. The artifact was not deleted.") } path := fmt.Sprintf("repositories/%d/pulls/%d/artifacts", repository.GetID(), coordinates.PullNumber) - if name != "" { - path += "/" + url.PathEscape(name) + if artifactNumber > 0 { + path += "/" + strconv.Itoa(artifactNumber) } if len(query) > 0 { path += "?" + query.Encode() @@ -361,6 +415,7 @@ func validatePullRequestArtifact(artifact *PullRequestArtifact) error { func sanitizePullRequestArtifact(artifact *PullRequestArtifact) { artifact.NameKey = base64.RawURLEncoding.EncodeToString([]byte(artifact.Name)) artifact.Name = sanitize.PlainText(artifact.Name) + artifact.Type = sanitize.PlainText(artifact.Type) artifact.Body = sanitize.Content(artifact.Body) if artifact.Creator != nil { artifact.Creator.Login = sanitize.PlainText(artifact.Creator.Login) diff --git a/pkg/github/pull_request_artifacts_test.go b/pkg/github/pull_request_artifacts_test.go index 7be7fbfa34..60dcfd78c1 100644 --- a/pkg/github/pull_request_artifacts_test.go +++ b/pkg/github/pull_request_artifacts_test.go @@ -7,7 +7,6 @@ import ( "maps" "net/http" "net/http/httptest" - "net/url" "strings" "testing" @@ -28,7 +27,7 @@ func pullRequestArtifactTestTools() []inventory.ServerTool { } func pullRequestArtifactTestTool(method string) inventory.ServerTool { - if method == "list" { + if method == "list" || method == "get" { return PullRequestArtifactRead(translations.NullTranslationHelper) } return PullRequestArtifactWrite(translations.NullTranslationHelper) @@ -127,7 +126,7 @@ func TestPullRequestArtifactTools(t *testing.T) { } func TestPullRequestArtifactRequests(t *testing.T) { - artifact := `{"id":"artifact-id","number":3,"name":"report","body":"full body","commit_oid":null,"creator":null,"created_at":null,"updated_at":null}` + artifact := `{"id":"artifact-id","number":3,"type":"embedded_html","name":"report","body":"full body","commit_oid":null,"creator":null,"created_at":null,"updated_at":null}` for _, protocol := range []string{inventory.ProtocolVersionMultiRoundTrip, "2025-11-25"} { for _, tc := range []struct { name, method, verb, query, body string @@ -136,9 +135,12 @@ func TestPullRequestArtifactRequests(t *testing.T) { response string next bool }{ - {name: "upsert create empty body", method: "upsert", verb: "PUT", args: map[string]any{"name": "report", "body": ""}, body: `{"body":""}`, status: 201, response: artifact}, - {name: "upsert update with commit", method: "upsert", verb: "PUT", args: map[string]any{"name": "report", "body": "new", "commit_oid": "abc123"}, body: `{"body":"new","commit_oid":"abc123"}`, status: 200, response: artifact}, - {name: "upsert with lossless key", method: "upsert", verb: "PUT", args: map[string]any{"name_key": "cmVwb3J0", "body": "new"}, body: `{"body":"new"}`, status: 200, response: artifact}, + {name: "upsert create empty body", method: "upsert", verb: "PUT", args: map[string]any{"name": "report", "body": ""}, body: `{"name":"report","body":""}`, status: 201, response: artifact}, + {name: "upsert update with commit and type", method: "upsert", verb: "PUT", args: map[string]any{"name": "report", "type": "embedded_html", "body": "new", "commit_oid": "abc123"}, body: `{"name":"report","type":"embedded_html","body":"new","commit_oid":"abc123"}`, status: 200, response: artifact}, + {name: "upsert with lossless key", method: "upsert", verb: "PUT", args: map[string]any{"name_key": "cmVwb3J0", "body": "new"}, body: `{"name":"report","body":"new"}`, status: 200, response: artifact}, + {name: "get by number", method: "get", verb: "GET", args: map[string]any{"artifact_number": 3}, status: 200, response: artifact}, + {name: "update by number", method: "update", verb: "PATCH", args: map[string]any{"artifact_number": 3, "body": "new", "commit_oid": "abc123"}, body: `{"body":"new","commit_oid":"abc123"}`, status: 200, response: artifact}, + {name: "update clear commit", method: "update", verb: "PATCH", args: map[string]any{"artifact_number": 3, "body": "new", "commit_oid": ""}, body: `{"body":"new","commit_oid":""}`, status: 200, response: artifact}, {name: "list default", method: "list", verb: "GET", query: "page=1&per_page=30", status: 200, response: "[" + artifact + "]"}, {name: "list current", method: "list", verb: "GET", args: map[string]any{"commit_oid": "current"}, query: "commit_oid=current&page=1&per_page=30", status: 200, response: "[" + artifact + "]"}, {name: "list all", method: "list", verb: "GET", args: map[string]any{"commit_oid": "all"}, query: "commit_oid=all&page=1&per_page=30", status: 200, response: "[" + artifact + "]"}, @@ -160,8 +162,8 @@ func TestPullRequestArtifactRequests(t *testing.T) { } assert.Equal(t, tc.verb, r.Method) path := "/api/v3/repositories/42/pulls/12/artifacts" - if tc.method != "list" { - path += "/report" + if tc.method == "get" || tc.method == "update" { + path += "/3" } assert.Equal(t, path, r.URL.Path) assert.Equal(t, tc.query, r.URL.RawQuery) @@ -207,7 +209,7 @@ func TestPullRequestArtifactRequests(t *testing.T) { assert.Equal(t, 2, output.List.Page) assert.Equal(t, 1, output.List.PerPage) } - case "upsert": + case "upsert", "get", "update": expected := strings.Replace(artifact, `"name":"report"`, `"name":"report","name_key":"cmVwb3J0"`, 1) assert.JSONEq(t, `{"artifact":`+expected+`}`, text) } @@ -216,42 +218,28 @@ func TestPullRequestArtifactRequests(t *testing.T) { } } -func TestPullRequestArtifactEscapedNames(t *testing.T) { - for _, method := range []string{"upsert", "delete"} { - t.Run(method, func(t *testing.T) { - name := "report #1?%draft" - calls := 0 - client := pullRequestArtifactTestClient(t, func(w http.ResponseWriter, r *http.Request) { - calls++ - if r.Method == http.MethodGet && strings.Contains(r.URL.Path, "/repos/") { - _, _ = w.Write([]byte(`{"id":42}`)) - return - } - assert.Equal(t, "/api/v3/repositories/42/pulls/12/artifacts/"+url.PathEscape(name), r.URL.EscapedPath()) - assert.Empty(t, r.URL.RawQuery) - if method == "delete" { - w.WriteHeader(http.StatusNoContent) - return - } - _, _ = fmt.Fprintf(w, `{"id":9007199254740993,"number":3,"name":%q,"body":""}`, name) - }) - args := map[string]any{"owner": "o", "repo": "r", "pull_number": 12, "method": method, "name": name} - if method == "upsert" { - args["body"] = "" - } - deps := BaseDeps{Client: client} - result := invokePullRequestArtifactWithApproval(context.Background(), t, deps, args) - require.False(t, result.IsError, mustMarshalJSON(t, result)) - expectedCalls := 2 - if method == "delete" { - expectedCalls++ - } - assert.Equal(t, expectedCalls, calls) - if method == "upsert" { - assert.Contains(t, getTextResult(t, result).Text, `"id":9007199254740993`) - } - }) - } +func TestPullRequestArtifactUpsertNameInBody(t *testing.T) { + name := "report #1?%draft" + calls := 0 + client := pullRequestArtifactTestClient(t, func(w http.ResponseWriter, r *http.Request) { + calls++ + if r.Method == http.MethodGet && strings.Contains(r.URL.Path, "/repos/") { + _, _ = w.Write([]byte(`{"id":42}`)) + return + } + assert.Equal(t, "/api/v3/repositories/42/pulls/12/artifacts", r.URL.Path) + assert.Empty(t, r.URL.RawQuery) + var body map[string]any + require.NoError(t, json.NewDecoder(r.Body).Decode(&body)) + assert.Equal(t, name, body["name"]) + _, _ = fmt.Fprintf(w, `{"id":9007199254740993,"number":3,"name":%q,"body":""}`, name) + }) + args := map[string]any{"owner": "o", "repo": "r", "pull_number": 12, "method": "upsert", "name": name, "body": ""} + deps := BaseDeps{Client: client} + result := invokePullRequestArtifactWithApproval(context.Background(), t, deps, args) + require.False(t, result.IsError, mustMarshalJSON(t, result)) + assert.Equal(t, 2, calls) + assert.Contains(t, getTextResult(t, result).Text, `"id":9007199254740993`) } func TestPullRequestArtifactRepositoryEscaping(t *testing.T) { @@ -284,11 +272,11 @@ func TestPullRequestArtifactInvalidInputs(t *testing.T) { {"missing body", "upsert", nil}, {"missing name", "upsert", map[string]any{"name": "", "body": ""}}, {"null body", "upsert", map[string]any{"body": nil}}, - {"blank name", "delete", map[string]any{"name": " "}}, - {"dot name", "delete", map[string]any{"name": "."}}, - {"traversal name", "delete", map[string]any{"name": ".."}}, - {"slash name", "delete", map[string]any{"name": "../x"}}, - {"backslash name", "delete", map[string]any{"name": `a\b`}}, + {"blank name", "upsert", map[string]any{"name": " ", "body": "x"}}, + {"dot name", "upsert", map[string]any{"name": ".", "body": "x"}}, + {"traversal name", "upsert", map[string]any{"name": "..", "body": "x"}}, + {"slash name", "upsert", map[string]any{"name": "../x", "body": "x"}}, + {"backslash name", "upsert", map[string]any{"name": `a\b`, "body": "x"}}, {"delete body", "delete", map[string]any{"body": ""}}, {"delete commit", "delete", map[string]any{"commit_oid": "abc"}}, {"both name and key", "upsert", map[string]any{"name_key": "cmVwb3J0", "body": ""}}, @@ -296,7 +284,21 @@ func TestPullRequestArtifactInvalidInputs(t *testing.T) { {"noncanonical key", "upsert", map[string]any{"name": "", "name_key": "cmVwb3J0\n", "body": ""}}, {"invalid UTF-8 key", "upsert", map[string]any{"name": "", "name_key": "_w", "body": ""}}, {"slash key", "upsert", map[string]any{"name": "", "name_key": "YS9i", "body": ""}}, - {"traversal key", "delete", map[string]any{"name": "", "name_key": "Li4"}}, + {"traversal key", "upsert", map[string]any{"name": "", "name_key": "Li4", "body": "x"}}, + {"upsert number", "upsert", map[string]any{"artifact_number": 3, "body": "x"}}, + {"invalid type", "upsert", map[string]any{"type": "other", "body": "x"}}, + {"missing get number", "get", map[string]any{"artifact_number": 0}}, + {"get commit", "get", map[string]any{"commit_oid": "all"}}, + {"get page", "get", map[string]any{"page": 2}}, + {"list number", "list", map[string]any{"artifact_number": 3}}, + {"missing update number", "update", map[string]any{"artifact_number": 0, "body": "x", "commit_oid": ""}}, + {"missing update body", "update", map[string]any{"commit_oid": ""}}, + {"missing update commit", "update", map[string]any{"body": "x"}}, + {"update name", "update", map[string]any{"name": "report", "body": "x", "commit_oid": ""}}, + {"update type", "update", map[string]any{"type": "generic", "body": "x", "commit_oid": ""}}, + {"missing delete number", "delete", map[string]any{"artifact_number": 0}}, + {"delete name", "delete", map[string]any{"name": "report"}}, + {"delete key", "delete", map[string]any{"name_key": "cmVwb3J0"}}, {"negative pull", "list", map[string]any{"pull_number": -1}}, {"missing pull", "list", map[string]any{"pull_number": 0}}, {"empty owner", "list", map[string]any{"owner": " "}}, @@ -305,7 +307,7 @@ func TestPullRequestArtifactInvalidInputs(t *testing.T) { {"negative page", "list", map[string]any{"page": -1}}, {"negative size", "list", map[string]any{"perPage": -1}}, {"large size", "list", map[string]any{"perPage": 101}}, - {"unknown read method", "list", map[string]any{"method": "get"}}, + {"unknown read method", "list", map[string]any{"method": "other"}}, {"unknown write method", "upsert", map[string]any{"method": "create", "body": ""}}, {"missing method", "list", map[string]any{"method": ""}}, } { @@ -316,8 +318,11 @@ func TestPullRequestArtifactInvalidInputs(t *testing.T) { w.WriteHeader(http.StatusInternalServerError) }) args := map[string]any{"owner": "o", "repo": "r", "pull_number": 12, "method": tc.method} - if tc.method != "list" { + switch tc.method { + case "upsert": args["name"] = "report" + case "get", "update", "delete": + args["artifact_number"] = 3 } maps.Copy(args, tc.args) deps := BaseDeps{Client: client} @@ -336,16 +341,22 @@ func TestPullRequestArtifactInvalidInputs(t *testing.T) { } func TestPullRequestArtifactLockdown(t *testing.T) { - for _, method := range []string{"list", "upsert", "delete"} { + for _, method := range []string{"list", "get", "upsert", "update", "delete"} { t.Run(method, func(t *testing.T) { deps := BaseDeps{Flags: FeatureFlags{LockdownMode: true}} tool := pullRequestArtifactTestTool(method) args := map[string]any{"owner": "o", "repo": "r", "pull_number": 12, "method": method} - if method != "list" { + switch method { + case "upsert": args["name"] = "report" + case "get", "update", "delete": + args["artifact_number"] = 3 } - if method == "upsert" { + switch method { + case "upsert": args["body"] = "" + case "update": + args["body"], args["commit_oid"] = "x", "" } request := createMCPRequest(args) result, err := tool.Handler(deps)(ContextWithDeps(context.Background(), deps), &request) @@ -357,7 +368,7 @@ func TestPullRequestArtifactLockdown(t *testing.T) { } func TestPullRequestArtifactFailures(t *testing.T) { - for _, method := range []string{"list", "upsert", "delete"} { + for _, method := range []string{"list", "get", "upsert", "update", "delete"} { for _, status := range []int{400, 401, 403, 404, 409, 422, 429, 500, 503} { t.Run(method+"/"+http.StatusText(status), func(t *testing.T) { calls := 0 @@ -376,11 +387,17 @@ func TestPullRequestArtifactFailures(t *testing.T) { }) deps := BaseDeps{Client: client} args := map[string]any{"owner": "o", "repo": "r", "pull_number": 12, "method": method} - if method != "list" { + switch method { + case "upsert": args["name"] = "report" + case "get", "update", "delete": + args["artifact_number"] = 3 } - if method == "upsert" { + switch method { + case "upsert": args["body"] = "" + case "update": + args["body"], args["commit_oid"] = "x", "" } result := invokePullRequestArtifactWithApproval(context.Background(), t, deps, args) require.True(t, result.IsError) @@ -427,7 +444,7 @@ func TestPullRequestArtifactRepositoryFailures(t *testing.T) { } func TestPullRequestArtifactRepositoryGate(t *testing.T) { - for _, method := range []string{"list", "upsert", "delete"} { + for _, method := range []string{"list", "get", "upsert", "update", "delete"} { t.Run(method, func(t *testing.T) { calls := 0 client := pullRequestArtifactTestClient(t, func(w http.ResponseWriter, r *http.Request) { @@ -448,7 +465,7 @@ func TestPullRequestArtifactRepositoryGate(t *testing.T) { switch method { case "list": _, _ = w.Write([]byte("[" + artifact + "]")) - case "upsert": + case "upsert", "get", "update": _, _ = w.Write([]byte(artifact)) case "delete": w.WriteHeader(http.StatusNoContent) @@ -459,11 +476,17 @@ func TestPullRequestArtifactRepositoryGate(t *testing.T) { ctx := inventory.WithFeatureState(ContextWithDeps(context.Background(), deps), featureCheckerFor(FeatureFlagPullRequestArtifacts)) for _, repo := range []string{"enabled", "disabled", "enabled"} { args := map[string]any{"owner": "o", "repo": repo, "pull_number": 12, "method": method} - if method != "list" { + switch method { + case "upsert": args["name"] = "report" + case "get", "update", "delete": + args["artifact_number"] = 1 } - if method == "upsert" { + switch method { + case "upsert": args["body"] = "" + case "update": + args["body"], args["commit_oid"] = "x", "" } result := invokePullRequestArtifactWithApproval(ctx, t, deps, args) assert.Equal(t, repo == "disabled", result.IsError, mustMarshalJSON(t, result)) @@ -487,6 +510,8 @@ func TestPullRequestArtifactResponseValidation(t *testing.T) { {"invalid ID", "list", `[{"id":{},"number":1,"name":"report","body":""}]`, 200}, {"missing number", "upsert", `{"id":"a","name":"report","body":""}`, 200}, {"mismatched name", "upsert", `{"id":"a","number":1,"name":"other","body":""}`, 200}, + {"mismatched get number", "get", `{"id":"a","number":1,"name":"report","body":""}`, 200}, + {"mismatched update number", "update", `{"id":"a","number":1,"name":"report","body":""}`, 200}, {"unexpected success", "upsert", `{}`, 202}, {"unexpected delete", "delete", `{}`, 200}, } { @@ -503,11 +528,17 @@ func TestPullRequestArtifactResponseValidation(t *testing.T) { }) deps := BaseDeps{Client: client} args := map[string]any{"owner": "o", "repo": "r", "pull_number": 12, "method": tc.method} - if tc.method != "list" { + switch tc.method { + case "upsert": args["name"] = "report" + case "get", "update", "delete": + args["artifact_number"] = 3 } - if tc.method == "upsert" { + switch tc.method { + case "upsert": args["body"] = "" + case "update": + args["body"], args["commit_oid"] = "x", "" } result := invokePullRequestArtifactWithApproval(context.Background(), t, deps, args) require.True(t, result.IsError) @@ -554,7 +585,7 @@ func TestPullRequestArtifactSanitization(t *testing.T) { } func TestPullRequestArtifactIFCLabels(t *testing.T) { - for _, method := range []string{"list", "upsert"} { + for _, method := range []string{"list", "get", "upsert", "update"} { for _, visibility := range []struct { name, repository string label ifc.SecurityLabel @@ -585,8 +616,13 @@ func TestPullRequestArtifactIFCLabels(t *testing.T) { } session := pullRequestArtifactTestSession(t, deps, inventory.ProtocolVersionMultiRoundTrip) args := map[string]any{"owner": "o", "repo": "r", "pull_number": 12, "method": method} - if method == "upsert" { + switch method { + case "upsert": args["name"], args["body"] = "report", "artifact content" + case "get": + args["artifact_number"] = 1 + case "update": + args["artifact_number"], args["body"], args["commit_oid"] = 1, "artifact content", "" } result, err := session.CallTool(context.Background(), &mcp.CallToolParams{ Name: pullRequestArtifactTestTool(method).Tool.Name, Arguments: args, From 11086194aa120a7df2e55590398ffe91cc500546 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 2 Dec 2026 17:21:56 +0000 Subject: [PATCH 2/2] chore: regenerate license files Auto-generated by license-check workflow --- third-party-licenses.darwin.md | 2 +- third-party-licenses.linux.md | 2 +- third-party-licenses.windows.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/third-party-licenses.darwin.md b/third-party-licenses.darwin.md index 315240c267..5a44f5a5a5 100644 --- a/third-party-licenses.darwin.md +++ b/third-party-licenses.darwin.md @@ -21,7 +21,7 @@ The following packages are included for the amd64, arm64 architectures. - [github.com/google/go-querystring/query](https://pkg.go.dev/github.com/google/go-querystring/query) ([BSD-3-Clause](https://github.com/google/go-querystring/blob/v1.2.0/LICENSE)) - [github.com/google/jsonschema-go/jsonschema](https://pkg.go.dev/github.com/google/jsonschema-go/jsonschema) ([MIT](https://github.com/google/jsonschema-go/blob/v0.4.3/LICENSE)) - [github.com/gorilla/css/scanner](https://pkg.go.dev/github.com/gorilla/css/scanner) ([BSD-3-Clause](https://github.com/gorilla/css/blob/v1.0.1/LICENSE)) - - [github.com/josephburnett/jd/v2](https://pkg.go.dev/github.com/josephburnett/jd/v2) ([MIT](https://github.com/josephburnett/jd/blob/v2.5.0/v2/LICENSE)) + - [github.com/josephburnett/jd/v2](https://pkg.go.dev/github.com/josephburnett/jd/v2) ([MIT](https://github.com/josephburnett/jd/blob/v2.5.0/LICENSE)) - [github.com/lithammer/fuzzysearch/fuzzy](https://pkg.go.dev/github.com/lithammer/fuzzysearch/fuzzy) ([MIT](https://github.com/lithammer/fuzzysearch/blob/v1.1.8/LICENSE)) - [github.com/microcosm-cc/bluemonday](https://pkg.go.dev/github.com/microcosm-cc/bluemonday) ([BSD-3-Clause](https://github.com/microcosm-cc/bluemonday/blob/v1.0.27/LICENSE.md)) - [github.com/modelcontextprotocol/go-sdk](https://pkg.go.dev/github.com/modelcontextprotocol/go-sdk) ([Apache-2.0](https://github.com/modelcontextprotocol/go-sdk/blob/v1.9.0/LICENSE)) diff --git a/third-party-licenses.linux.md b/third-party-licenses.linux.md index 94152ca40d..63e43dabe4 100644 --- a/third-party-licenses.linux.md +++ b/third-party-licenses.linux.md @@ -21,7 +21,7 @@ The following packages are included for the 386, amd64, arm64 architectures. - [github.com/google/go-querystring/query](https://pkg.go.dev/github.com/google/go-querystring/query) ([BSD-3-Clause](https://github.com/google/go-querystring/blob/v1.2.0/LICENSE)) - [github.com/google/jsonschema-go/jsonschema](https://pkg.go.dev/github.com/google/jsonschema-go/jsonschema) ([MIT](https://github.com/google/jsonschema-go/blob/v0.4.3/LICENSE)) - [github.com/gorilla/css/scanner](https://pkg.go.dev/github.com/gorilla/css/scanner) ([BSD-3-Clause](https://github.com/gorilla/css/blob/v1.0.1/LICENSE)) - - [github.com/josephburnett/jd/v2](https://pkg.go.dev/github.com/josephburnett/jd/v2) ([MIT](https://github.com/josephburnett/jd/blob/v2.5.0/v2/LICENSE)) + - [github.com/josephburnett/jd/v2](https://pkg.go.dev/github.com/josephburnett/jd/v2) ([MIT](https://github.com/josephburnett/jd/blob/v2.5.0/LICENSE)) - [github.com/lithammer/fuzzysearch/fuzzy](https://pkg.go.dev/github.com/lithammer/fuzzysearch/fuzzy) ([MIT](https://github.com/lithammer/fuzzysearch/blob/v1.1.8/LICENSE)) - [github.com/microcosm-cc/bluemonday](https://pkg.go.dev/github.com/microcosm-cc/bluemonday) ([BSD-3-Clause](https://github.com/microcosm-cc/bluemonday/blob/v1.0.27/LICENSE.md)) - [github.com/modelcontextprotocol/go-sdk](https://pkg.go.dev/github.com/modelcontextprotocol/go-sdk) ([Apache-2.0](https://github.com/modelcontextprotocol/go-sdk/blob/v1.9.0/LICENSE)) diff --git a/third-party-licenses.windows.md b/third-party-licenses.windows.md index 67d0d716a0..323f3f8d48 100644 --- a/third-party-licenses.windows.md +++ b/third-party-licenses.windows.md @@ -22,7 +22,7 @@ The following packages are included for the 386, amd64, arm64 architectures. - [github.com/google/jsonschema-go/jsonschema](https://pkg.go.dev/github.com/google/jsonschema-go/jsonschema) ([MIT](https://github.com/google/jsonschema-go/blob/v0.4.3/LICENSE)) - [github.com/gorilla/css/scanner](https://pkg.go.dev/github.com/gorilla/css/scanner) ([BSD-3-Clause](https://github.com/gorilla/css/blob/v1.0.1/LICENSE)) - [github.com/inconshreveable/mousetrap](https://pkg.go.dev/github.com/inconshreveable/mousetrap) ([Apache-2.0](https://github.com/inconshreveable/mousetrap/blob/v1.1.0/LICENSE)) - - [github.com/josephburnett/jd/v2](https://pkg.go.dev/github.com/josephburnett/jd/v2) ([MIT](https://github.com/josephburnett/jd/blob/v2.5.0/v2/LICENSE)) + - [github.com/josephburnett/jd/v2](https://pkg.go.dev/github.com/josephburnett/jd/v2) ([MIT](https://github.com/josephburnett/jd/blob/v2.5.0/LICENSE)) - [github.com/lithammer/fuzzysearch/fuzzy](https://pkg.go.dev/github.com/lithammer/fuzzysearch/fuzzy) ([MIT](https://github.com/lithammer/fuzzysearch/blob/v1.1.8/LICENSE)) - [github.com/microcosm-cc/bluemonday](https://pkg.go.dev/github.com/microcosm-cc/bluemonday) ([BSD-3-Clause](https://github.com/microcosm-cc/bluemonday/blob/v1.0.27/LICENSE.md)) - [github.com/modelcontextprotocol/go-sdk](https://pkg.go.dev/github.com/modelcontextprotocol/go-sdk) ([Apache-2.0](https://github.com/modelcontextprotocol/go-sdk/blob/v1.9.0/LICENSE))