lotto-mcp-server

labforadvancedstudy/lotto-mcp-server

3.2

If you are the rightful owner of lotto-mcp-server 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.

This is an MCP server for automatically purchasing lottery tickets and checking results from Donghaeng Lottery.

Tools
  1. purchase_lotto

    Automatically purchases lottery tickets from Donghaeng Lottery.

  2. check_lotto_winning

    Checks the winning results of lottery numbers.

๋กœ๋˜ MCP ์„œ๋ฒ„

๋™ํ–‰๋ณต๊ถŒ์—์„œ ๋กœ๋˜๋ฅผ ์ž๋™์œผ๋กœ ๊ตฌ๋งคํ•˜๊ณ  ๋‹น์ฒจ ๊ฒฐ๊ณผ๋ฅผ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋Š” MCP(Model Context Protocol) ์„œ๋ฒ„์ž…๋‹ˆ๋‹ค.

๐Ÿ“‹ ๊ธฐ๋Šฅ

  • ๋กœ๋˜ ์ž๋™ ๊ตฌ๋งค: ๋™ํ–‰๋ณต๊ถŒ ๊ณ„์ •์œผ๋กœ ๋กœ๊ทธ์ธํ•˜์—ฌ ๋กœ๋˜๋ฅผ ์ž๋™์œผ๋กœ ๊ตฌ๋งค
  • ๋‹น์ฒจ ๊ฒฐ๊ณผ ํ™•์ธ: ๊ตฌ๋งคํ•œ ๋กœ๋˜ ๋ฒˆํ˜ธ์˜ ๋‹น์ฒจ ๊ฒฐ๊ณผ๋ฅผ ์ž๋™์œผ๋กœ ํ™•์ธ
  • ๋ณด์•ˆ ๊ฐ•ํ™”: ID/ํŒจ์Šค์›Œ๋“œ๋ฅผ ์•”ํ˜ธํ™”ํ•˜์—ฌ ์•ˆ์ „ํ•˜๊ฒŒ ์ €์žฅ
  • Docker ์ง€์›: ๋ณ„๋„ ์„ค์น˜ ์—†์ด Docker๋กœ ๋ฐ”๋กœ ์‹คํ–‰ ๊ฐ€๋Šฅ

๐Ÿš€ ์„ค์น˜ ๋ฐ ์‹คํ–‰ ๋ฐฉ๋ฒ•

๋ฐฉ๋ฒ• 1: npx ์‚ฌ์šฉ (์ถ”์ฒœ) โšก

# ๊ณ„์ • ์„ค์ • ๋„์šฐ๋ฏธ
npx @labforadvanced.study/lotto-mcp-server --setup

# ๋˜๋Š” ์ง์ ‘ ์ธ์ฝ”๋”ฉ
echo "your_id,your_password" | base64

Claude Desktop ์„ค์ •:

{
  "mcpServers": {
    "lotto": {
      "command": "npx",
      "args": ["@labforadvanced.study/lotto-mcp-server"],
      "env": {
        "LOTTO_CREDENTIALS": "your_base64_credentials"
      }
    }
  }
}

์ž์„ธํ•œ npm ์‚ฌ์šฉ๋ฒ•์€ ๋ฅผ ์ฐธ๊ณ ํ•˜์„ธ์š”.

๋ฐฉ๋ฒ• 2: Docker ์‚ฌ์šฉ ๐Ÿณ

๋ณ„๋„ ์„ค์น˜๋‚˜ ๋นŒ๋“œ ์—†์ด ๋ฐฐํฌ๋œ Docker ์ด๋ฏธ์ง€๋ฅผ ๋ฐ”๋กœ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค!

1๋‹จ๊ณ„: ๊ณ„์ • ์ •๋ณด ์ธ์ฝ”๋”ฉ

ํ„ฐ๋ฏธ๋„์—์„œ ๊ฐ„๋‹จํ•˜๊ฒŒ ์ธ์ฝ”๋”ฉ:

# macOS/Linux
echo "your_lotto_id,your_password" | base64

# Windows (PowerShell)
[Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes("your_id,your_password"))

# ๊ฒฐ๊ณผ ์˜ˆ์‹œ: bXlfbG90dG9faWQsbXlfcGFzc3dvcmQ=
2๋‹จ๊ณ„: Claude Desktop ์„ค์ •

claude_desktop_config.json ํŒŒ์ผ์— ๋‹ค์Œ ์„ค์ •์„ ์ถ”๊ฐ€:

{
  "mcpServers": {
    "lotto": {
      "command": "docker",
      "args": [
        "run", "--rm", "-i",
        "-e", "LOTTO_CREDENTIALS=bXlfbG90dG9faWQsbXlfcGFzc3dvcmQ=",
        "your-dockerhub-username/lotto-mcp-server:latest"
      ]
    }
  }
}
3๋‹จ๊ณ„: Claude Desktop ์žฌ์‹œ์ž‘

Claude Desktop์„ ์žฌ์‹œ์ž‘ํ•˜๋ฉด ๋ฐ”๋กœ ์‚ฌ์šฉ ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค!

๋กœ๋˜ 3๊ฒŒ์ž„ ๊ตฌ๋งคํ•ด์ค˜

๋ฐฉ๋ฒ• 3: ๋กœ์ปฌ ์„ค์น˜

2-1. ํ•„์ˆ˜ ์กฐ๊ฑด
  • Node.js 18.0.0 ์ด์ƒ
  • ๋™ํ–‰๋ณต๊ถŒ ๊ณ„์ • (๋ฏธ๋ฆฌ ์˜ˆ์น˜๊ธˆ ์ถฉ์ „ ํ•„์š”)
2-2. ์„ค์น˜
# ์˜์กด์„ฑ ์„ค์น˜
npm install

# Playwright ๋ธŒ๋ผ์šฐ์ € ์„ค์น˜
npm run install-playwright

# ๋นŒ๋“œ
npm run build

3. ๊ณ„์ • ์ •๋ณด ์„ค์ • (๋‘ ๊ฐ€์ง€ ๋ฐฉ๋ฒ•)

๋ฐฉ๋ฒ• 1: ๊ฐ„๋‹จ ๋ชจ๋“œ (Base64 ์ธ์ฝ”๋”ฉ) - ์ถ”์ฒœ โญ
# ๋ฐฉ๋ฒ• 1-A: ์ธํ„ฐ๋ž™ํ‹ฐ๋ธŒ ๋„๊ตฌ ์‚ฌ์šฉ
npm run encrypt-credentials
# ์„ ํƒ: 1 (๊ฐ„๋‹จ ๋ชจ๋“œ)

# ๋ฐฉ๋ฒ• 1-B: ๊ฐ„๋‹จ ์Šคํฌ๋ฆฝํŠธ ์‚ฌ์šฉ
npm run simple-encode

# ๋ฐฉ๋ฒ• 1-C: ํ„ฐ๋ฏธ๋„์—์„œ ์ง์ ‘
echo "your_id,your_password" | base64

์ถœ๋ ฅ ์˜ˆ์‹œ:

{
  "mcpServers": {
    "lotto": {
      "command": "node",
      "args": ["path/to/lotto-mcp-server/dist/index.js"],
      "env": {
        "LOTTO_CREDENTIALS": "eW91cl9pZCx5b3VyX3Bhc3N3b3Jk"
      }
    }
  }
}
๋ฐฉ๋ฒ• 2: ๊ณ ๊ธ‰ ๋ชจ๋“œ (AES ์•”ํ˜ธํ™”)
npm run encrypt-credentials
# ์„ ํƒ: 2 (๊ณ ๊ธ‰ ๋ชจ๋“œ)

์ถœ๋ ฅ ์˜ˆ์‹œ:

{
  "mcpServers": {
    "lotto": {
      "command": "node",
      "args": ["path/to/lotto-mcp-server/dist/index.js"],
      "env": {
        "LOTTO_ENCRYPTED_ID": "YWJjZGVmZ2hpams...",
        "LOTTO_ENCRYPTED_PASSWORD": "bXlwYXNzd29yZA...",
        "LOTTO_SECRET_KEY": "optional-custom-key"
      }
    }
  }
}

4. Claude Desktop ์„ค์ •

  1. ์œ„์—์„œ ์ƒ์„ฑ๋œ ์„ค์ •์„ claude_desktop_config.json ํŒŒ์ผ์— ๋ณต์‚ฌ
  2. "path/to/lotto-mcp-server/dist/index.js"๋ฅผ ์‹ค์ œ ๊ฒฝ๋กœ๋กœ ๋ณ€๊ฒฝ
  3. Claude Desktop ์žฌ์‹œ์ž‘

5. ๊ฐœ๋ฐœ ๋ชจ๋“œ ์‹คํ–‰

npm run dev

6. ํ”„๋กœ๋•์…˜ ์‹คํ–‰

npm start

๐Ÿ› ๏ธ ์‚ฌ์šฉ๋ฒ•

์ด MCP ์„œ๋ฒ„๋Š” ๋‹ค์Œ ๋‘ ๊ฐ€์ง€ ๋„๊ตฌ๋ฅผ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค:

1. purchase_lotto - ๋กœ๋˜ ๊ตฌ๋งค

๋™ํ–‰๋ณต๊ถŒ์—์„œ ๋กœ๋˜๋ฅผ ์ž๋™์œผ๋กœ ๊ตฌ๋งคํ•ฉ๋‹ˆ๋‹ค. ID/ํŒจ์Šค์›Œ๋“œ๋Š” ์„ค์ •์—์„œ ์ž๋™์œผ๋กœ ๊ฐ€์ ธ์˜ต๋‹ˆ๋‹ค.

์ž…๋ ฅ ํŒŒ๋ผ๋ฏธํ„ฐ:

  • count (number): ๊ตฌ๋งคํ•  ๋กœ๋˜ ๊ฒŒ์ž„ ์ˆ˜ (1-5)

์ถœ๋ ฅ ์˜ˆ์‹œ:

{
  "success": true,
  "numbers": [
    [1, 14, 21, 27, 30, 44],
    [4, 5, 27, 29, 40, 44],
    [9, 18, 19, 24, 38, 42]
  ],
  "message": "3๊ฒŒ์ž„์„ ์„ฑ๊ณต์ ์œผ๋กœ ๊ตฌ๋งคํ–ˆ์Šต๋‹ˆ๋‹ค."
}

2. check_lotto_winning - ๋‹น์ฒจ ํ™•์ธ

๋กœ๋˜ ๋ฒˆํ˜ธ์˜ ๋‹น์ฒจ ๊ฒฐ๊ณผ๋ฅผ ํ™•์ธํ•ฉ๋‹ˆ๋‹ค.

์ž…๋ ฅ ํŒŒ๋ผ๋ฏธํ„ฐ:

  • numbers (array): ํ™•์ธํ•  ๋กœ๋˜ ๋ฒˆํ˜ธ ๋ฐฐ์—ด (์˜ˆ: [[1,2,3,4,5,6], [7,8,9,10,11,12]])
  • round (number, ์„ ํƒ์‚ฌํ•ญ): ํ™•์ธํ•  ํšŒ์ฐจ (๊ธฐ๋ณธ๊ฐ’: ํ˜„์žฌ ํšŒ์ฐจ)

์ถœ๋ ฅ ์˜ˆ์‹œ:

{
  "success": true,
  "results": [
    {
      "numbers": [1, 2, 3, 4, 5, 6],
      "rank": 5,
      "matchedNumbers": [1, 2, 3]
    },
    {
      "numbers": [7, 8, 9, 10, 11, 12],
      "rank": 0,
      "matchedNumbers": []
    }
  ],
  "message": "1143ํšŒ์ฐจ ๋‹น์ฒจ ๊ฒฐ๊ณผ๋ฅผ ํ™•์ธํ–ˆ์Šต๋‹ˆ๋‹ค."
}

๐Ÿ’ก MCP ํด๋ผ์ด์–ธํŠธ์—์„œ ์‚ฌ์šฉํ•˜๊ธฐ

Claude Desktop์—์„œ ์‚ฌ์šฉ

์„ค์ • ์™„๋ฃŒ ํ›„ Claude์—์„œ ๋‹ค์Œ๊ณผ ๊ฐ™์ด ์‚ฌ์šฉ:

๋กœ๋˜ 3๊ฒŒ์ž„ ๊ตฌ๋งคํ•ด์ค˜
์ด ๋กœ๋˜ ๋ฒˆํ˜ธ๋“ค ๋‹น์ฒจ ํ™•์ธํ•ด์ค˜: [[1,2,3,4,5,6], [7,8,9,10,11,12]]

๐Ÿ” ๋ณด์•ˆ ๊ธฐ๋Šฅ

๊ฐ„๋‹จ ๋ชจ๋“œ (Base64) - ์ถ”์ฒœ

  • ํ„ฐ๋ฏธ๋„์—์„œ echo "id,password" | base64๋กœ ๊ฐ„๋‹จ ์ƒ์„ฑ
  • raw ํŒจ์Šค์›Œ๋“œ๊ฐ€ ๊ทธ๋Œ€๋กœ ๋…ธ์ถœ๋˜์ง€ ์•Š์Œ
  • ์„ค์ • ํŒŒ์ผ์—์„œ ํŒจ์Šค์›Œ๋“œ ์ง์ ‘ ํ™•์ธ ๋ถˆ๊ฐ€
  • ๋Œ€๋ถ€๋ถ„ ์‚ฌ์šฉ์ž์—๊ฒŒ ์ถฉ๋ถ„ํ•œ ๋ณด์•ˆ ์ˆ˜์ค€

๊ณ ๊ธ‰ ๋ชจ๋“œ (AES ์•”ํ˜ธํ™”)

  • AES-256-CBC ๋Œ€์นญ ์•”ํ˜ธํ™”
  • ์‚ฌ์šฉ์ž ์ •์˜ ์•”ํ˜ธํ™” ํ‚ค ์ง€์›
  • Base64 ์ถ”๊ฐ€ ์ธ์ฝ”๋”ฉ์œผ๋กœ ๋ณด์•ˆ์ธต ๊ฐ•ํ™”
  • ๊ณ ๊ธ‰ ๋ณด์•ˆ์ด ํ•„์š”ํ•œ ๊ฒฝ์šฐ ์‚ฌ์šฉ

ํ„ฐ๋ฏธ๋„์—์„œ ์ง์ ‘ ์ƒ์„ฑํ•˜๊ธฐ

๊ฐ„๋‹จ ๋ชจ๋“œ๋ฅผ ํ„ฐ๋ฏธ๋„์—์„œ ์ง์ ‘ ์ƒ์„ฑํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค:

# macOS/Linux
echo "your_id,your_password" | base64

# Windows (PowerShell)
[Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes("your_id,your_password"))

๋ณด์•ˆ ์ˆ˜์ค€ ๋น„๊ต

๋ฐฉ์‹๋ณด์•ˆ ์ˆ˜์ค€ํŽธ์˜์„ฑ์‚ฌ์šฉ ์ƒํ™ฉ
๊ฐ„๋‹จ ๋ชจ๋“œโญโญโญโญโญโญโญโญ์ผ๋ฐ˜ ์‚ฌ์šฉ์ž, ๊ฐœ์ธ PC
๊ณ ๊ธ‰ ๋ชจ๋“œโญโญโญโญโญโญโญโญ๋ฏผ๊ฐํ•œ ํ™˜๊ฒฝ, ๊ณต์šฉ PC

โš ๏ธ ์ฃผ์˜์‚ฌํ•ญ

  1. ์˜ˆ์น˜๊ธˆ ์ถฉ์ „: ๊ตฌ๋งค ์ „์— ๋™ํ–‰๋ณต๊ถŒ ๊ณ„์ •์— ์ถฉ๋ถ„ํ•œ ์˜ˆ์น˜๊ธˆ์„ ๋ฏธ๋ฆฌ ์ถฉ์ „ํ•ด๋‘์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.
  2. ๊ณ„์ • ๋ณด์•ˆ: ์•”ํ˜ธํ™”๋œ ๊ณ„์ • ์ •๋ณด์™€ ์‹œํฌ๋ฆฟ ํ‚ค๋ฅผ ์•ˆ์ „ํ•˜๊ฒŒ ๊ด€๋ฆฌํ•˜์„ธ์š”.
  3. ๊ตฌ๋งค ํ•œ๋„: ํ•œ ๋ฒˆ์— ์ตœ๋Œ€ 5๊ฒŒ์ž„๊นŒ์ง€๋งŒ ๊ตฌ๋งค ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค.
  4. ๋‹น์ฒจ ๋ฒˆํ˜ธ: ๋กœ๋˜ ๋ฒˆํ˜ธ๋Š” 1~45 ์‚ฌ์ด์˜ ์ˆซ์ž 6๊ฐœ์—ฌ์•ผ ํ•ฉ๋‹ˆ๋‹ค.
  5. ๋ธŒ๋ผ์šฐ์ € ์ž์›: Playwright๊ฐ€ Chromium์„ ์‹คํ–‰ํ•˜๋ฏ€๋กœ ์‹œ์Šคํ…œ ๋ฆฌ์†Œ์Šค๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.

๐Ÿ”ง ์„ค์ • ์˜ต์…˜

src/lotto-service.ts ํŒŒ์ผ์—์„œ ๋‹ค์Œ ์˜ต์…˜์„ ์ˆ˜์ •ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค:

this.lottoService = new BaseLottoService({
  controller: chromium,
  headless: true,              // false๋กœ ๋ณ€๊ฒฝํ•˜๋ฉด ๋ธŒ๋ผ์šฐ์ € ์ฐฝ์ด ๋ณด์ž„
  defaultViewport: { 
    width: 1280, 
    height: 720 
  },
  logLevel: 2                  // ๋กœ๊ทธ ๋ ˆ๋ฒจ (0: ERROR, 1: WARN, 2: INFO, 3: DEBUG)
});

๐Ÿ“ ํ”„๋กœ์ ํŠธ ๊ตฌ์กฐ

lotto-mcp-server/
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ index.ts              # MCP ์„œ๋ฒ„ ๋ฉ”์ธ ํŒŒ์ผ
โ”‚   โ”œโ”€โ”€ lotto-service.ts      # ๋กœ๋˜ ์„œ๋น„์Šค ํด๋ž˜์Šค
โ”‚   โ”œโ”€โ”€ crypto-utils.ts       # ์•”ํ˜ธํ™”/๋ณตํ˜ธํ™” ์œ ํ‹ธ๋ฆฌํ‹ฐ
โ”‚   โ””โ”€โ”€ encrypt-credentials.ts # ๊ณ„์ • ์ •๋ณด ์ธ์ฝ”๋”ฉ ๋„๊ตฌ
โ”œโ”€โ”€ scripts/
โ”‚   โ””โ”€โ”€ simple-encode.sh      # ๊ฐ„๋‹จ ์ธ์ฝ”๋”ฉ ์Šคํฌ๋ฆฝํŠธ
โ”œโ”€โ”€ dist/                     # ๋นŒ๋“œ ๊ฒฐ๊ณผ๋ฌผ
โ”œโ”€โ”€ package.json
โ”œโ”€โ”€ tsconfig.json
โ””โ”€โ”€ README.md

๐Ÿ› ๋ฌธ์ œ ํ•ด๊ฒฐ

๋ธŒ๋ผ์šฐ์ € ์„ค์น˜ ์˜ค๋ฅ˜

# Playwright ๋ธŒ๋ผ์šฐ์ € ์žฌ์„ค์น˜
npx playwright install chromium

๊ณ„์ • ์ •๋ณด ์˜ค๋ฅ˜

# ๊ฐ„๋‹จ ๋ชจ๋“œ๋กœ ์žฌ์„ค์ •
npm run simple-encode

# ๋˜๋Š” ๊ณ ๊ธ‰ ๋ชจ๋“œ๋กœ ์žฌ์„ค์ •
npm run encrypt-credentials

๋กœ๊ทธ์ธ ์‹คํŒจ

  • ID์™€ ํŒจ์Šค์›Œ๋“œ๊ฐ€ ์ •ํ™•ํ•œ์ง€ ํ™•์ธ
  • ๋™ํ–‰๋ณต๊ถŒ ์‚ฌ์ดํŠธ์— ์ง์ ‘ ๋กœ๊ทธ์ธํ•ด์„œ ๊ณ„์ • ์ƒํƒœ ํ™•์ธ
  • ๋ณด์•ˆ ์„ค์ •์œผ๋กœ ์ธํ•œ ๋กœ๊ทธ์ธ ์ œํ•œ ์—ฌ๋ถ€ ํ™•์ธ

๊ตฌ๋งค ์‹คํŒจ

  • ๊ณ„์ •์— ์ถฉ๋ถ„ํ•œ ์˜ˆ์น˜๊ธˆ์ด ์žˆ๋Š”์ง€ ํ™•์ธ
  • ๋™ํ–‰๋ณต๊ถŒ ์‚ฌ์ดํŠธ์˜ ์„œ๋น„์Šค ์‹œ๊ฐ„ ํ™•์ธ (ํ† ์š”์ผ ๋ฐค~์ผ์š”์ผ ์˜คํ›„๋Š” ์„œ๋น„์Šค ์ค‘๋‹จ)

๐Ÿ“„ ๋ผ์ด์„ ์Šค

MIT License

๐Ÿค ๊ธฐ์—ฌ

๋ฒ„๊ทธ ๋ฆฌํฌํŠธ๋‚˜ ๊ธฐ๋Šฅ ์ œ์•ˆ์€ ์ด์Šˆ๋กœ ๋“ฑ๋กํ•ด์ฃผ์„ธ์š”.

โš–๏ธ ๋ฒ•์  ๊ณ ์ง€

์ด ๋„๊ตฌ๋Š” ๋™ํ–‰๋ณต๊ถŒ์˜ ๊ณต์‹ API๋ฅผ ์‚ฌ์šฉํ•˜์ง€ ์•Š๊ณ  ์›น ์Šคํฌ๋ž˜ํ•‘์„ ํ†ตํ•ด ์ž‘๋™ํ•ฉ๋‹ˆ๋‹ค. ์‚ฌ์šฉ์— ๋”ฐ๋ฅธ ๋ชจ๋“  ์ฑ…์ž„์€ ์‚ฌ์šฉ์ž์—๊ฒŒ ์žˆ์œผ๋ฉฐ, ๊ณผ๋„ํ•œ ์‚ฌ์šฉ์œผ๋กœ ์ธํ•œ ๊ณ„์ • ์ œ์žฌ๋‚˜ ๊ธฐํƒ€ ๋ฌธ์ œ์— ๋Œ€ํ•ด์„œ๋Š” ์ฑ…์ž„์ง€์ง€ ์•Š์Šต๋‹ˆ๋‹ค.