feat: mcp server

This commit is contained in:
Jacky 2025-04-29 17:15:42 +08:00
parent c4a9d03bb3
commit e8ee931e16
No known key found for this signature in database
GPG key ID: 215C21B10DF38B4D
51 changed files with 2749 additions and 1526 deletions

24
mcp/nginx/restart.go Normal file
View file

@ -0,0 +1,24 @@
package nginx
import (
"context"
"github.com/0xJacky/Nginx-UI/internal/nginx"
"github.com/mark3labs/mcp-go/mcp"
)
const nginxRestartToolName = "restart_nginx"
var nginxRestartTool = mcp.NewTool(
nginxRestartToolName,
mcp.WithDescription("Perform a graceful restart of the Nginx configuration"),
)
func handleNginxRestart(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
nginx.Restart()
output, err := nginx.GetLastOutput()
if err != nil {
return mcp.NewToolResultError(output + "\n" + err.Error()), err
}
return mcp.NewToolResultText(output), nil
}