Skip to content

Commit 0434b7e

Browse files
committed
use flag for maxJobLogLines
1 parent ec070ee commit 0434b7e

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

cmd/github-mcp-server/main.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ func init() {
7575
rootCmd.PersistentFlags().Bool("enable-command-logging", false, "When enabled, the server will log all command requests and responses to the log file")
7676
rootCmd.PersistentFlags().Bool("export-translations", false, "Save translations to a JSON file")
7777
rootCmd.PersistentFlags().String("gh-host", "", "Specify the GitHub hostname (for GitHub Enterprise etc.)")
78+
rootCmd.PersistentFlags().Int("content-window-size", 5000, "Specify the content window size")
7879

7980
// Bind flag to viper
8081
_ = viper.BindPFlag("toolsets", rootCmd.PersistentFlags().Lookup("toolsets"))
@@ -84,6 +85,7 @@ func init() {
8485
_ = viper.BindPFlag("enable-command-logging", rootCmd.PersistentFlags().Lookup("enable-command-logging"))
8586
_ = viper.BindPFlag("export-translations", rootCmd.PersistentFlags().Lookup("export-translations"))
8687
_ = viper.BindPFlag("host", rootCmd.PersistentFlags().Lookup("gh-host"))
88+
_ = viper.BindPFlag("content_window_size", rootCmd.PersistentFlags().Lookup("content-window-size"))
8789

8890
// Add subcommands
8991
rootCmd.AddCommand(stdioCmd)

pkg/github/actions.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import (
88
"strconv"
99
"strings"
1010

11+
"github.com/spf13/viper"
12+
1113
buffer "github.com/github/github-mcp-server/pkg/buffer"
1214
ghErrors "github.com/github/github-mcp-server/pkg/errors"
1315
"github.com/github/github-mcp-server/pkg/profiler"
@@ -20,7 +22,6 @@ import (
2022
const (
2123
DescriptionRepositoryOwner = "Repository owner"
2224
DescriptionRepositoryName = "Repository name"
23-
maxJobLogLines = 50000
2425
)
2526

2627
// ListWorkflows creates a tool to list workflows in a repository
@@ -748,6 +749,11 @@ func downloadLogContent(ctx context.Context, logURL string, tailLines int) (stri
748749
prof := profiler.New(nil, profiler.IsProfilingEnabled())
749750
finish := prof.Start(ctx, "log_buffer_processing")
750751

752+
maxJobLogLines := viper.GetInt("content_window_size")
753+
if maxJobLogLines <= 0 || maxJobLogLines > 10000 {
754+
maxJobLogLines = 10000
755+
}
756+
751757
httpResp, err := http.Get(logURL) //nolint:gosec
752758
if err != nil {
753759
return "", 0, httpResp, fmt.Errorf("failed to download logs: %w", err)

0 commit comments

Comments
 (0)