Skip to content

Commit 106d802

Browse files
committed
refactor: rename contextWindowSize to contentWindowSize for consistency
1 parent fb301c6 commit 106d802

File tree

4 files changed

+18
-18
lines changed

4 files changed

+18
-18
lines changed

cmd/github-mcp-server/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ var (
5555
ExportTranslations: viper.GetBool("export-translations"),
5656
EnableCommandLogging: viper.GetBool("enable-command-logging"),
5757
LogFilePath: viper.GetString("log-file"),
58-
ContextWindowSize: viper.GetInt("content_window_size"),
58+
ContentWindowSize: viper.GetInt("content_window_size"),
5959
}
6060
return ghmcp.RunStdioServer(stdioServerConfig)
6161
},

internal/ghmcp/server.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ type MCPServerConfig struct {
4848
// Translator provides translated text for the server tooling
4949
Translator translations.TranslationHelperFunc
5050

51-
// Context window size
52-
ContextWindowSize int
51+
// Content window size
52+
ContentWindowSize int
5353
}
5454

5555
const stdioServerLogPrefix = "stdioserver"
@@ -135,7 +135,7 @@ func NewMCPServer(cfg MCPServerConfig) (*server.MCPServer, error) {
135135
}
136136

137137
// Create default toolsets
138-
tsg := github.DefaultToolsetGroup(cfg.ReadOnly, getClient, getGQLClient, getRawClient, cfg.Translator, cfg.ContextWindowSize)
138+
tsg := github.DefaultToolsetGroup(cfg.ReadOnly, getClient, getGQLClient, getRawClient, cfg.Translator, cfg.ContentWindowSize)
139139
err = tsg.EnableToolsets(enabledToolsets)
140140

141141
if err != nil {
@@ -184,8 +184,8 @@ type StdioServerConfig struct {
184184
// Path to the log file if not stderr
185185
LogFilePath string
186186

187-
// Context window size
188-
ContextWindowSize int
187+
// Content window size
188+
ContentWindowSize int
189189
}
190190

191191
// RunStdioServer is not concurrent safe.
@@ -204,7 +204,7 @@ func RunStdioServer(cfg StdioServerConfig) error {
204204
DynamicToolsets: cfg.DynamicToolsets,
205205
ReadOnly: cfg.ReadOnly,
206206
Translator: t,
207-
ContextWindowSize: cfg.ContextWindowSize,
207+
ContentWindowSize: cfg.ContentWindowSize,
208208
})
209209
if err != nil {
210210
return fmt.Errorf("failed to create MCP server: %w", err)

pkg/github/actions.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@ func ListWorkflowJobs(getClient GetClientFn, t translations.TranslationHelperFun
531531
}
532532

533533
// GetJobLogs creates a tool to download logs for a specific workflow job or efficiently get all failed job logs for a workflow run
534-
func GetJobLogs(getClient GetClientFn, t translations.TranslationHelperFunc, contextWindowSize int) (tool mcp.Tool, handler server.ToolHandlerFunc) {
534+
func GetJobLogs(getClient GetClientFn, t translations.TranslationHelperFunc, contentWindowSize int) (tool mcp.Tool, handler server.ToolHandlerFunc) {
535535
return mcp.NewTool("get_job_logs",
536536
mcp.WithDescription(t("TOOL_GET_JOB_LOGS_DESCRIPTION", "Download logs for a specific workflow job or efficiently get all failed job logs for a workflow run")),
537537
mcp.WithToolAnnotation(mcp.ToolAnnotation{
@@ -614,18 +614,18 @@ func GetJobLogs(getClient GetClientFn, t translations.TranslationHelperFunc, con
614614

615615
if failedOnly && runID > 0 {
616616
// Handle failed-only mode: get logs for all failed jobs in the workflow run
617-
return handleFailedJobLogs(ctx, client, owner, repo, int64(runID), returnContent, tailLines, contextWindowSize)
617+
return handleFailedJobLogs(ctx, client, owner, repo, int64(runID), returnContent, tailLines, contentWindowSize)
618618
} else if jobID > 0 {
619619
// Handle single job mode
620-
return handleSingleJobLogs(ctx, client, owner, repo, int64(jobID), returnContent, tailLines, contextWindowSize)
620+
return handleSingleJobLogs(ctx, client, owner, repo, int64(jobID), returnContent, tailLines, contentWindowSize)
621621
}
622622

623623
return mcp.NewToolResultError("Either job_id must be provided for single job logs, or run_id with failed_only=true for failed job logs"), nil
624624
}
625625
}
626626

627627
// handleFailedJobLogs gets logs for all failed jobs in a workflow run
628-
func handleFailedJobLogs(ctx context.Context, client *github.Client, owner, repo string, runID int64, returnContent bool, tailLines int, contextWindowSize int) (*mcp.CallToolResult, error) {
628+
func handleFailedJobLogs(ctx context.Context, client *github.Client, owner, repo string, runID int64, returnContent bool, tailLines int, contentWindowSize int) (*mcp.CallToolResult, error) {
629629
// First, get all jobs for the workflow run
630630
jobs, resp, err := client.Actions.ListWorkflowJobs(ctx, owner, repo, runID, &github.ListWorkflowJobsOptions{
631631
Filter: "latest",
@@ -657,7 +657,7 @@ func handleFailedJobLogs(ctx context.Context, client *github.Client, owner, repo
657657
// Collect logs for all failed jobs
658658
var logResults []map[string]any
659659
for _, job := range failedJobs {
660-
jobResult, resp, err := getJobLogData(ctx, client, owner, repo, job.GetID(), job.GetName(), returnContent, tailLines, contextWindowSize)
660+
jobResult, resp, err := getJobLogData(ctx, client, owner, repo, job.GetID(), job.GetName(), returnContent, tailLines, contentWindowSize)
661661
if err != nil {
662662
// Continue with other jobs even if one fails
663663
jobResult = map[string]any{
@@ -690,8 +690,8 @@ func handleFailedJobLogs(ctx context.Context, client *github.Client, owner, repo
690690
}
691691

692692
// handleSingleJobLogs gets logs for a single job
693-
func handleSingleJobLogs(ctx context.Context, client *github.Client, owner, repo string, jobID int64, returnContent bool, tailLines int, contextWindowSize int) (*mcp.CallToolResult, error) {
694-
jobResult, resp, err := getJobLogData(ctx, client, owner, repo, jobID, "", returnContent, tailLines, contextWindowSize)
693+
func handleSingleJobLogs(ctx context.Context, client *github.Client, owner, repo string, jobID int64, returnContent bool, tailLines int, contentWindowSize int) (*mcp.CallToolResult, error) {
694+
jobResult, resp, err := getJobLogData(ctx, client, owner, repo, jobID, "", returnContent, tailLines, contentWindowSize)
695695
if err != nil {
696696
return ghErrors.NewGitHubAPIErrorResponse(ctx, "failed to get job logs", resp, err), nil
697697
}
@@ -705,7 +705,7 @@ func handleSingleJobLogs(ctx context.Context, client *github.Client, owner, repo
705705
}
706706

707707
// getJobLogData retrieves log data for a single job, either as URL or content
708-
func getJobLogData(ctx context.Context, client *github.Client, owner, repo string, jobID int64, jobName string, returnContent bool, tailLines int, contextWindowSize int) (map[string]any, *github.Response, error) {
708+
func getJobLogData(ctx context.Context, client *github.Client, owner, repo string, jobID int64, jobName string, returnContent bool, tailLines int, contentWindowSize int) (map[string]any, *github.Response, error) {
709709
// Get the download URL for the job logs
710710
url, resp, err := client.Actions.GetWorkflowJobLogs(ctx, owner, repo, jobID, 1)
711711
if err != nil {
@@ -722,7 +722,7 @@ func getJobLogData(ctx context.Context, client *github.Client, owner, repo strin
722722

723723
if returnContent {
724724
// Download and return the actual log content
725-
content, originalLength, httpResp, err := downloadLogContent(ctx, url.String(), tailLines, contextWindowSize) //nolint:bodyclose // Response body is closed in downloadLogContent, but we need to return httpResp
725+
content, originalLength, httpResp, err := downloadLogContent(ctx, url.String(), tailLines, contentWindowSize) //nolint:bodyclose // Response body is closed in downloadLogContent, but we need to return httpResp
726726
if err != nil {
727727
// To keep the return value consistent wrap the response as a GitHub Response
728728
ghRes := &github.Response{

pkg/github/tools.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ type GetGQLClientFn func(context.Context) (*githubv4.Client, error)
1616

1717
var DefaultTools = []string{"all"}
1818

19-
func DefaultToolsetGroup(readOnly bool, getClient GetClientFn, getGQLClient GetGQLClientFn, getRawClient raw.GetRawClientFn, t translations.TranslationHelperFunc, contextWindowSize int) *toolsets.ToolsetGroup {
19+
func DefaultToolsetGroup(readOnly bool, getClient GetClientFn, getGQLClient GetGQLClientFn, getRawClient raw.GetRawClientFn, t translations.TranslationHelperFunc, contentWindowSize int) *toolsets.ToolsetGroup {
2020
tsg := toolsets.NewToolsetGroup(readOnly)
2121

2222
// Define all available features with their default state (disabled)
@@ -146,7 +146,7 @@ func DefaultToolsetGroup(readOnly bool, getClient GetClientFn, getGQLClient GetG
146146
toolsets.NewServerTool(GetWorkflowRun(getClient, t)),
147147
toolsets.NewServerTool(GetWorkflowRunLogs(getClient, t)),
148148
toolsets.NewServerTool(ListWorkflowJobs(getClient, t)),
149-
toolsets.NewServerTool(GetJobLogs(getClient, t, contextWindowSize)),
149+
toolsets.NewServerTool(GetJobLogs(getClient, t, contentWindowSize)),
150150
toolsets.NewServerTool(ListWorkflowRunArtifacts(getClient, t)),
151151
toolsets.NewServerTool(DownloadWorkflowRunArtifact(getClient, t)),
152152
toolsets.NewServerTool(GetWorkflowRunUsage(getClient, t)),

0 commit comments

Comments
 (0)