Skip to content

Commit c9a7208

Browse files
committed
feat: golangci-lint with JSON output
1 parent fb1725a commit c9a7208

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

cmd/mcp-golang/main.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,17 @@ func main() {
2929
),
3030
toolHandler.HandleLint,
3131
)
32+
s.AddTool(
33+
mcp.NewTool(
34+
"static-analysis-with-json-output",
35+
mcp.WithDescription("Tool to lint the project (runs static analysis on the codebase) leveraging golangci-lint, but with JSON output"),
36+
37+
mcp.WithString("directory",
38+
mcp.Description("The directory to run the static analysis in"),
39+
),
40+
),
41+
toolHandler.HandleLintWithJSONOutput,
42+
)
3243
s.AddTool(
3344
mcp.NewTool("test",
3445
mcp.WithDescription("Tool to run tests on the project"),

internal/app/mcp-golang/tools/tools.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,19 @@ func (t *Handler) HandleLint(_ context.Context, request mcp.CallToolRequest) (*m
3030
return t.executeTask(arguments)
3131
}
3232

33+
func (t *Handler) HandleLintWithJSONOutput(_ context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
34+
arguments := []string{
35+
"remote:golangci-lint-run-output-json",
36+
"-y",
37+
}
38+
39+
dir, ok := request.Params.Arguments["directory"].(string)
40+
if ok {
41+
arguments = append(arguments, "-d", dir)
42+
}
43+
return t.executeTask(arguments)
44+
}
45+
3346
func (t *Handler) HandleUnitTest(_ context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
3447
arguments := []string{
3548
"remote:test",

0 commit comments

Comments
 (0)