Initial commit: Caddy MCP Server

This commit is contained in:
2026-04-10 21:57:20 -07:00
commit 2a3107f9e2
21 changed files with 2194 additions and 0 deletions
+51
View File
@@ -0,0 +1,51 @@
package main
import "fmt"
func (s *MCPServer) handleToolCall(id interface{}, toolName string, args map[string]interface{}) {
switch toolName {
case "list_sites":
s.handleListSites(id)
case "get_site":
s.handleGetSite(id, args)
case "get_site_routes":
s.handleGetSiteRoutes(id, args)
case "add_site":
s.handleAddSite(id, args)
case "remove_site":
s.handleRemoveSite(id, args)
case "update_upstream":
s.handleUpdateUpstream(id, args)
case "add_path_route":
s.handleAddPathRoute(id, args)
case "remove_path_route":
s.handleRemovePathRoute(id, args)
case "add_basic_auth":
s.handleAddBasicAuth(id, args)
case "remove_basic_auth":
s.handleRemoveBasicAuth(id, args)
case "add_request_header":
s.handleAddRequestHeader(id, args)
case "add_response_header":
s.handleAddResponseHeader(id, args)
case "add_file_server":
s.handleAddFileServer(id, args)
case "update_file_root":
s.handleUpdateFileRoot(id, args)
case "add_wip_environment":
s.handleAddWipEnvironment(id, args)
case "export_config":
s.handleExportConfig(id)
case "adapt_caddyfile":
s.handleAdaptCaddyfile(id, args)
case "validate_config":
s.handleValidateConfig(id, args)
case "caddy_status":
s.handleCaddyStatus(id)
case "stop_caddy":
s.handleStopCaddy(id)
default:
s.sendError(id, -32601, fmt.Sprintf("Unknown tool: %s", toolName))
}
}