Skip to content

Conversation

@stephenotalora
Copy link
Contributor

@stephenotalora stephenotalora commented Nov 4, 2025

Towards https://github.com/github/memex/issues/20995
Depends on #1357

Overview

This PR updates the MCP server to utilize the latest google/go-github API for interacting with GitHub projects, more specifically the ability to perform CRUD operations introduced in google/go-github@V77.

Details

  • Most API integrations have been refactored to use the google/go-github library, replacing previous implementations.
  • The migration was applied across all relevant endpoints and toolsets to ensure consistent usage of the new API client.

Outstanding Work

The only toolsets that have not yet been migrated to use google/go-github are:

  • GetProjectItem and
  • UpdateProjectItem.

This is due to notable differences in parameter handling between the google/go-github library and GitHub's RESTful API. Specifically, the way parameters must be passed for these endpoints does not fully align with the current library's abstractions, making a straightforward migration infeasible.

I am actively working to resolve these discrepancies and plan to make further adjustments within google/go-github to support these use cases.

Update:

I have opened google/go-github#3809 to resolve issues with GetProjectItem and UpdateProjectItem that came up during integration. The PR is ready for review and currently waiting on maintainers’ input.

Next Steps

  • Complete functional parity for GetProjectItem and UpdateProjectItem by contributing necessary changes upstream.
  • Monitor for any new breaking changes as GitHub's API evolves.

@stephenotalora stephenotalora force-pushed the stephenotalora/update-mcp-api branch from e7f625a to a6d80e1 Compare November 4, 2025 21:22
@stephenotalora stephenotalora force-pushed the stephenotalora/mcp-projects-v77 branch 2 times, most recently from 0a402d8 to fc1471d Compare November 4, 2025 21:27
@stephenotalora stephenotalora force-pushed the stephenotalora/update-mcp-api branch from a6d80e1 to fcf7fd5 Compare November 4, 2025 21:30
@stephenotalora stephenotalora force-pushed the stephenotalora/mcp-projects-v77 branch from fc1471d to fce10ae Compare November 4, 2025 21:31
@stephenotalora stephenotalora force-pushed the stephenotalora/update-mcp-api branch from fcf7fd5 to 5a4a278 Compare November 4, 2025 21:32
@stephenotalora stephenotalora force-pushed the stephenotalora/update-mcp-api branch from 5a4a278 to 4d6a90a Compare November 4, 2025 22:09
@stephenotalora stephenotalora changed the title Stephenotalora/update mcp api Update mcp server with latest google/go-github API Nov 5, 2025
@stephenotalora stephenotalora force-pushed the stephenotalora/mcp-projects-v77 branch from 4c97a67 to b1183b4 Compare November 5, 2025 18:55
@stephenotalora stephenotalora force-pushed the stephenotalora/update-mcp-api branch from eac7899 to 3e3ab15 Compare November 5, 2025 19:13
@stephenotalora stephenotalora self-assigned this Nov 5, 2025
@stephenotalora stephenotalora marked this pull request as ready for review November 6, 2025 17:56
@stephenotalora stephenotalora requested a review from a team as a code owner November 6, 2025 17:56
Copilot AI review requested due to automatic review settings November 6, 2025 17:56
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request refactors GitHub Projects V2 API integration by migrating from manual HTTP request construction to using the go-github SDK's native client methods, and updates field ID handling to use int64 instead of strings.

  • Introduces RequiredBigInt and OptionalBigIntArrayParam helper functions to handle large integer field/item IDs
  • Migrates multiple project-related functions to use go-github SDK methods (ListProjectFields, GetProjectField, ListProjectItems, AddProjectItem, DeleteProjectItem)
  • Updates field ID representation from []string to []int64 with comma-separated URL encoding

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.

File Description
pkg/github/server.go Adds helper functions for handling large integers (RequiredBigInt, OptionalBigIntArrayParam) and conversion utilities for string-to-int64 conversion
pkg/github/projects.go Migrates project API calls to use go-github SDK methods, updates data structures to use int64 for IDs, and removes obsolete custom types now replaced by SDK types
pkg/github/projects_test.go Updates test assertions to check for comma-separated field parameters instead of array-style parameters

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@stephenotalora stephenotalora marked this pull request as draft November 6, 2025 18:48
}
projectItems := []projectV2Item{}
var resp *github.Response
var projectItems []*github.ProjectV2Item
Copy link
Contributor Author

@stephenotalora stephenotalora Nov 6, 2025

Choose a reason for hiding this comment

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

Standardized field parameters has changed from array notation (fields[]=123&fields[]=456) to comma-separated format (fields=123,456,789).

Why this change was needed:

  • The comma-separated format is handled natively by the github.com/google/go-querystring library using the ,comma tag option
  • Eliminates manual URL encoding complexity in our code
  • Better aligns with Go's standard query parameter handling patterns
  • Our tests in projects_test.go confirm the comma format works correctly: fieldParams == "123,456,789"

Technical details: The fieldSelectionOptions struct now uses url:"fields,omitempty,comma" which leverages go-querystring's built-in comma support rather than custom array parameter logic.

See ListProjectItemsOptions struct

// ListProjectItemsOptions specifies optional parameters when listing project items.
// Note: Pagination uses before/after cursor-style pagination similar to ListProjectsOptions.
// "Fields" can be used to restrict which field values are returned (by their numeric IDs).
type ListProjectItemsOptions struct {
	// Embed ListProjectsOptions to reuse pagination and query parameters.
	ListProjectsOptions
	// Fields restricts which field values are returned by numeric field IDs.
	Fields []int64 `url:"fields,omitempty,comma"`
}

I have also updated this internally to align the MCP server with the underlying google/go-github dependency since we're not quite ready to migrate GetProjectItem yet as per this PR's description.

fieldParams := q["fields"]
if len(fieldParams) == 3 && fieldParams[0] == "123" && fieldParams[1] == "456" && fieldParams[2] == "789" {
fieldParams := q.Get("fields")
if fieldParams == "123,456,789" {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

see this comment in relation to this change.

@stephenotalora stephenotalora marked this pull request as ready for review November 6, 2025 19:56
@stephenotalora stephenotalora force-pushed the stephenotalora/mcp-projects-v77 branch from b1183b4 to fab59eb Compare November 6, 2025 20:02
@stephenotalora stephenotalora force-pushed the stephenotalora/update-mcp-api branch from 0743dcb to fd09a4a Compare November 6, 2025 20:03
@jm809 jm809 mentioned this pull request Nov 6, 2025
Base automatically changed from stephenotalora/mcp-projects-v77 to main November 7, 2025 16:06
@stephenotalora stephenotalora force-pushed the stephenotalora/update-mcp-api branch from fd09a4a to 7cb55a6 Compare November 7, 2025 17:01
Copy link
Contributor

@kerobbi kerobbi left a comment

Choose a reason for hiding this comment

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

Lgtm!

@kerobbi kerobbi merged commit b68bec0 into main Nov 7, 2025
16 checks passed
@kerobbi kerobbi deleted the stephenotalora/update-mcp-api branch November 7, 2025 17:31
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.

3 participants