-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcheck-config.sh
More file actions
executable file
·130 lines (113 loc) · 4.12 KB
/
check-config.sh
File metadata and controls
executable file
·130 lines (113 loc) · 4.12 KB
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#!/bin/bash
# Check MCP ACP Configuration
echo "=== MCP ACP Configuration Check ==="
echo ""
# Check clusters.yaml
echo "1. Checking clusters.yaml configuration:"
CONFIG_FILE="$HOME/.config/acp/clusters.yaml"
if [ -f "$CONFIG_FILE" ]; then
echo " ✓ Config file exists: $CONFIG_FILE"
echo ""
# Check file permissions
PERMS=$(stat -f "%Lp" "$CONFIG_FILE" 2>/dev/null || stat -c "%a" "$CONFIG_FILE" 2>/dev/null)
if [ "$PERMS" = "600" ]; then
echo " ✓ File permissions: $PERMS (secure)"
else
echo " ⚠ File permissions: $PERMS (should be 600 — file contains tokens)"
echo " Fix: chmod 600 $CONFIG_FILE"
fi
echo ""
# Parse and show key values
echo " Parsed configuration:"
if command -v python3 &> /dev/null; then
python3 << 'PYEOF'
import yaml
from pathlib import Path
config_path = Path.home() / ".config" / "acp" / "clusters.yaml"
with open(config_path) as f:
config = yaml.safe_load(f)
default_cluster = config.get("default_cluster")
print(f" - default_cluster: {default_cluster}")
clusters = config.get("clusters", {})
print(f" - clusters configured: {len(clusters)}")
if default_cluster:
cluster_config = clusters.get(default_cluster, {})
server = cluster_config.get("server", "not set")
project = cluster_config.get("default_project", "not set")
has_token = "yes" if cluster_config.get("token") else "no"
description = cluster_config.get("description", "")
print(f" - server: {server}")
print(f" - default_project: {project}")
print(f" - token configured: {has_token}")
if description:
print(f" - description: {description}")
# Check for port 6443 (direct K8s API)
if ":6443" in server:
print()
print(" ⚠ WARNING: Server URL uses port 6443 (direct K8s API)")
print(" Use the public-api gateway URL instead:")
print(" e.g., https://public-api-ambient.apps.cluster.example.com")
else:
print(" ⚠ No default_cluster set!")
PYEOF
fi
else
echo " ✗ Config file not found: $CONFIG_FILE"
echo " Create it with: mkdir -p ~/.config/acp && cp clusters.yaml.example ~/.config/acp/clusters.yaml"
fi
echo ""
# Check ACP_TOKEN environment variable
echo "2. Checking ACP_TOKEN environment variable:"
if [ -n "$ACP_TOKEN" ]; then
echo " ✓ ACP_TOKEN is set (${#ACP_TOKEN} characters)"
else
echo " - ACP_TOKEN is not set (will use token from clusters.yaml)"
fi
echo ""
# Test MCP server config loading
echo "3. Test MCP server config loading:"
if command -v python3 &> /dev/null; then
python3 << 'PYEOF'
import sys
try:
from mcp_acp.settings import load_settings, load_clusters_config
settings = load_settings()
config = load_clusters_config(settings)
print(f" ✓ Config loaded successfully")
print(f" Clusters: {list(config.clusters.keys())}")
print(f" Default cluster: {config.default_cluster}")
if config.default_cluster:
cluster = config.clusters.get(config.default_cluster)
if cluster:
has_token = bool(cluster.token)
print(f" Token configured: {'yes' if has_token else 'no'}")
print(f" Server: {cluster.server}")
print(f" Default project: {cluster.default_project}")
except ImportError as e:
print(f" ✗ Cannot import mcp_acp: {e}")
print(f" Install with: uv pip install -e '.[dev]'")
except FileNotFoundError as e:
print(f" ✗ Config file not found: {e}")
except Exception as e:
print(f" ✗ Error: {e}")
PYEOF
else
echo " ✗ python3 not found"
fi
echo ""
echo "=== Summary ==="
echo "If you see issues above, check:"
echo "1. clusters.yaml has correct server (gateway URL), token, and default_project"
echo "2. File permissions are 600 (chmod 600 ~/.config/acp/clusters.yaml)"
echo "3. Bearer token is valid and not expired"
echo ""
echo "Example clusters.yaml:"
echo "---"
echo "clusters:"
echo " my-cluster:"
echo " server: https://public-api-ambient.apps.cluster.example.com"
echo " token: your-bearer-token-here"
echo " default_project: my-workspace"
echo ""
echo "default_cluster: my-cluster"
echo "---"