-
Notifications
You must be signed in to change notification settings - Fork 42
/
Copy pathinstall.sh
executable file
·112 lines (97 loc) · 2.98 KB
/
install.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/bin/bash
set -e
echo "Installing kubectl-mcp-tool..."
# Uninstall any previous versions first
pip uninstall -y kubectl-mcp-tool fastmcp mcp mcp-python || true
# Install the correct version of MCP SDK
pip install mcp>=1.5.0
# Create logs directory if it doesn't exist
mkdir -p logs
# Install kubectl-mcp-tool in development mode
pip install -e .
# Create directories for all supported AI assistants
mkdir -p ~/.cursor
mkdir -p ~/.cursor/logs
mkdir -p ~/.config/claude
mkdir -p ~/.config/windsurf
# Get absolute path to Python interpreter
PYTHON_PATH=$(which python)
echo "Using Python interpreter: $PYTHON_PATH"
# Get absolute path to kubectl config
KUBE_CONFIG="${KUBECONFIG:-$HOME/.kube/config}"
echo "Using Kubernetes config: $KUBE_CONFIG"
# Get absolute path to kubectl command
KUBECTL_PATH=$(which kubectl)
if [ -z "$KUBECTL_PATH" ]; then
echo "WARNING: kubectl not found in PATH. Please install kubectl."
KUBECTL_PATH="kubectl"
fi
echo "Using kubectl: $KUBECTL_PATH"
# Create a test configuration for Cursor MCP with absolute path and minimal wrapper
cat > ~/.cursor/mcp.json << EOF
{
"mcpServers": {
"kubernetes": {
"command": "$PYTHON_PATH",
"args": ["-m", "kubectl_mcp_tool.minimal_wrapper"],
"env": {
"KUBECONFIG": "$KUBE_CONFIG",
"PATH": "/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/homebrew/bin:$HOME/.pyenv/versions/3.10.0/bin"
}
}
}
}
EOF
# Create a test configuration for Claude with absolute path
cat > ~/.config/claude/mcp.json << EOF
{
"mcpServers": {
"kubernetes": {
"command": "$PYTHON_PATH",
"args": ["-m", "kubectl_mcp_tool.cli.cli", "serve"],
"env": {
"KUBECONFIG": "$KUBE_CONFIG"
}
}
}
}
EOF
# Create a test configuration for WindSurf with absolute path
cat > ~/.config/windsurf/mcp.json << EOF
{
"mcpServers": {
"kubernetes": {
"command": "$PYTHON_PATH",
"args": ["-m", "kubectl_mcp_tool.cli.cli", "serve"],
"env": {
"KUBECONFIG": "$KUBE_CONFIG"
}
}
}
}
EOF
# Test that kubectl is working
echo "Testing kubectl access..."
if $KUBECTL_PATH version --client > /dev/null 2>&1; then
echo "✅ kubectl is working correctly"
else
echo "⚠️ kubectl test failed. You may need to set up kubernetes access."
fi
# Check if kubeconfig exists
if [ -f "$KUBE_CONFIG" ]; then
echo "✅ Kubernetes config exists at $KUBE_CONFIG"
else
echo "⚠️ Kubernetes config not found at $KUBE_CONFIG. You may need to set up kubernetes access."
fi
echo "Installation complete. Verify with: kubectl-mcp --help"
echo ""
echo "To start the MCP server, run: kubectl-mcp serve"
echo ""
echo "MCP configurations have been added for:"
echo " - Cursor: ~/.cursor/mcp.json (with minimal wrapper)"
echo " - Claude: ~/.config/claude/mcp.json"
echo " - WindSurf: ~/.config/windsurf/mcp.json"
echo ""
echo "If Cursor fails to connect, check the output of: python -m kubectl_mcp_tool.minimal_wrapper"
echo ""
echo "If you encounter any issues, check the documentation in the docs/ folder"