# Arthas MCP Server Setup & Configuration Reference

## 1. Quick Start Commands

### Dynamic Attach (Default password: arthas123)
```bash
# 1. Download official Arthas boot jar (if not using offline package)
curl -O https://arthas.aliyun.com/arthas-boot.jar

# 2. Attach to target Java PID with MCP enabled (default password: arthas123)
java -jar arthas-boot.jar <PID> --target-ip 0.0.0.0 --http-port 8563 --password arthas123
```

### Custom Password
```bash
# Attach with custom security password
java -jar arthas-boot.jar <PID> --target-ip 0.0.0.0 --http-port 8563 --password MyCustomPassword
```

---

## 2. Health Check
```bash
# Health check with default password
curl --noproxy "*" -i -H "Authorization: Bearer arthas123" http://localhost:8563/mcp

# Or use offline package check script
./bin/check-mcp.sh 8563
```

---

## 3. Client Configuration

### Antigravity (`~/.gemini/config/mcp_config.json`)
```json
{
  "mcpServers": {
    "arthas": {
      "serverUrl": "http://localhost:8563/mcp",
      "headers": {
        "Authorization": "Bearer arthas123"
      }
    }
  }
}
```

### Claude Desktop / Cursor / Cherry Studio / Generic MCP Clients
```json
{
  "mcpServers": {
    "arthas-mcp": {
      "type": "streamableHttp",
      "url": "http://192.168.1.100:8563/mcp",
      "headers": {
        "Authorization": "Bearer arthas123"
      }
    }
  }
}
```
> *Note: If connecting locally, replace `192.168.1.100` with `localhost`.*

---

## 4. Stopping & Releasing Sessions

### Via Stop Script (Multi-Tier Graceful Stop)
```bash
# Default (frees port 8563 with default password arthas123)
./bin/stop-mcp.sh

# Or specify port / PID / custom password
./bin/stop-mcp.sh 8563
./bin/stop-mcp.sh <PID>
./bin/stop-mcp.sh 8563 <PID> MyCustomPassword
```

### Via Direct Arthas Client (Telnet Port 3658)
```bash
java -jar arthas-bin/arthas-client.jar 127.0.0.1 3658 -c "stop"
```

### Via HTTP API Command
```bash
curl --noproxy "*" -X POST http://127.0.0.1:8563/api \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer arthas123" \
  -d '{"action":"exec","command":"stop"}'
```
