Skip to content

use WithPagination tool option #632

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -478,15 +478,15 @@ export GITHUB_MCP_TOOL_ADD_ISSUE_COMMENT_DESCRIPTION="an alternative description
- **list_workflow_jobs** - List workflow jobs
- `filter`: Filters jobs by their completed_at timestamp (string, optional)
- `owner`: Repository owner (string, required)
- `page`: The page number of the results to fetch (number, optional)
- `per_page`: The number of results per page (max 100) (number, optional)
- `page`: Page number for pagination (min 1) (number, optional)
- `perPage`: Results per page for pagination (min 1, max 100) (number, optional)
- `repo`: Repository name (string, required)
- `run_id`: The unique identifier of the workflow run (number, required)

- **list_workflow_run_artifacts** - List workflow artifacts
- `owner`: Repository owner (string, required)
- `page`: The page number of the results to fetch (number, optional)
- `per_page`: The number of results per page (max 100) (number, optional)
- `page`: Page number for pagination (min 1) (number, optional)
- `perPage`: Results per page for pagination (min 1, max 100) (number, optional)
- `repo`: Repository name (string, required)
- `run_id`: The unique identifier of the workflow run (number, required)

Expand All @@ -495,16 +495,16 @@ export GITHUB_MCP_TOOL_ADD_ISSUE_COMMENT_DESCRIPTION="an alternative description
- `branch`: Returns workflow runs associated with a branch. Use the name of the branch. (string, optional)
- `event`: Returns workflow runs for a specific event type (string, optional)
- `owner`: Repository owner (string, required)
- `page`: The page number of the results to fetch (number, optional)
- `per_page`: The number of results per page (max 100) (number, optional)
- `page`: Page number for pagination (min 1) (number, optional)
- `perPage`: Results per page for pagination (min 1, max 100) (number, optional)
- `repo`: Repository name (string, required)
- `status`: Returns workflow runs with the check run status (string, optional)
- `workflow_id`: The workflow ID or workflow file name (string, required)

- **list_workflows** - List workflows
- `owner`: Repository owner (string, required)
- `page`: The page number of the results to fetch (number, optional)
- `per_page`: The number of results per page (max 100) (number, optional)
- `page`: Page number for pagination (min 1) (number, optional)
- `perPage`: Results per page for pagination (min 1, max 100) (number, optional)
- `repo`: Repository name (string, required)

- **rerun_failed_jobs** - Rerun failed jobs
Expand Down Expand Up @@ -632,8 +632,8 @@ export GITHUB_MCP_TOOL_ADD_ISSUE_COMMENT_DESCRIPTION="an alternative description
- **get_issue_comments** - Get issue comments
- `issue_number`: Issue number (number, required)
- `owner`: Repository owner (string, required)
- `page`: Page number (number, optional)
- `per_page`: Number of records per page (number, optional)
- `page`: Page number for pagination (min 1) (number, optional)
- `perPage`: Results per page for pagination (min 1, max 100) (number, optional)
- `repo`: Repository name (string, required)

- **list_issues** - List issues
Expand Down
9 changes: 6 additions & 3 deletions pkg/github/__toolsnaps__/get_issue_comments.snap
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,14 @@
"type": "string"
},
"page": {
"description": "Page number",
"description": "Page number for pagination (min 1)",
"minimum": 1,
"type": "number"
},
"per_page": {
"description": "Number of records per page",
"perPage": {
"description": "Results per page for pagination (min 1, max 100)",
"maximum": 100,
"minimum": 1,
"type": "number"
},
"repo": {
Expand Down
68 changes: 16 additions & 52 deletions pkg/github/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,7 @@ func ListWorkflows(getClient GetClientFn, t translations.TranslationHelperFunc)
mcp.Required(),
mcp.Description(DescriptionRepositoryName),
),
mcp.WithNumber("per_page",
mcp.Description("The number of results per page (max 100)"),
),
mcp.WithNumber("page",
mcp.Description("The page number of the results to fetch"),
),
WithPagination(),
),
func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
owner, err := RequiredParam[string](request, "owner")
Expand All @@ -55,11 +50,7 @@ func ListWorkflows(getClient GetClientFn, t translations.TranslationHelperFunc)
}

// Get optional pagination parameters
perPage, err := OptionalIntParam(request, "per_page")
if err != nil {
return mcp.NewToolResultError(err.Error()), nil
}
page, err := OptionalIntParam(request, "page")
pagination, err := OptionalPaginationParams(request)
if err != nil {
return mcp.NewToolResultError(err.Error()), nil
}
Expand All @@ -71,8 +62,8 @@ func ListWorkflows(getClient GetClientFn, t translations.TranslationHelperFunc)

// Set up list options
opts := &github.ListOptions{
PerPage: perPage,
Page: page,
PerPage: pagination.perPage,
Page: pagination.page,
}

workflows, resp, err := client.Actions.ListWorkflows(ctx, owner, repo, opts)
Expand Down Expand Up @@ -157,12 +148,7 @@ func ListWorkflowRuns(getClient GetClientFn, t translations.TranslationHelperFun
mcp.Description("Returns workflow runs with the check run status"),
mcp.Enum("queued", "in_progress", "completed", "requested", "waiting"),
),
mcp.WithNumber("per_page",
mcp.Description("The number of results per page (max 100)"),
),
mcp.WithNumber("page",
mcp.Description("The page number of the results to fetch"),
),
WithPagination(),
),
func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
owner, err := RequiredParam[string](request, "owner")
Expand Down Expand Up @@ -197,11 +183,7 @@ func ListWorkflowRuns(getClient GetClientFn, t translations.TranslationHelperFun
}

// Get optional pagination parameters
perPage, err := OptionalIntParam(request, "per_page")
if err != nil {
return mcp.NewToolResultError(err.Error()), nil
}
page, err := OptionalIntParam(request, "page")
pagination, err := OptionalPaginationParams(request)
if err != nil {
return mcp.NewToolResultError(err.Error()), nil
}
Expand All @@ -218,8 +200,8 @@ func ListWorkflowRuns(getClient GetClientFn, t translations.TranslationHelperFun
Event: event,
Status: status,
ListOptions: github.ListOptions{
PerPage: perPage,
Page: page,
PerPage: pagination.perPage,
Page: pagination.page,
},
}

Expand Down Expand Up @@ -483,12 +465,7 @@ func ListWorkflowJobs(getClient GetClientFn, t translations.TranslationHelperFun
mcp.Description("Filters jobs by their completed_at timestamp"),
mcp.Enum("latest", "all"),
),
mcp.WithNumber("per_page",
mcp.Description("The number of results per page (max 100)"),
),
mcp.WithNumber("page",
mcp.Description("The page number of the results to fetch"),
),
WithPagination(),
),
func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
owner, err := RequiredParam[string](request, "owner")
Expand All @@ -512,11 +489,7 @@ func ListWorkflowJobs(getClient GetClientFn, t translations.TranslationHelperFun
}

// Get optional pagination parameters
perPage, err := OptionalIntParam(request, "per_page")
if err != nil {
return mcp.NewToolResultError(err.Error()), nil
}
page, err := OptionalIntParam(request, "page")
pagination, err := OptionalPaginationParams(request)
if err != nil {
return mcp.NewToolResultError(err.Error()), nil
}
Expand All @@ -530,8 +503,8 @@ func ListWorkflowJobs(getClient GetClientFn, t translations.TranslationHelperFun
opts := &github.ListWorkflowJobsOptions{
Filter: filter,
ListOptions: github.ListOptions{
PerPage: perPage,
Page: page,
PerPage: pagination.perPage,
Page: pagination.page,
},
}

Expand Down Expand Up @@ -1022,12 +995,7 @@ func ListWorkflowRunArtifacts(getClient GetClientFn, t translations.TranslationH
mcp.Required(),
mcp.Description("The unique identifier of the workflow run"),
),
mcp.WithNumber("per_page",
mcp.Description("The number of results per page (max 100)"),
),
mcp.WithNumber("page",
mcp.Description("The page number of the results to fetch"),
),
WithPagination(),
),
func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
owner, err := RequiredParam[string](request, "owner")
Expand All @@ -1045,11 +1013,7 @@ func ListWorkflowRunArtifacts(getClient GetClientFn, t translations.TranslationH
runID := int64(runIDInt)

// Get optional pagination parameters
perPage, err := OptionalIntParam(request, "per_page")
if err != nil {
return mcp.NewToolResultError(err.Error()), nil
}
page, err := OptionalIntParam(request, "page")
pagination, err := OptionalPaginationParams(request)
if err != nil {
return mcp.NewToolResultError(err.Error()), nil
}
Expand All @@ -1061,8 +1025,8 @@ func ListWorkflowRunArtifacts(getClient GetClientFn, t translations.TranslationH

// Set up list options
opts := &github.ListOptions{
PerPage: perPage,
Page: page,
PerPage: pagination.perPage,
Page: pagination.page,
}

artifacts, resp, err := client.Actions.ListWorkflowRunArtifacts(ctx, owner, repo, runID, opts)
Expand Down
4 changes: 2 additions & 2 deletions pkg/github/actions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func Test_ListWorkflows(t *testing.T) {
assert.NotEmpty(t, tool.Description)
assert.Contains(t, tool.InputSchema.Properties, "owner")
assert.Contains(t, tool.InputSchema.Properties, "repo")
assert.Contains(t, tool.InputSchema.Properties, "per_page")
assert.Contains(t, tool.InputSchema.Properties, "perPage")
assert.Contains(t, tool.InputSchema.Properties, "page")
assert.ElementsMatch(t, tool.InputSchema.Required, []string{"owner", "repo"})

Expand Down Expand Up @@ -393,7 +393,7 @@ func Test_ListWorkflowRunArtifacts(t *testing.T) {
assert.Contains(t, tool.InputSchema.Properties, "owner")
assert.Contains(t, tool.InputSchema.Properties, "repo")
assert.Contains(t, tool.InputSchema.Properties, "run_id")
assert.Contains(t, tool.InputSchema.Properties, "per_page")
assert.Contains(t, tool.InputSchema.Properties, "perPage")
assert.Contains(t, tool.InputSchema.Properties, "page")
assert.ElementsMatch(t, tool.InputSchema.Required, []string{"owner", "repo", "run_id"})

Expand Down
17 changes: 4 additions & 13 deletions pkg/github/issues.go
Original file line number Diff line number Diff line change
Expand Up @@ -608,12 +608,7 @@ func GetIssueComments(getClient GetClientFn, t translations.TranslationHelperFun
mcp.Required(),
mcp.Description("Issue number"),
),
mcp.WithNumber("page",
mcp.Description("Page number"),
),
mcp.WithNumber("per_page",
mcp.Description("Number of records per page"),
),
WithPagination(),
),
func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
owner, err := RequiredParam[string](request, "owner")
Expand All @@ -628,19 +623,15 @@ func GetIssueComments(getClient GetClientFn, t translations.TranslationHelperFun
if err != nil {
return mcp.NewToolResultError(err.Error()), nil
}
page, err := OptionalIntParamWithDefault(request, "page", 1)
if err != nil {
return mcp.NewToolResultError(err.Error()), nil
}
perPage, err := OptionalIntParamWithDefault(request, "per_page", 30)
pagination, err := OptionalPaginationParams(request)
if err != nil {
return mcp.NewToolResultError(err.Error()), nil
}

opts := &github.IssueListCommentsOptions{
ListOptions: github.ListOptions{
Page: page,
PerPage: perPage,
Page: pagination.page,
PerPage: pagination.perPage,
},
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/github/issues_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1087,7 +1087,7 @@ func Test_GetIssueComments(t *testing.T) {
assert.Contains(t, tool.InputSchema.Properties, "repo")
assert.Contains(t, tool.InputSchema.Properties, "issue_number")
assert.Contains(t, tool.InputSchema.Properties, "page")
assert.Contains(t, tool.InputSchema.Properties, "per_page")
assert.Contains(t, tool.InputSchema.Properties, "perPage")
assert.ElementsMatch(t, tool.InputSchema.Required, []string{"owner", "repo", "issue_number"})

// Setup mock comments for success case
Expand Down Expand Up @@ -1152,7 +1152,7 @@ func Test_GetIssueComments(t *testing.T) {
"repo": "repo",
"issue_number": float64(42),
"page": float64(2),
"per_page": float64(10),
"perPage": float64(10),
},
expectError: false,
expectedComments: mockComments,
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy