Skip to content

Commit 25985df

Browse files
authored
Merge branch 'main' into fix/search-issues-duplicate-filters
2 parents 5b57b2e + 0e7a25e commit 25985df

File tree

19 files changed

+644
-120
lines changed

19 files changed

+644
-120
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Close inactive issues
2+
on:
3+
schedule:
4+
- cron: "30 8 * * *"
5+
6+
jobs:
7+
close-issues:
8+
runs-on: ubuntu-latest
9+
env:
10+
PR_DAYS_BEFORE_STALE: 60
11+
PR_DAYS_BEFORE_CLOSE: 10
12+
PR_STALE_LABEL: stale
13+
permissions:
14+
issues: write
15+
pull-requests: write
16+
steps:
17+
- uses: actions/stale@v9
18+
with:
19+
days-before-issue-stale: ${{ env.PR_DAYS_BEFORE_STALE }}
20+
days-before-issue-close: ${{ env.PR_DAYS_BEFORE_CLOSE }}
21+
stale-issue-label: ${{ env.PR_STALE_LABEL }}
22+
stale-issue-message: "This issue is stale because it has been open for ${{ env.PR_DAYS_BEFORE_STALE }} days with no activity. Leave a comment to avoid closing this issue in ${{ env.PR_DAYS_BEFORE_CLOSE }} days."
23+
close-issue-message: "This issue was closed because it has been inactive for ${{ env.PR_DAYS_BEFORE_CLOSE }} days since being marked as stale."
24+
days-before-pr-stale: -1
25+
days-before-pr-close: -1
26+
# Start with the oldest items first
27+
ascending: true
28+
repo-token: ${{ secrets.GITHUB_TOKEN }}

README.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,9 @@ The following sets of tools are available (all are on by default):
538538
- `perPage`: Results per page for pagination (min 1, max 100) (number, optional)
539539
- `repo`: Repository name (string, required)
540540

541+
- **list_issue_types** - List available issue types
542+
- `owner`: The organization owner of the repository (string, required)
543+
541544
- **list_issues** - List issues
542545
- `after`: Cursor for pagination. Use the endCursor from the previous page's PageInfo for GraphQL APIs. (string, optional)
543546
- `direction`: Order direction. If provided, the 'orderBy' also needs to be provided. (string, optional)
@@ -829,6 +832,10 @@ The following sets of tools are available (all are on by default):
829832
- `repo`: Repository name (string, required)
830833
- `sha`: Accepts optional commit SHA. If specified, it will be used instead of ref (string, optional)
831834

835+
- **get_latest_release** - Get latest release
836+
- `owner`: Repository owner (string, required)
837+
- `repo`: Repository name (string, required)
838+
832839
- **get_tag** - Get tag details
833840
- `owner`: Repository owner (string, required)
834841
- `repo`: Repository name (string, required)
@@ -848,6 +855,12 @@ The following sets of tools are available (all are on by default):
848855
- `repo`: Repository name (string, required)
849856
- `sha`: Commit SHA, branch or tag name to list commits of. If not provided, uses the default branch of the repository. If a commit SHA is provided, will list commits up to that SHA. (string, optional)
850857

858+
- **list_releases** - List releases
859+
- `owner`: Repository owner (string, required)
860+
- `page`: Page number for pagination (min 1) (number, optional)
861+
- `perPage`: Results per page for pagination (min 1, max 100) (number, optional)
862+
- `repo`: Repository name (string, required)
863+
851864
- **list_tags** - List tags
852865
- `owner`: Repository owner (string, required)
853866
- `page`: Page number for pagination (min 1) (number, optional)
@@ -1075,4 +1088,4 @@ The exported Go API of this module should currently be considered unstable, and
10751088

10761089
## License
10771090

1078-
This project is licensed under the terms of the MIT open source license. Please refer to [MIT](./LICENSE) for the full terms.
1091+
This project is licensed under the terms of the MIT open source license. Please refer to [MIT](./LICENSE) for the full terms.

go.mod

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ require (
77
github.com/josephburnett/jd v1.9.2
88
github.com/mark3labs/mcp-go v0.32.0
99
github.com/migueleliasweb/go-github-mock v1.3.0
10-
github.com/sirupsen/logrus v1.9.3
1110
github.com/spf13/cobra v1.9.1
1211
github.com/spf13/viper v1.20.1
1312
github.com/stretchr/testify v1.10.0

go.sum

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,6 @@ github.com/shurcooL/githubv4 v0.0.0-20240727222349-48295856cce7 h1:cYCy18SHPKRkv
6666
github.com/shurcooL/githubv4 v0.0.0-20240727222349-48295856cce7/go.mod h1:zqMwyHmnN/eDOZOdiTohqIUKUrTFX62PNlu7IJdu0q8=
6767
github.com/shurcooL/graphql v0.0.0-20230722043721-ed46e5a46466 h1:17JxqqJY66GmZVHkmAsGEkcIu0oCe3AM420QDgGwZx0=
6868
github.com/shurcooL/graphql v0.0.0-20230722043721-ed46e5a46466/go.mod h1:9dIRpgIY7hVhoqfe0/FcYp0bpInZaT7dc3BYOprrIUE=
69-
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
70-
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
7169
github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9ySo=
7270
github.com/sourcegraph/conc v0.3.0/go.mod h1:Sdozi7LEKbFPqYX2/J+iBAM6HpqSLTASQIKqDmF7Mt0=
7371
github.com/spf13/afero v1.14.0 h1:9tH6MapGnn/j0eb0yIXiLjERO8RB6xIVZRDCX7PtqWA=
@@ -83,7 +81,6 @@ github.com/spf13/viper v1.20.1/go.mod h1:P9Mdzt1zoHIG8m2eZQinpiBjo6kCmZSKBClNNqj
8381
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
8482
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
8583
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
86-
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
8784
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
8885
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
8986
github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8=
@@ -98,7 +95,6 @@ golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 h1:2dVuKD2vS7b0QIHQbpyTISPd0
9895
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56/go.mod h1:M4RDyNAINzryxdtnbRXRL/OHtkFuWGRjvuhBJpk2IlY=
9996
golang.org/x/oauth2 v0.29.0 h1:WdYw2tdTK1S8olAzWHdgeqfy+Mtm9XNhv/xJsY65d98=
10097
golang.org/x/oauth2 v0.29.0/go.mod h1:onh5ek6nERTohokkhCD/y2cV4Do3fxFHFuAejCkRWT8=
101-
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
10298
golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik=
10399
golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
104100
golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY=

internal/ghmcp/server.go

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"fmt"
66
"io"
77
"log"
8+
"log/slog"
89
"net/http"
910
"net/url"
1011
"os"
@@ -21,7 +22,6 @@ import (
2122
"github.com/mark3labs/mcp-go/mcp"
2223
"github.com/mark3labs/mcp-go/server"
2324
"github.com/shurcooL/githubv4"
24-
"github.com/sirupsen/logrus"
2525
)
2626

2727
type MCPServerConfig struct {
@@ -49,6 +49,8 @@ type MCPServerConfig struct {
4949
Translator translations.TranslationHelperFunc
5050
}
5151

52+
const stdioServerLogPrefix = "stdioserver"
53+
5254
func NewMCPServer(cfg MCPServerConfig) (*server.MCPServer, error) {
5355
apiHost, err := parseAPIHost(cfg.Host)
5456
if err != nil {
@@ -203,17 +205,22 @@ func RunStdioServer(cfg StdioServerConfig) error {
203205

204206
stdioServer := server.NewStdioServer(ghServer)
205207

206-
logrusLogger := logrus.New()
208+
var slogHandler slog.Handler
209+
var logOutput io.Writer
207210
if cfg.LogFilePath != "" {
208211
file, err := os.OpenFile(cfg.LogFilePath, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0600)
209212
if err != nil {
210213
return fmt.Errorf("failed to open log file: %w", err)
211214
}
212-
213-
logrusLogger.SetLevel(logrus.DebugLevel)
214-
logrusLogger.SetOutput(file)
215-
}
216-
stdLogger := log.New(logrusLogger.Writer(), "stdioserver", 0)
215+
logOutput = file
216+
slogHandler = slog.NewTextHandler(logOutput, &slog.HandlerOptions{Level: slog.LevelDebug})
217+
} else {
218+
logOutput = os.Stderr
219+
slogHandler = slog.NewTextHandler(logOutput, &slog.HandlerOptions{Level: slog.LevelInfo})
220+
}
221+
logger := slog.New(slogHandler)
222+
logger.Info("starting server", "version", cfg.Version, "host", cfg.Host, "dynamicToolsets", cfg.DynamicToolsets, "readOnly", cfg.ReadOnly)
223+
stdLogger := log.New(logOutput, stdioServerLogPrefix, 0)
217224
stdioServer.SetErrorLogger(stdLogger)
218225

219226
if cfg.ExportTranslations {
@@ -227,7 +234,7 @@ func RunStdioServer(cfg StdioServerConfig) error {
227234
in, out := io.Reader(os.Stdin), io.Writer(os.Stdout)
228235

229236
if cfg.EnableCommandLogging {
230-
loggedIO := mcplog.NewIOLogger(in, out, logrusLogger)
237+
loggedIO := mcplog.NewIOLogger(in, out, logger)
231238
in, out = loggedIO, loggedIO
232239
}
233240
// enable GitHub errors in the context
@@ -241,9 +248,10 @@ func RunStdioServer(cfg StdioServerConfig) error {
241248
// Wait for shutdown signal
242249
select {
243250
case <-ctx.Done():
244-
logrusLogger.Infof("shutting down server...")
251+
logger.Info("shutting down server", "signal", "context done")
245252
case err := <-errC:
246253
if err != nil {
254+
logger.Error("error running server", "error", err)
247255
return fmt.Errorf("error running server: %w", err)
248256
}
249257
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"annotations": {
3+
"title": "List available issue types",
4+
"readOnlyHint": true
5+
},
6+
"description": "List supported issue types for repository owner (organization).",
7+
"inputSchema": {
8+
"properties": {
9+
"owner": {
10+
"description": "The organization owner of the repository",
11+
"type": "string"
12+
}
13+
},
14+
"required": [
15+
"owner"
16+
],
17+
"type": "object"
18+
},
19+
"name": "list_issue_types"
20+
}

pkg/github/actions.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -955,7 +955,9 @@ func CancelWorkflowRun(getClient GetClientFn, t translations.TranslationHelperFu
955955

956956
resp, err := client.Actions.CancelWorkflowRunByID(ctx, owner, repo, runID)
957957
if err != nil {
958-
return ghErrors.NewGitHubAPIErrorResponse(ctx, "failed to cancel workflow run", resp, err), nil
958+
if _, ok := err.(*github.AcceptedError); !ok {
959+
return ghErrors.NewGitHubAPIErrorResponse(ctx, "failed to cancel workflow run", resp, err), nil
960+
}
959961
}
960962
defer func() { _ = resp.Body.Close() }()
961963

pkg/github/actions_test.go

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -323,12 +323,14 @@ func Test_CancelWorkflowRun(t *testing.T) {
323323
{
324324
name: "successful workflow run cancellation",
325325
mockedClient: mock.NewMockedHTTPClient(
326-
mock.WithRequestMatch(
326+
mock.WithRequestMatchHandler(
327327
mock.EndpointPattern{
328328
Pattern: "/repos/owner/repo/actions/runs/12345/cancel",
329329
Method: "POST",
330330
},
331-
"", // Empty response body for 202 Accepted
331+
http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
332+
w.WriteHeader(http.StatusAccepted)
333+
}),
332334
),
333335
),
334336
requestArgs: map[string]any{
@@ -338,6 +340,27 @@ func Test_CancelWorkflowRun(t *testing.T) {
338340
},
339341
expectError: false,
340342
},
343+
{
344+
name: "conflict when cancelling a workflow run",
345+
mockedClient: mock.NewMockedHTTPClient(
346+
mock.WithRequestMatchHandler(
347+
mock.EndpointPattern{
348+
Pattern: "/repos/owner/repo/actions/runs/12345/cancel",
349+
Method: "POST",
350+
},
351+
http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
352+
w.WriteHeader(http.StatusConflict)
353+
}),
354+
),
355+
),
356+
requestArgs: map[string]any{
357+
"owner": "owner",
358+
"repo": "repo",
359+
"run_id": float64(12345),
360+
},
361+
expectError: true,
362+
expectedErrMsg: "failed to cancel workflow run",
363+
},
341364
{
342365
name: "missing required parameter run_id",
343366
mockedClient: mock.NewMockedHTTPClient(),
@@ -369,7 +392,7 @@ func Test_CancelWorkflowRun(t *testing.T) {
369392
textContent := getTextResult(t, result)
370393

371394
if tc.expectedErrMsg != "" {
372-
assert.Equal(t, tc.expectedErrMsg, textContent.Text)
395+
assert.Contains(t, textContent.Text, tc.expectedErrMsg)
373396
return
374397
}
375398

0 commit comments

Comments
 (0)