-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.go
More file actions
38 lines (33 loc) · 1.39 KB
/
server.go
File metadata and controls
38 lines (33 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package mcp
import (
"log/slog"
"github.com/modelcontextprotocol/go-sdk/mcp"
"github.com/techprimate/github-actions-utils-cli/internal/github"
)
// MCPServer wraps the ActionsService and provides MCP tool handlers.
// It uses dependency injection to receive its dependencies.
type MCPServer struct {
actionsService *github.ActionsService
logger *slog.Logger
}
// NewMCPServer creates a new MCP server with the given dependencies.
func NewMCPServer(actionsService *github.ActionsService, logger *slog.Logger) *MCPServer {
if logger == nil {
logger = slog.Default()
}
return &MCPServer{
actionsService: actionsService,
logger: logger,
}
}
// RegisterTools registers all available tools with the MCP server.
func (m *MCPServer) RegisterTools(server *mcp.Server) {
mcp.AddTool(server, &mcp.Tool{
Name: "get_action_parameters",
Description: "Fetch and parse a GitHub Action's action.yml file. Returns the complete action.yml structure including inputs, outputs, runs configuration, and metadata.",
}, WithSentryTracing("get_action_parameters", m.handleGetActionParameters))
mcp.AddTool(server, &mcp.Tool{
Name: "get_readme",
Description: "Fetch the README.md file from a GitHub repository. Takes a repository reference (e.g., 'owner/repo@main' or 'owner/repo'). If no ref is provided, defaults to 'main' branch.",
}, WithSentryTracing("get_readme", m.handleGetReadme))
}