whatap-mxql-cli

devload/whatap-mxql-cli

3.2

If you are the rightful owner of whatap-mxql-cli and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.

WhaTap MXQL CLI is a command-line interface for querying WhaTap monitoring data using MXQL (Metrics Query Language).

Tools
2
Resources
0
Prompts
0

WhaTap MXQL CLI

WhaTap λͺ¨λ‹ˆν„°λ§ 데이터λ₯Ό MXQL(Metrics Query Language)둜 μ‘°νšŒν•˜λŠ” λͺ…령쀄 μΈν„°νŽ˜μ΄μŠ€μž…λ‹ˆλ‹€.

✨ κΈ°λŠ₯

  • πŸ” μ•ˆμ „ν•œ 인증: AES-256-GCM μ•”ν˜Έν™”λœ μ„Έμ…˜ μ €μž₯
  • πŸ“Š ν”„λ‘œμ νŠΈ 관리: μ ‘κ·Ό κ°€λŠ₯ν•œ λͺ¨λ“  ν”„λ‘œμ νŠΈ 쑰회 및 필터링
  • πŸ” MXQL 쿼리: κ°•λ ₯ν•œ MXQL 쿼리 μ‹€ν–‰ (λ³΅μž‘ν•œ νŒŒμ΄ν”„λΌμΈ 지원)
  • 🎨 λ‹€μ–‘ν•œ 좜λ ₯ ν˜•μ‹: Table, JSON, CSV
  • πŸ’¬ λŒ€ν™”ν˜• REPL: μΈν„°λž™ν‹°λΈŒν•œ 쿼리 μ‹€ν–‰ ν™˜κ²½
  • ⏰ μ‹œκ°„ λ²”μœ„ 지원: 프리셋 및 μ»€μŠ€ν…€ μ‹œκ°„ λ²”μœ„
  • πŸš€ MCP μ„œλ²„: Claude Code 톡합 μ™„λ£Œ! (Tools 제곡)
  • πŸ€– Skill 톡합: mxql-for-claude-code Skillκ³Ό ν•¨κ»˜ μ‚¬μš© (μžμ—°μ–΄ β†’ MXQL)

πŸš€ λΉ λ₯Έ μ‹œμž‘

μ„€μΉ˜

# μ €μž₯μ†Œ 클둠
git clone <repository-url>
cd whatap-mxql-cli

# μ˜μ‘΄μ„± μ„€μΉ˜
npm install

# λΉŒλ“œ
npm run build

# bin μ‹€ν–‰ κΆŒν•œ λΆ€μ—¬
chmod +x bin/whatap-mxql

κΈ°λ³Έ μ‚¬μš©λ²•

# 방법 1: λͺ…λ Ήμ–΄ λ°”λ‘œ μ‹€ν–‰ (μžλ™ 둜그인 μœ λ„)
./bin/whatap-mxql projects
# β†’ 둜그인 μ•ˆ λ˜μ–΄ 있으면 μžλ™μœΌλ‘œ 둜그인 ν”„λ‘¬ν”„νŠΈ ν‘œμ‹œ

# 방법 2: λͺ…μ‹œμ  둜그인 ν›„ μ‚¬μš©
./bin/whatap-mxql login
./bin/whatap-mxql projects

# 3. MXQL 쿼리 μ‹€ν–‰
./bin/whatap-mxql query 27506 "CATEGORY app_counter" -r 24h

# 4. λŒ€ν™”ν˜• λͺ¨λ“œ
./bin/whatap-mxql interactive

πŸ’‘ TIP: 둜그인 없이 μ–΄λ–€ λͺ…λ Ήμ–΄λ“  μ‹€ν–‰ν•˜λ©΄ μžλ™μœΌλ‘œ 둜그인 ν”„λ‘¬ν”„νŠΈκ°€ ν‘œμ‹œλ©λ‹ˆλ‹€!

πŸ“‹ λͺ…λ Ήμ–΄

λͺ…λ Ήμ–΄μ„€λͺ…
login [options]WhaTap μ„œλΉ„μŠ€ 둜그인
logoutλ‘œκ·Έμ•„μ›ƒ 및 μ„Έμ…˜ μ‚­μ œ
projects [options]ν”„λ‘œμ νŠΈ λͺ©λ‘ 쑰회
query <pcode> [mxql] [options]MXQL 쿼리 μ‹€ν–‰
interactive [options]λŒ€ν™”ν˜• REPL λͺ¨λ“œ

상세 μ‚¬μš©λ²•μ€ λ₯Ό μ°Έμ‘°ν•˜μ„Έμš”.

πŸ€– Claude Code 톡합 (MCP)

MCP μ„œλ²„ μ„€μ •

# λΉŒλ“œ (이미 μ™„λ£Œλœ 경우 skip)
npm run build

# MCP μ„€μ • 파일 생성
mkdir -p ~/.claude/mcp
cat > ~/.claude/mcp/whatap-mxql.json << 'EOF'
{
  "mcpServers": {
    "whatap-mxql": {
      "command": "node",
      "args": ["/μ ˆλŒ€/경둜/whatap-mxql-cli/dist/mcp/index.js"],
      "description": "WhaTap MXQL Query Executor"
    }
  }
}
EOF

⚠️ μ€‘μš”: /μ ˆλŒ€/경둜/λ₯Ό μ‹€μ œ ν”„λ‘œμ νŠΈ 경둜둜 λ³€κ²½ν•˜μ„Έμš”!

Skill μ„€μΉ˜ (mxql-for-claude-code)

# μ €μž₯μ†Œ 클둠
git clone https://github.com/kyupid/mxql-for-claude-code.git
cd mxql-for-claude-code

# μ„€μΉ˜
./install.sh

μ‚¬μš© μ˜ˆμ‹œ

μ‚¬μš©μž: "PostgreSQLμ—μ„œ CPU 80% 이상인 μΈμŠ€ν„΄μŠ€ μ°Ύμ•„μ€˜"

Claude Code:
  1. (Skill) PostgreSQL μΉ΄ν…Œκ³ λ¦¬ 및 MXQL νŒ¨ν„΄ ν•™μŠ΅
  2. (Skill) MXQL 생성: "CATEGORY db_postgresql_counter FILTER..."
  3. (MCP Tool) whatap.getProjects() - ν”„λ‘œμ νŠΈ λͺ©λ‘ 확인
  4. (MCP Tool) whatap.executeMxql(pcode, mxql) - 쿼리 μ‹€ν–‰
  5. κ²°κ³Ό 뢄석 및 응닡

상세 μ„€μΉ˜ κ°€μ΄λ“œ:

🎨 좜λ ₯ μ˜ˆμ‹œ

ν”„λ‘œμ νŠΈ λͺ©λ‘

βœ“ Found 12 project(s)

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Project Code β”‚ Project Name            β”‚ Type    β”‚ Status     β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ 27506        β”‚ Browser Monitoring Demo β”‚ BROWSER β”‚ subscribe  β”‚
β”‚ 44482        β”‚ mobile test project     β”‚ MOBILE  β”‚ subscribe  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

MXQL 쿼리 결과

[
  {
    "_id_": "27506_",
    "pname": "Browser Monitoring Demo",
    "pcode": 27506,
    "sessionCount": 108.04790419161677,
    "_rows_": 167
  }
]

πŸ”§ Development

Setup

npm install

Build

npm run build

Test

# Run all tests
npm test

# Run unit tests only
npm run test:unit

# Run integration tests (requires WhaTap account)
npm run test:integration

# Watch mode
npm run test:watch

# Coverage
npm run test:coverage

Lint & Format

npm run lint
npm run lint:fix
npm run format

πŸ§ͺ Testing

Unit Tests

Mock-based tests for all modules without external dependencies.

Integration Tests

Real API calls to WhaTap service (requires test account).

Configure test credentials in .env.test:

WHATAP_TEST_EMAIL=your-email@whatap.io
WHATAP_TEST_PASSWORD=your-password
WHATAP_SERVICE_URL=https://service.whatap.io
RUN_INTEGRATION_TESTS=true

πŸ“ ν”„λ‘œμ νŠΈ ꡬ쑰

whatap-mxql-cli/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ core/                 # 핡심 λͺ¨λ“ˆ (CLI & MCP 곡유)
β”‚   β”‚   β”œβ”€β”€ types/           # TypeScript νƒ€μž… μ •μ˜
β”‚   β”‚   β”œβ”€β”€ auth/            # 인증 λͺ¨λ“ˆ
β”‚   β”‚   β”‚   β”œβ”€β”€ SessionStore.ts      # μ„Έμ…˜ μ €μž₯ (AES-256-GCM)
β”‚   β”‚   β”‚   └── AuthManager.ts       # 인증 관리 (Cookie Jar)
β”‚   β”‚   β”œβ”€β”€ client/          # API ν΄λΌμ΄μ–ΈνŠΈ
β”‚   β”‚   β”‚   └── WhatapClient.ts      # WhaTap API (Dual Auth)
β”‚   β”‚   └── executor/        # MXQL μ‹€ν–‰κΈ°
β”‚   β”‚       └── MxqlExecutor.ts      # 쿼리 μ‹€ν–‰ 및 편의 λ©”μ„œλ“œ
β”‚   └── cli/                  # CLI μΈν„°νŽ˜μ΄μŠ€
β”‚       β”œβ”€β”€ commands/        # λͺ…λ Ήμ–΄ κ΅¬ν˜„
β”‚       β”‚   β”œβ”€β”€ login.ts
β”‚       β”‚   β”œβ”€β”€ logout.ts
β”‚       β”‚   β”œβ”€β”€ projects.ts
β”‚       β”‚   β”œβ”€β”€ query.ts
β”‚       β”‚   └── interactive.ts
β”‚       β”œβ”€β”€ utils/           # μœ ν‹Έλ¦¬ν‹°
β”‚       β”‚   β”œβ”€β”€ formatters.ts        # 좜λ ₯ ν¬λ§·νŒ…
β”‚       β”‚   └── session.ts           # μ„Έμ…˜ 관리
β”‚       └── index.ts         # CLI μ§„μž…μ 
β”œβ”€β”€ test/                     # ν…ŒμŠ€νŠΈ
β”œβ”€β”€ bin/                      # μ‹€ν–‰ 파일
β”‚   └── whatap-mxql
└── dist/                     # λΉŒλ“œ 좜λ ₯

πŸ“Š ν…ŒμŠ€νŠΈ ν˜„ν™©

Core λͺ¨λ“ˆ (52개 μœ λ‹› ν…ŒμŠ€νŠΈ)

  • βœ… SessionStore: 16/16 ν…ŒμŠ€νŠΈ 톡과
  • βœ… AuthManager: 16/16 ν…ŒμŠ€νŠΈ 톡과
  • βœ… WhatapClient: 13/13 ν…ŒμŠ€νŠΈ 톡과
  • βœ… MxqlExecutor: 7/7 ν…ŒμŠ€νŠΈ 톡과

CLI

  • βœ… login: 정상 λ™μž‘
  • βœ… logout: 정상 λ™μž‘
  • βœ… projects: 정상 λ™μž‘ (12개 ν”„λ‘œμ νŠΈ 쑰회)
  • βœ… query: 정상 λ™μž‘ (μ‹€μ œ 데이터 쑰회 성곡)
  • βœ… interactive: 정상 λ™μž‘
  • βœ… 좜λ ₯ ν˜•μ‹: Table, JSON, CSV λͺ¨λ‘ 정상

μ‹€μ œ 데이터 쑰회

  • βœ… λ³΅μž‘ν•œ MXQL νŒŒμ΄ν”„λΌμΈ 쿼리 μ‹€ν–‰
  • βœ… ν”„λ‘œμ νŠΈ 27506μ—μ„œ sessionCount 데이터 쑰회
  • βœ… 167개 ν–‰ 집계 κ²°κ³Ό λ°˜ν™˜
  • βœ… λ°”μ΄λ„ˆλ¦¬ 데이터 ν¬ν•¨ν•œ λ³΅μž‘ν•œ ꡬ쑰 처리

상세 검증 κ²°κ³ΌλŠ” λ₯Ό μ°Έμ‘°ν•˜μ„Έμš”.

πŸ“ License

MIT

πŸ”’ Security

Session data is encrypted using AES-256-GCM. Encryption keys are stored locally with restricted permissions (0600).

Never commit .env.test or any files containing credentials to version control.