mirror of
https://github.com/0xJacky/nginx-ui.git
synced 2025-05-11 18:35:51 +02:00
feat: mcp server
This commit is contained in:
parent
c4a9d03bb3
commit
e8ee931e16
51 changed files with 2749 additions and 1526 deletions
24
mcp/nginx/restart.go
Normal file
24
mcp/nginx/restart.go
Normal 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
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue