-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquick-start.sh
More file actions
233 lines (203 loc) · 6.28 KB
/
quick-start.sh
File metadata and controls
233 lines (203 loc) · 6.28 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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
#!/bin/bash
# CoorChat Quick Start Script
# Automates local installation and setup
set -e # Exit on error
echo "🚀 CoorChat Quick Start"
echo "======================="
echo ""
# Colors for output
GREEN='\033[0;32m'
BLUE='\033[0;34m'
YELLOW='\033[1;33m'
RED='\033[0;31m'
NC='\033[0m' # No Color
# Check prerequisites
echo "📋 Checking prerequisites..."
if ! command -v node &> /dev/null; then
echo -e "${RED}❌ Node.js not found. Please install Node.js 18+${NC}"
exit 1
fi
if ! command -v npm &> /dev/null; then
echo -e "${RED}❌ npm not found. Please install npm${NC}"
exit 1
fi
if ! command -v docker &> /dev/null; then
echo -e "${YELLOW}⚠️ Docker not found. You'll need to install Redis manually.${NC}"
DOCKER_AVAILABLE=false
else
DOCKER_AVAILABLE=true
fi
echo -e "${GREEN}✅ Prerequisites checked${NC}"
echo ""
# Navigate to MCP server
cd packages/mcp-server
# Install dependencies
echo "📦 Installing dependencies..."
npm install
echo -e "${GREEN}✅ Dependencies installed${NC}"
echo ""
# Build project
echo "🔨 Building project..."
npm run build
echo -e "${GREEN}✅ Project built${NC}"
echo ""
# Generate secure token
echo "🔑 Generating secure token..."
TOKEN=$(node -e "console.log('cct_' + require('crypto').randomBytes(32).toString('hex'))")
echo -e "${GREEN}✅ Token generated${NC}"
echo ""
echo -e "${BLUE}Your secure token: ${YELLOW}${TOKEN}${NC}"
echo -e "${YELLOW}⚠️ Save this token! You'll need it for all agents.${NC}"
echo ""
# Save token to .env file
cat > .env << EOF
# CoorChat Configuration
# Generated: $(date)
# Shared authentication token (use same token for all agents)
SHARED_TOKEN=${TOKEN}
# Channel configuration (redis, discord, or signalr)
CHANNEL_TYPE=redis
REDIS_HOST=localhost
REDIS_PORT=6379
# Agent configuration
AGENT_ID=agent-claude-1
AGENT_ROLE=developer
# Optional: GitHub integration
# GITHUB_TOKEN=ghp_your_token_here
# GITHUB_OWNER=your-org
# GITHUB_REPO=your-repo
# Logging
LOG_LEVEL=info
EOF
echo -e "${GREEN}✅ Configuration saved to .env${NC}"
echo ""
# Setup channel
echo "📡 Setting up communication channel..."
echo "Choose your channel type:"
echo " 1) Redis (Recommended - requires Docker)"
echo " 2) Discord (Easy - requires Discord bot)"
echo " 3) SignalR (Advanced - requires relay server)"
echo ""
read -p "Enter choice [1-3]: " channel_choice
case $channel_choice in
1)
if [ "$DOCKER_AVAILABLE" = true ]; then
echo "Starting Redis container..."
docker run -d --name coorchat-redis -p 6379:6379 redis:7-alpine 2>/dev/null || {
echo -e "${YELLOW}Redis container already exists, starting it...${NC}"
docker start coorchat-redis
}
echo -e "${GREEN}✅ Redis started on localhost:6379${NC}"
else
echo -e "${RED}❌ Docker not available. Please install Docker or choose another channel.${NC}"
exit 1
fi
;;
2)
echo ""
echo "Discord Setup Instructions:"
echo "1. Go to https://discord.com/developers/applications"
echo "2. Create a new application"
echo "3. Go to 'Bot' → 'Add Bot'"
echo "4. Copy the bot token"
echo "5. Enable 'Message Content Intent'"
echo "6. Invite bot to your server"
echo "7. Create a channel and copy its ID"
echo ""
read -p "Enter Discord bot token: " discord_token
read -p "Enter Discord channel ID: " channel_id
# Update .env
sed -i "s/CHANNEL_TYPE=redis/CHANNEL_TYPE=discord/" .env
echo "DISCORD_BOT_TOKEN=${discord_token}" >> .env
echo "DISCORD_CHANNEL_ID=${channel_id}" >> .env
echo -e "${GREEN}✅ Discord configured${NC}"
;;
3)
echo "Starting SignalR relay server..."
cd ../../packages/relay-server
docker build -t coorchat-relay . || {
echo -e "${RED}❌ Failed to build relay server${NC}"
exit 1
}
docker run -d --name coorchat-relay -p 5001:5001 \
-e "Authentication__SharedToken=${TOKEN}" \
coorchat-relay
cd ../../packages/mcp-server
# Update .env
sed -i "s/CHANNEL_TYPE=redis/CHANNEL_TYPE=signalr/" .env
echo "SIGNALR_HUB_URL=https://localhost:5001/agentHub" >> .env
echo -e "${GREEN}✅ SignalR relay server started${NC}"
;;
*)
echo -e "${RED}Invalid choice${NC}"
exit 1
;;
esac
echo ""
# Run tests
echo "🧪 Running tests..."
npm test -- --run || {
echo -e "${YELLOW}⚠️ Some tests failed, but installation is complete${NC}"
}
echo ""
# Generate Claude Desktop config
echo "📝 Generating Claude Desktop configuration..."
REPO_PATH=$(cd ../.. && pwd)
MCP_SERVER_PATH="${REPO_PATH}/packages/mcp-server/dist/index.js"
cat > claude_desktop_config.json << EOF
{
"mcpServers": {
"coorchat": {
"command": "node",
"args": [
"${MCP_SERVER_PATH}"
],
"env": {
"CHANNEL_TYPE": "redis",
"REDIS_HOST": "localhost",
"REDIS_PORT": "6379",
"SHARED_TOKEN": "${TOKEN}",
"AGENT_ID": "agent-claude-1",
"AGENT_ROLE": "developer",
"LOG_LEVEL": "info"
}
}
}
}
EOF
echo -e "${GREEN}✅ Claude Desktop config generated${NC}"
echo ""
# Installation complete
echo "🎉 Installation Complete!"
echo "======================="
echo ""
echo -e "${BLUE}Next Steps:${NC}"
echo ""
echo "1. Copy the Claude Desktop configuration:"
if [[ "$OSTYPE" == "msys" || "$OSTYPE" == "win32" ]]; then
CLAUDE_CONFIG_PATH="%APPDATA%\\Claude\\claude_desktop_config.json"
else
CLAUDE_CONFIG_PATH="~/.claude/claude_desktop_config.json"
fi
echo -e " ${YELLOW}${CLAUDE_CONFIG_PATH}${NC}"
echo ""
echo " Configuration file created at:"
echo -e " ${YELLOW}./claude_desktop_config.json${NC}"
echo ""
echo "2. Restart Claude Desktop"
echo ""
echo "3. Test the MCP server in Claude:"
echo " Ask: 'Can you check if coorchat is connected?'"
echo ""
echo -e "${BLUE}Useful Commands:${NC}"
echo ""
echo " Start agents manually:"
echo -e " ${YELLOW}npm run cli -- agent start --role developer${NC}"
echo ""
echo " Monitor coordination:"
echo -e " ${YELLOW}npm run cli -- monitor${NC}"
echo ""
echo " View logs:"
echo -e " ${YELLOW}npm run cli -- logs${NC}"
echo ""
echo -e "${GREEN}Happy coordinating! 🤖${NC}"