Commit Graph

16 Commits

Author SHA1 Message Date
Kelsey Myers 4f73cfd1db Add repo-scoped support to list_issue_types tool (#2692)
CodeQL / Analyze (go) (push) Has been cancelled
CodeQL / Analyze (actions) (push) Has been cancelled
CodeQL / Analyze (javascript) (push) Has been cancelled
Docker / build (push) Has been cancelled
Build and Test Go Project / build (macos-latest) (push) Has been cancelled
Build and Test Go Project / build (ubuntu-latest) (push) Has been cancelled
Build and Test Go Project / build (windows-latest) (push) Has been cancelled
GoReleaser Release / release (push) Has been cancelled
MCP Server Diff / mcp-diff (push) Has been cancelled
MCP Server Diff / mcp-diff-http (push) Has been cancelled
Publish to MCP Registry / publish (push) Has been cancelled
* Add repo-scoped support to list_issue_types tool

* Render multi-scope tools as "any of" in generated docs

* Clarify issue type field description for repo-scoped list_issue_types
2026-06-17 17:04:18 +01:00
Dan Moseley 1654d32ad8 errors: improve rate limit error messages for AI agents (#2386)
* errors: improve rate limit error messages for AI agents

When the GitHub API returns a rate limit error, replace the raw Go HTTP
error string with a clean, actionable message so agents know exactly
how long to wait before retrying.

Before:
  search code: GET https://api.github.com/search/code: 403 API rate
  limit exceeded for user ID 12345. [rate reset in 2m59s]

After:
  search code: GitHub API rate limit exceeded. Retry after 2m59s.
  create issue: GitHub secondary rate limit exceeded. Retry after 47s.
  create issue: GitHub secondary rate limit exceeded. Wait before retrying.

Edge cases: expired/zero reset time, nil RetryAfter, and errors
wrapped with errors.As all produce "Wait before retrying." rather
than a negative or confusing duration.

The original error is stored in context via addGitHubAPIErrorToContext
before the rate-limit check, so middleware is unaffected.

Fixes #2385.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* errors: fix flaky rate limit tests

Compute expectedRetryIn before calling the function under test,
and use larger reset time offsets (20-30 min), so a 1s boundary
during time.Duration.Round cannot cause spurious mismatches.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* errors: extract requireErrorText and assertContextHasError test helpers

Reduces repetition in TestNewGitHubAPIErrorResponse_RateLimits subtests.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Fix edge cases: sub-second rate limit durations and UTF-8 BOM

- Primary rate limit: compute time.Until(resetTime) once and check the
  rounded result is >0 before showing 'Retry after X'. This avoids a
  TOCTOU race between the After(time.Now()) guard and the subsequent
  time.Until call, and prevents showing 'Retry after 0s.' when the
  reset time is imminent.

- Secondary rate limit: round RetryAfter first, then check >0.
  Previously, a RetryAfter of e.g. 200ms would pass the >0 guard
  but format as 'Retry after 0s.' after rounding.

- Add tests for both sub-second edge cases.

- Remove UTF-8 BOM accidentally introduced in error_test.go by
  .NET WriteAllText with the default UTF8 encoding.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-06-11 14:16:33 +02:00
Iulia Bejan 1861a351f8 Upgrade go-github from v82 to v87 (#2452)
Breaking changes addressed:
- raw.NewClient: Use WithHTTPClient/WithEnterpriseURLs options, pass ctx to
  NewRequest, return (*Client, error)
- internal/ghmcp/server.go: Use functional options for REST client creation,
  replace UserAgent field mutation with UserAgentTransport wrapper, add
  restUATransp field to githubClients struct
- pkg/github/dependencies.go: Use functional options for REST client creation,
  handle raw.NewClient error return
- pkg/github/actions.go: Handle new WorkflowDispatchRunDetails return value
  from CreateWorkflowDispatchEventByID/ByFileName
- pkg/github/issues.go: Replace IssueListOptions with ListOptions for
  SubIssue.ListByIssue
- pkg/github/notifications.go: MarkThreadDone now takes string instead of
  int64; remove ParseInt and strconv import
- pkg/github/projects.go: Remove pointer indirection from
  ListProjectsPaginationOptions and ListProjectsOptions fields
- pkg/github/issues_granular.go: Pass ctx to NewRequest, remove ctx from Do
- Test files: Add mustNewGHClient helper, replace all NewClient calls,
  fix stubClientFnFromHTTP signature, fix lockdown_test.go BaseURL handling,
  fix raw_test.go, remove invalid threadID test case

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-05-18 14:36:23 +02:00
JoannaaKL 266bd9311e Gogithub update (#2004)
* Bump google/go-github

* chore: regenerate license files

Auto-generated by license-check workflow

* Fix required block

* Go mod vendor and tidy again

* Remove unused fatih/color dependency to fix CI (#2005)

* Initial plan

* Remove unused github.com/fatih/color dependency

The fatih/color package was listed in go.mod but not actually imported
or used anywhere in the codebase. This caused the CI "go mod tidy -diff"
check to fail. Running go mod tidy removed:
- github.com/fatih/color v1.18.0
- github.com/mattn/go-colorable v0.1.13 (transitive)
- github.com/mattn/go-isatty v0.0.20 (transitive)

Fixes the failing ubuntu-latest workflow build.

Co-authored-by: JoannaaKL <67866556+JoannaaKL@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: JoannaaKL <67866556+JoannaaKL@users.noreply.github.com>

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
2026-02-12 11:04:54 +01:00
Adam Holt 762845a8b7 Add API Error annotations to GitHub issue errors (#1566)
* Add API Error annotations to GitHub issue errors

* Return an error back.

---------

Co-authored-by: Matt Holloway <mattdholloway@github.com>
2026-01-02 14:19:06 +00:00
Adam Holt b79d1264d5 Add raw client error annotation and annotate GetFileContents (#1570)
* Add raw client error annotation and annotate GetFileContents

* Track response.

* add raw errors to context

* add raw api error test

* Update pkg/errors/error.go

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Add blank line after Error() method for readability

* add NewGitHubRawAPIErrorResponse back

---------

Co-authored-by: Matt Holloway <mattdholloway@pm.me>
Co-authored-by: Matt Holloway <mattdholloway@github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-12-19 14:23:06 +00:00
Sam Morrow bc5d08da5c fix: track HTTP status code errors in context for observability (#1630)
Add NewGitHubAPIStatusErrorResponse helper function to properly track
GitHub API errors when the API call succeeds but returns an unexpected
HTTP status code (e.g., 404, 422, 500).

Previously, these errors were returned via utils.NewToolResultError which
bypasses the context-based error tracking used by the remote server's
error_categorizer.go for observability metrics. This resulted in 100%
tool call success rates in observability even when errors occurred.

The fix adds a new helper function that:
1. Creates a synthetic error from the status code and response body
2. Records the error in context via NewGitHubAPIErrorResponse
3. Returns the MCP error result to the client

Updated all tool files to use the new pattern for status code errors:
- pullrequests.go: 12 fixes
- repositories.go: 18 fixes
- issues.go: 10 fixes
- notifications.go: 6 fixes
- projects.go: 5 fixes
- search.go: 3 fixes
- search_utils.go: 1 fix
- gists.go: 4 fixes
- code_scanning.go: 2 fixes
- dependabot.go: 2 fixes
- secret_scanning.go: 2 fixes
- security_advisories.go: 4 fixes

Total: ~69 error paths now properly tracked.

Note: Parameter validation errors (RequiredParam failures) and internal
I/O errors (io.ReadAll failures) intentionally continue to use
utils.NewToolResultError as they are not GitHub API errors.
2025-12-17 17:03:03 +01:00
Adam Holt 60aef5d2e3 Convert to modelcontextprotocol/go-sdk (#1428)
Move from `mark3labs/mcp-go` to `modelcontextprotocol/go-sdk`.

This is mostly focused on updating tool schema and tool handler signatures, along with any associated internal changes related to those changes.

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Co-authored-by: omgitsads <4619+omgitsads@users.noreply.github.com>
Co-authored-by: LuluBeatson <lulubeatson@github.com>
Co-authored-by: Lulu <59149422+LuluBeatson@users.noreply.github.com>
Co-authored-by: SamMorrowDrums <4811358+SamMorrowDrums@users.noreply.github.com>
Co-authored-by: Sam Morrow <info@sam-morrow.com>
2025-12-01 14:30:59 +01:00
Jonathan c73f06fa29 bumps google/go-github to v79 2025-11-15 22:07:38 +01:00
Jonathan cf0e05e300 Update to google/go-github@v77 (#1357)
* update to google/go-github@v77

* licences update from required CI build

* fixes licences

* fixes possible nil reference

* refresh licences due to recent conflicts

---------

Co-authored-by: Roberto Nacu <kerobbi@github.com>
2025-11-07 08:06:27 -08:00
Jonathan 6f5040734a Updates github-mcp-server to go-github/v76 (#1289)
* updates github-mcp-server to go-github/v76

* updates license files

* refactors ListProjects to make use of
google/go-github ProjectsService

* refactors GetProject to make use of google/go-github ProjectsService

* declaring commit without a pointer

* cleanup additional commit pointer

---------

Co-authored-by: Tommaso Moro <37270480+tommaso-moro@users.noreply.github.com>
2025-10-27 13:53:53 +01:00
Tommaso Moro 521d5e9258 Bump go-github to v74 (#826)
* update all imports to use v74

* go mod tidy

* update third party licenses

* rename

* autogen licenses
2025-08-06 22:11:50 +01:00
Martin Høst Normark be91795fd3 Bump go-github to v73.0.0 (#597)
* Bump go-github to v73.0.0

* Clean up go.mod and update licenses

* Updated remaining imports to use github package v73 instead of v72

---------

Co-authored-by: Tommaso Moro <37270480+tommaso-moro@users.noreply.github.com>
Co-authored-by: tommaso-moro <tommaso-moro@github.com>
2025-07-15 15:21:24 +01:00
JoannaaKL 5904a0365e Fix linting flow (#614)
* Add issues type filter

* Add e2e test

* Update e2e/e2e_test.go

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Add lint script and update golangci config

* Add lint script

* Install if not installed

* Pass lint config

* Use action and rename workflow

* Back to reparate config

* Migrate config to v2

* Update config

* Lint code

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-06-30 15:14:45 +02:00
Sam Morrow f90ff16f2e move to new approach and update testing 2025-06-25 08:12:38 +02:00
Adam Holt 36e6add0dd Return concrete error types for API errors 2025-06-25 08:12:38 +02:00