Skip to content

Add list_user_events for recent GitHub activity - #3491

Open
kaii9 wants to merge 5 commits into
github:mainfrom
kaii9:feat/list-user-events
Open

kaii9 wants to merge 5 commits into
github:mainfrom
kaii9:feat/list-user-events

Conversation

@kaii9

@kaii9 kaii9 commented Oct 13, 2026 •

Copy link
Copy Markdown

Summary

Add a read-only list_user_events tool in the users toolset so agents can retrieve a user's recent GitHub activity with pagination.

Why

Fixes #2420. Query GET /users/{username}/events as requested by the issue. GitHub returns public events for other users and may include private events when querying the authenticated user's own activity, subject to the token's permissions.

What changed

  • Register concrete Go input and output types with the v2 typed tool path; modern clients receive an output schema and structured results, while legacy clients retain JSON text.
  • Advertise and validate integer pagination; use page 1 and 30 events per page by default, with perPage limited to 1–100.
  • Return compact event metadata, the API's public visibility flag, and event-specific payloads. Retain unknown event types and exact payload numeric IDs.
  • Recursively clean payload strings with the existing sanitizer and apply plain-text sanitization to titles and names. Label all-public pages public/untrusted and pages with private or unknown-visibility events private/untrusted when IFC labels are enabled.
  • Add handler/protocol tests, input/output schema snapshots, and generated README documentation.

MCP impact

  • No tool or API changes
  • Tool schema or behavior changed
  • New tool added

list_user_events(username, page?, perPage?) joins the default users toolset. There is no publicOnly option; event visibility follows GitHub's endpoint and the current credentials.

Prompts tested (tool changes only)

Representative workflow: "Summarize kaii9's recent GitHub activity." Validation uses equivalent direct MCP requests rather than an LLM prompt run: activity queries, explicit pagination, missing/invalid arguments, legacy JSON, modern JSON, and modern CSV. Live event metadata is compared with an independent call to the same GitHub Events endpoint.

Security / limits

  • No security or limits impact
  • Auth / permissions considered
  • Data exposure, filtering, or token/size limits considered

The tool follows the existing repository public-read scope policy; GitHub remains responsible for access checks and fine-grained private Events permissions. Private events are retained when the API returns them, and result confidentiality is derived from returned event visibility. Missing visibility is conservatively private. Payload content remains untrusted. The tool description documents the feed's 300-event, 30-day history limit and possible latency; callers control page size.

Tool renaming

  • I am renaming tools as part of this PR
  • I am not renaming tools as part of this PR

Lint & tests

  • Linted locally with ./script/lint — 0 issues.
  • Tested locally with ./script/test (go test -race ./...); the full suite passed after switching to /events and adding visibility handling.

Also built the binary, regenerated docs, ran CI-mode feature/schema checks without test cache, and validated live read-only MCP calls. Private-event retention and mixed-page confidentiality are covered with simulated GitHub responses; the account's current live sample contained public events.

Docs

  • Not needed
  • Updated (README / docs / examples)

Generated README tool documentation and schema snapshots.

Skills

  • Updated relevant skills or confirmed no bundled skill applies

User activity history is outside the scope of the bundled account identity and team membership skill. The catalog coverage check records this exemption.

On November 18, 2026, this branch was synced with upstream main at 4e6e6c0. The full race test suite, lint, build, and skill catalog coverage check passed with Go 1.27.3. Live MCP checks against the Events API passed for legacy JSON, modern JSON, and modern CSV.

Review follow-up

Commit f6abc1b rejects dot-only usernames before obtaining a GitHub client and removes HTML from payload titles and names while preserving body formatting. In lockdown mode, the tool returns event metadata and visibility. It omits payloads because the feed may embed content from several authors and repositories and does not establish the origin of every field.

Regression tests cover all three changes. The full race test suite, lint, and build passed. A live comparison against GitHub returned the same two events with and without lockdown, with payloads present in normal mode and omitted under lockdown.

@kaii9
kaii9 requested a review from a team as a code owner October 13, 2026 16:14
Copilot AI adaptive review requested due to automatic review settings November 18, 2026 03:48

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Dot-segment usernames can redirect requests to global activity, and lockdown mode exposes embedded content without verifying authors’ repository access.

3 open issues
What changed in this PR

Adds list_user_events to the GitHub MCP Server’s users toolset, enabling paginated retrieval of recent user activity through GET /users/{username}/events and addressing #2420.

Changes:

  • Adds a read-only tool with typed schemas, structured results, and legacy JSON compatibility.
  • Preserves event payloads and exact numeric IDs, sanitizes payload strings, and derives confidentiality labels from event visibility.
  • Adds validation and protocol tests, schema snapshots, documentation, and a skill coverage exemption.
File Description
README.md Documents the new tool and its parameters.
pkg/​skills/​catalog/​availability_test.go Records the tool’s skill coverage exemption.
pkg/​github/​users.go Implements activity retrieval, pagination, payload handling, and visibility labels.
pkg/​github/​users_test.go Tests responses, validation, visibility labels, and protocol compatibility.
pkg/​github/​tools.go Registers the tool in the inventory.
pkg/​github/​__toolsnaps__/​list_user_events.snap Captures the tool’s input schema and metadata.
pkg/​github/​__toolsnaps__/​list_user_events_output.snap Captures the typed event output schema.

Review effort: Max (adaptive)

Comment thread pkg/github/users.go Outdated
Comment on lines +66 to +68
if input.Username == "" {
return utils.NewToolResultError("missing required parameter: username"), nil, nil
}
Comment thread pkg/github/users.go
if err := decoder.Decode(&payload); err != nil {
return utils.NewToolResultErrorFromErr("failed to decode event payload", err), nil, nil
}
payload = sanitizeUserEventPayload(payload)
Comment thread pkg/github/users.go
Comment on lines +137 to +141
case map[string]any:
for key, item := range value {
value[key] = sanitizeUserEventPayload(item)
}
return value
@kaii9

kaii9 commented Nov 18, 2026

Copy link
Copy Markdown
Author

I addressed the three Copilot findings in f6abc1b. The tool rejects dot-only usernames before making an API request and sanitizes event titles and names as plain text. In lockdown mode, it returns event metadata and omits payloads because those payloads may contain content from multiple authors and repositories.

The regression tests, full race test suite, lint, and live GitHub checks passed. Could a maintainer review the lockdown behavior and approve the workflow runs for this revision when you have a chance?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

List user's recent activities

3 participants