You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This directory contains the Go implementation of all KAgent tools, migrated from the original Python implementation. The tools are designed to work with the Model Context Protocol (MCP) server and provide comprehensive Kubernetes, cloud-native, and observability functionality.
docker run -it --rm -p 8084:8084 ghcr.io/kagent-dev/kagent/tools:0.0.13
Kubernetes
helm upgrade -i -n kagent --create-namespace kagent-tools oci://ghcr.io/kagent-dev/tools/helm/kagent-tools --version 0.0.13
helm ls -A
Quickstart Guide
For a quickstart guide on how to run KAgent tools using AgentGateway, please refer to the Quickstart Guide.
Architecture
The Go tools are implemented as a single MCP server that exposes all available tools through the MCP protocol.
Each tool category is implemented in its own Go file for better organization and maintainability.
grafana_alert_management: Manage alerts and alert rules
grafana_datasource_management: Manage data sources
8. DateTime Tools (datetime.go)
Provides time and date utilities:
current_date_time: Get current date and time in ISO 8601 format
format_time: Format timestamps with optional timezone
parse_time: Parse time strings into RFC3339 format
9. Documentation Tools (docs.go)
Provides documentation query functionality:
query_documentation: Query documentation for supported products (simplified implementation)
list_supported_products: List supported products for documentation queries
10. Common Tools (common.go)
Provides general utility functions:
shell: Execute shell commands
Building and Running
Prerequisites
Go 1.21 or later
Access to Kubernetes cluster (for K8s tools)
Required CLI tools installed:
kubectl (for Kubernetes tools)
helm (for Helm tools)
istioctl (for Istio tools)
cilium (for Cilium tools)
Building
go build -o kagent-tools .
Running
./kagent-tools
The server runs using sse transport for MCP communication.
CLI Flags
Flag
Default
Description
--port, -p
8084
Port to run the MCP server on
--metrics-port
8084
Port to run the Prometheus metrics server on
--stdio
false
Use stdio for communication instead of HTTP
--tools
[] (all)
Comma-separated list of tool providers to register
--read-only
false
Disable tools that perform write operations
--kubeconfig
""
Path to kubeconfig file (defaults to in-cluster config)
--version, -v
false
Show version information and exit
Testing
go test -v ./...
Tool Implementation Details
Error Handling
All tools implement comprehensive error handling and return appropriate error messages through the MCP protocol. When CLI tools are not available or commands fail, the tools return descriptive error messages.
Authentication and Configuration
Tools respect existing authentication and configuration:
Kubernetes tools use the default kubeconfig or KUBECONFIG environment variable
Helm tools use Helm's default configuration
Prometheus tools accept custom Prometheus server URLs
Grafana tools support API key and basic authentication
Command Execution
The tools use a common runCommand function that:
Executes commands with proper error handling
Captures both stdout and stderr
Returns formatted output or error messages
Handles timeouts and cancellation
MCP Integration
All tools are properly integrated with the MCP protocol:
Use proper parameter parsing with mcp.ParseString, mcp.ParseBool, etc.
Return results using mcp.NewToolResultText or mcp.NewToolResultError
Include comprehensive tool descriptions and parameter documentation
Support required and optional parameters
Migration from Python
This Go implementation provides feature parity with the original Python tools while offering:
Better Performance: Native Go execution without Python interpreter overhead
Smaller Binary: Single compiled binary with all tools included
Better Resource Usage: Lower memory footprint and faster startup
Enhanced Error Handling: More robust error handling and reporting
Simplified Deployment: No Python dependencies or virtual environments required
Key Differences from Python Implementation
Uses native Go clients instead of Python requests/httpx
Implements simplified documentation query (full vector search would require additional Go libraries)
Uses Go's native JSON handling instead of Python's json module
Command execution uses Go's os/exec package instead of Python's subprocess
Configuration
Tools can be configured through environment variables:
KUBECONFIG: Kubernetes configuration file path
PROMETHEUS_URL: Default Prometheus server URL
GRAFANA_URL: Default Grafana server URL
GRAFANA_API_KEY: Default Grafana API key
Observability
The MCP server exposes Prometheus metrics on a configurable HTTP endpoint (/metrics). By default, the metrics endpoint runs on the same port as the MCP server. To run it on a separate port: