config_base_path.go 649 B

123456789101112131415161718192021222324252627
  1. package config
  2. import (
  3. "context"
  4. "encoding/json"
  5. "github.com/0xJacky/Nginx-UI/internal/nginx"
  6. "github.com/mark3labs/mcp-go/mcp"
  7. )
  8. const nginxConfigBasePathToolName = "nginx_config_base_path"
  9. var nginxConfigBasePathTool = mcp.NewTool(
  10. nginxConfigBasePathToolName,
  11. mcp.WithDescription("Get the base path of Nginx configurations"),
  12. )
  13. func handleNginxConfigBasePath(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
  14. basePath := nginx.GetConfPath()
  15. result := map[string]interface{}{
  16. "base_path": basePath,
  17. }
  18. jsonResult, _ := json.Marshal(result)
  19. return mcp.NewToolResultText(string(jsonResult)), nil
  20. }