@@ -6,14 +6,11 @@ import (
66"fmt"
77"io"
88"net/http"
9- "net/url"
10- "reflect"
119"strings"
1210
1311ghErrors"github.com/github/github-mcp-server/pkg/errors"
1412"github.com/github/github-mcp-server/pkg/translations"
1513"github.com/google/go-github/v79/github"
16- "github.com/google/go-querystring/query"
1714"github.com/mark3labs/mcp-go/mcp"
1815"github.com/mark3labs/mcp-go/server"
1916)
@@ -542,8 +539,8 @@ func GetProjectItem(getClient GetClientFn, t translations.TranslationHelperFunc)
542539return mcp .NewToolResultError (err .Error ()),nil
543540}
544541
545- resp := & github.Response {}
546- projectItem := & github.ProjectV2Item {}
542+ var resp * github.Response
543+ var projectItem * github.ProjectV2Item
547544var opts * github.GetProjectItemOptions
548545
549546if len (fields )> 0 {
@@ -846,67 +843,13 @@ func DeleteProjectItem(getClient GetClientFn, t translations.TranslationHelperFu
846843}
847844}
848845
849- type fieldSelectionOptions struct {
850- // Specific list of field IDs to include in the response. If not provided, only the title field is included.
851- // The comma tag encodes the slice as comma-separated values: fields=102589,985201,169875
852- Fields []int64 `url:"fields,omitempty,comma"`
853- }
854-
855- type projectV2ItemFieldValue struct {
856- ID * int64 `json:"id,omitempty"`
857- Name string `json:"name,omitempty"`
858- DataType string `json:"data_type,omitempty"`
859- Value any `json:"value,omitempty"`
860- }
861-
862- type projectV2Item struct {
863- ArchivedAt * github.Timestamp `json:"archived_at,omitempty"`
864- Content * projectV2ItemContent `json:"content,omitempty"`
865- ContentType * string `json:"content_type,omitempty"`
866- CreatedAt * github.Timestamp `json:"created_at,omitempty"`
867- Creator * github.User `json:"creator,omitempty"`
868- Description * string `json:"description,omitempty"`
869- Fields []* projectV2ItemFieldValue `json:"fields,omitempty"`
870- ID * int64 `json:"id,omitempty"`
871- ItemURL * string `json:"item_url,omitempty"`
872- NodeID * string `json:"node_id,omitempty"`
873- ProjectURL * string `json:"project_url,omitempty"`
874- Title * string `json:"title,omitempty"`
875- UpdatedAt * github.Timestamp `json:"updated_at,omitempty"`
876- }
877-
878- type projectV2ItemContent struct {
879- Body * string `json:"body,omitempty"`
880- ClosedAt * github.Timestamp `json:"closed_at,omitempty"`
881- CreatedAt * github.Timestamp `json:"created_at,omitempty"`
882- ID * int64 `json:"id,omitempty"`
883- Number * int `json:"number,omitempty"`
884- State * string `json:"state,omitempty"`
885- StateReason * string `json:"stateReason,omitempty"`
886- Title * string `json:"title,omitempty"`
887- UpdatedAt * github.Timestamp `json:"updated_at,omitempty"`
888- URL * string `json:"url,omitempty"`
889- }
890-
891846type pageInfo struct {
892847HasNextPage bool `json:"hasNextPage"`
893848HasPreviousPage bool `json:"hasPreviousPage"`
894849NextCursor string `json:"nextCursor,omitempty"`
895850PrevCursor string `json:"prevCursor,omitempty"`
896851}
897852
898- type projectV2Field struct {
899- ID * int64 `json:"id,omitempty"`
900- NodeID * string `json:"node_id,omitempty"`
901- Name * string `json:"name,omitempty"`
902- DataType * string `json:"data_type,omitempty"`
903- ProjectURL * string `json:"project_url,omitempty"`
904- Options []any `json:"options,omitempty"`
905- Configuration any `json:"configuration,omitempty"`
906- CreatedAt * github.Timestamp `json:"created_at,omitempty"`
907- UpdatedAt * github.Timestamp `json:"updated_at,omitempty"`
908- }
909-
910853func toNewProjectType (projType string )string {
911854switch strings .ToLower (projType ) {
912855case "issue" :
@@ -990,35 +933,3 @@ func extractPaginationOptions(request mcp.CallToolRequest) (github.ListProjectsP
990933
991934return opts ,nil
992935}
993-
994- // addOptions adds the parameters in opts as URL query parameters to s. opts
995- // must be a struct whose fields may contain "url" tags.
996- func addOptions (s string ,opts any ) (string ,error ) {
997- v := reflect .ValueOf (opts )
998- if v .Kind ()== reflect .Ptr && v .IsNil () {
999- return s ,nil
1000- }
1001-
1002- origURL ,err := url .Parse (s )
1003- if err != nil {
1004- return s ,err
1005- }
1006-
1007- origValues := origURL .Query ()
1008-
1009- // Use the github.com/google/go-querystring library to parse the struct
1010- newValues ,err := query .Values (opts )
1011- if err != nil {
1012- return s ,err
1013- }
1014-
1015- // Merge the values
1016- for key ,values := range newValues {
1017- for _ ,value := range values {
1018- origValues .Add (key ,value )
1019- }
1020- }
1021-
1022- origURL .RawQuery = origValues .Encode ()
1023- return origURL .String (),nil
1024- }