├── .github ├── topics.txt └── workflows │ └── main.yml ├── .gitignore ├── CONTRIBUTING.md ├── LICENSE ├── README.ko.md ├── README.md ├── bin └── ccxt-mcp.js ├── docs └── getting-started.md ├── examples └── config-example.json ├── package-lock.json ├── package.json ├── src ├── index.ts ├── resources │ ├── exchanges.ts │ ├── markets.ts │ ├── orderbooks.ts │ └── prices.ts ├── server.ts └── tools │ ├── account-tools.ts │ ├── analysis-tools.ts │ ├── market-tools.ts │ └── order-tools.ts ├── test-config.js └── tsconfig.json /.github/topics.txt: -------------------------------------------------------------------------------- 1 | ccxt 2 | mcp 3 | modelcontextprotocol 4 | cryptocurrency 5 | trading 6 | exchange 7 | api 8 | claude 9 | gpt 10 | ai-trading 11 | crypto-trading 12 | crypto-exchange 13 | crypto-api 14 | ai-tools 15 | trading-bot 16 | algorithmic-trading 17 | quantitative-trading 18 | -------------------------------------------------------------------------------- /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: CI/CD Pipeline 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | pull_request: 7 | branches: [ master ] 8 | 9 | jobs: 10 | build: 11 | runs-on: ubuntu-latest 12 | 13 | strategy: 14 | matrix: 15 | node-version: [18.x, 20.x] 16 | 17 | steps: 18 | - uses: actions/checkout@v3 19 | - name: Use Node.js ${{ matrix.node-version }} 20 | uses: actions/setup-node@v3 21 | with: 22 | node-version: ${{ matrix.node-version }} 23 | cache: 'npm' 24 | - run: npm ci 25 | - run: npm run build 26 | - run: npm test 27 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # 개발 도구 및 환경 2 | .aider* 3 | .DS_Store 4 | .idea/ 5 | .vscode/ 6 | *.swp 7 | *.swo 8 | 9 | # 의존성 및 드 10 | /node_modules 11 | /dist 12 | /coverage 13 | *.log 14 | *.tsbuildinfo 15 | 16 | # 환경 변수 파일 17 | .env 18 | .env.local 19 | .env*.local 20 | 21 | # 테스트 결과 22 | /junit.xml 23 | /test-results/ 24 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # 기여 가이드라인 2 | 3 | CCXT MCP 프로젝트에 관심을 가져주셔서 감사합니다! 이 프로젝트는 커뮤니티의 기여를 통해 더 나아질 수 있습니다. 다음 가이드라인은 개발에 참여하고자 하는 분들을 위한 것입니다. 4 | 5 | ## 기여 방법 6 | 7 | 다음과 같은 방법으로 프로젝트에 기여하실 수 있습니다: 8 | 9 | 1. **버그 리포트**: GitHub 이슈를 통해 발견한 버그를 제보해 주세요. 10 | 2. **기능 요청**: 새로운 기능 아이디어가 있다면 GitHub 이슈를 통해 제안해 주세요. 11 | 3. **코드 기여**: Pull Request를 통해 직접 코드를 기여해 주세요. 12 | 4. **문서 개선**: README나 코드 문서화에 기여해 주세요. 13 | 5. **사용 사례 공유**: 이 도구를 사용하는 창의적인 방법을 공유해 주세요. 14 | 15 | ## 개발 환경 설정 16 | 17 | ```bash 18 | # 저장소 클론 19 | git clone https://github.com/lazy-dinosaur/ccxt-mcp.git 20 | 21 | # 프로젝트 디렉토리로 이동 22 | cd ccxt-mcp 23 | 24 | # 의존성 설치 25 | npm install 26 | 27 | # 개발 모드 실행 28 | npm run dev 29 | ``` 30 | 31 | ## Pull Request 과정 32 | 33 | 1. 먼저 GitHub에서 저장소를 포크하세요. 34 | 2. 포크한 저장소를 로컬에 클론하세요. 35 | 3. 기능별로 브랜치를 만드세요 (예: `feature/new-exchange-support`). 36 | 4. 변경사항을 커밋하세요. 37 | 5. GitHub에 변경사항을 푸시하세요. 38 | 6. GitHub에서 원본 저장소로 Pull Request를 만드세요. 39 | 40 | ## Pull Request 체크리스트 41 | 42 | PR을 제출하기 전에 다음 사항을 확인해 주세요: 43 | 44 | - [ ] 코드가 TypeScript 코딩 스타일을 따르는지 확인 45 | - [ ] 필요한 테스트를 추가했는지 확인 46 | - [ ] 모든 테스트가 통과하는지 확인 47 | - [ ] 필요한 문서를 업데이트했는지 확인 48 | - [ ] PR이 단일 책임 원칙을 따르는지 (한 PR에 한 가지 기능/수정사항) 49 | 50 | ## 코딩 스타일 51 | 52 | - TypeScript 코딩 규칙을 따릅니다. 53 | - 두 칸 들여쓰기를 사용합니다. 54 | - 명확한 변수 및 함수 이름을 사용합니다. 55 | - JSDoc 형식의 주석을 추가합니다. 56 | 57 | ## 커밋 메시지 가이드라인 58 | 59 | 커밋 메시지는 다음과 같은 형식을 따라주세요: 60 | 61 | ``` 62 | 유형: 간략한 변경사항 설명 63 | 64 | 상세 변경 내용 설명 (필요한 경우) 65 | ``` 66 | 67 | 유형: 68 | - `feat`: 새로운 기능 69 | - `fix`: 버그 수정 70 | - `docs`: 문서 변경 71 | - `style`: 코드 스타일 변경 72 | - `refactor`: 코드 리팩토링 73 | - `test`: 테스트 관련 변경 74 | - `chore`: 빌드 프로세스나 도구 변경 75 | 76 | 예시: 77 | ``` 78 | feat: 바이낸스 선물 시장 지원 추가 79 | 80 | - 바이낸스 선물 시장 API 연동 81 | - 레버리지 설정 기능 구현 82 | - 포지션 관리 기능 추가 83 | ``` 84 | 85 | ## 라이센스 86 | 87 | 이 프로젝트에 기여함으로써, 귀하의 기여물이 MIT 라이센스의 조건에 따라 배포된다는 것에 동의하게 됩니다. 88 | 89 | ## 연락처 90 | 91 | 질문이 있으시면 언제든지 GitHub 이슈를 통해 문의하거나 직접 이메일을 보내주세요. 92 | 93 | 감사합니다! 94 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2025 LazyDino 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.ko.md: -------------------------------------------------------------------------------- 1 | # CCXT MCP Server 2 | 3 | [![npm version](https://img.shields.io/npm/v/@lazydino/ccxt-mcp.svg)](https://www.npmjs.com/package/@lazydino/ccxt-mcp) 4 | [![npm downloads](https://img.shields.io/npm/dm/@lazydino/ccxt-mcp.svg)](https://www.npmjs.com/package/@lazydino/ccxt-mcp) 5 | [![GitHub stars](https://img.shields.io/github/stars/lazy-dinosaur/ccxt-mcp.svg)](https://github.com/lazy-dinosaur/ccxt-mcp/stargazers) 6 | [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) 7 | 8 | [English version(영어 버전)](README.md) 9 | 10 | CCXT MCP 서버는 [Model Context Protocol (MCP)](https://github.com/anthropics/anthropic-cookbook/tree/main/model-context-protocol)을 통해 AI 모델이 암호화폐 거래소 API와 상호작용할 수 있도록 하는 서버입니다. 이 서버는 [CCXT 라이브러리](https://github.com/ccxt/ccxt)를 사용하여 100개 이상의 암호화폐 거래소에 접근하고 거래할 수 있는 기능을 제공합니다. 11 | 12 | ## 🚀 빠른 시작 13 | 14 | ```bash 15 | # 패키지 전역 설치 16 | npm install -g @lazydino/ccxt-mcp 17 | 18 | # 기본 설정으로 실행 19 | ccxt-mcp 20 | 21 | # 또는 설치 없이 실행 22 | npx @lazydino/ccxt-mcp 23 | ``` 24 | 25 | ## 설치 및 사용법 26 | 27 | ### 글로벌 설치 28 | 29 | ```bash 30 | # 패키지 전역 설치 31 | npm install -g @lazydino/ccxt-mcp 32 | ``` 33 | 34 | ### npx로 실행하기 35 | 36 | 설치 없이 바로 실행할 수 있습니다: 37 | 38 | ```bash 39 | # 기본 설정 사용 40 | npx @lazydino/ccxt-mcp 41 | 42 | # 사용자 지정 설정 파일 사용 43 | npx @lazydino/ccxt-mcp --config /path/to/config.json 44 | ``` 45 | 46 | 도움말 보기: 47 | 48 | ```bash 49 | npx @lazydino/ccxt-mcp --help 50 | ``` 51 | 52 | ## 설정 방법 53 | 54 | ### Claude Desktop에서 MCP 서버 등록하기 55 | 56 | 1. **Claude Desktop 설정 열기**: 57 | 58 | - Claude Desktop 앱의 설정(Settings) 메뉴로 이동 59 | - "MCP Servers" 섹션 찾기 60 | 61 | 2. **새 MCP 서버 추가**: 62 | 63 | - "Add Server" 버튼 클릭 64 | - 서버 이름: `ccxt-mcp` 65 | - 명령어: `npx @lazydino/ccxt-mcp` 66 | - 추가 인수(선택 사항): `--config /path/to/config.json` 67 | 68 | 3. **서버 저장 및 테스트**: 69 | - 설정 저장 70 | - "Test Connection" 버튼으로 연결 테스트 71 | 72 | ### 설정 방법 - 두 가지 옵션 73 | 74 | #### 옵션 1: Claude Desktop 설정 파일 내에 직접 계정 정보 포함 (기본 방식) 75 | 76 | 이 방식은 Claude Desktop 설정 파일(claude_desktop_config.json) 내에 직접 CCXT 계정 정보를 포함합니다: 77 | 78 | ```json 79 | { 80 | "mcpServers": { 81 | "ccxt-mcp": { 82 | "command": "npx", 83 | "args": ["-y", "@lazydino/ccxt-mcp"], 84 | "accounts": [ 85 | { 86 | "name": "bybit_main", 87 | "exchangeId": "bybit", 88 | "apiKey": "YOUR_API_KEY", 89 | "secret": "YOUR_SECRET_KEY", 90 | "defaultType": "spot" 91 | }, 92 | { 93 | "name": "bybit_futures", 94 | "exchangeId": "bybit", 95 | "apiKey": "YOUR_API_KEY", 96 | "secret": "YOUR_SECRET_KEY", 97 | "defaultType": "swap" 98 | } 99 | ] 100 | } 101 | } 102 | } 103 | ``` 104 | 105 | 이 방식을 사용하면 별도의 설정 파일이 필요하지 않습니다. 모든 설정이 Claude Desktop 구성 파일에 통합됩니다. 106 | 107 | #### 옵션 2: 별도 설정 파일 사용 (고급 방식) 108 | 109 | 계정 정보를 별도의 설정 파일로 분리하려면 다음과 같이 구성하세요: 110 | 111 | 1. **별도 설정 파일 생성** (예: `ccxt-accounts.json`): 112 | 113 | ```json 114 | { 115 | "accounts": [ 116 | { 117 | "name": "bybit_main", 118 | "exchangeId": "bybit", 119 | "apiKey": "YOUR_API_KEY", 120 | "secret": "YOUR_SECRET_KEY", 121 | "defaultType": "spot" 122 | }, 123 | { 124 | "name": "bybit_futures", 125 | "exchangeId": "bybit", 126 | "apiKey": "YOUR_API_KEY", 127 | "secret": "YOUR_SECRET_KEY", 128 | "defaultType": "swap" 129 | } 130 | ] 131 | } 132 | ``` 133 | 134 | > **중요**: 설정 파일은 위와 같이 루트 수준에 `accounts` 배열을 포함해야 합니다. 135 | 136 | 2. **Claude Desktop 설정에서 설정 파일 경로 지정**: 137 | 138 | ```json 139 | { 140 | "mcpServers": { 141 | "ccxt-mcp": { 142 | "command": "npx", 143 | "args": [ 144 | "-y", 145 | "@lazydino/ccxt-mcp", 146 | "--config", 147 | "/path/to/ccxt-accounts.json" 148 | ] 149 | } 150 | } 151 | } 152 | ``` 153 | 154 | > **참고**: `--config` 옵션으로 별도 설정 파일을 사용할 때, 서버는 `mcpServers.ccxt-mcp.accounts` 경로가 아닌 JSON 파일의 루트에서 직접 `accounts` 배열을 찾습니다. 155 | 156 | 3. **명령줄에서 외부 설정 파일 사용하기**: 157 | 158 | ```bash 159 | # 사용자 지정 설정 파일 사용 160 | npx @lazydino/ccxt-mcp --config /path/to/ccxt-accounts.json 161 | ``` 162 | 163 | 저장소의 `examples/config-example.json`에서 예제 설정 파일을 찾을 수 있습니다. 164 | 165 | > **별도 설정 파일을 사용하는 이유**: 166 | > 167 | > - 재귀 참조 문제 방지 168 | > - API 키와 같은 민감한 정보 분리 169 | > - 다중 환경 설정 용이(개발, 테스트, 프로덕션) 170 | > - 설정 파일 버전 관리 개선 171 | 172 | ## 주요 기능 173 | 174 | - **시장 정보 조회**: 175 | 176 | - 거래소 목록 조회 177 | - 거래소별 시장 정보 조회 178 | - 특정 심볼의 가격 정보 조회 179 | - 특정 심볼의 주문장 정보 조회 180 | - 과거 OHLCV 데이터 검색 181 | 182 | - **거래 기능**: 183 | 184 | - 시장가/지정가 주문 생성 185 | - 주문 취소 및 상태 조회 186 | - 계정 잔액 조회 187 | - 거래 내역 조회 188 | 189 | - **트레이딩 분석**: 190 | 191 | - 일/주/월 단위 성과 분석 192 | - 승률 계산 (최근 7일, 30일, 전체 기간) 193 | - 평균 수익/손실 비율 (R-multiple) 194 | - 최대 연속 손실/이익 시리즈 분석 195 | - 자산 변동 추적 196 | - 종합적인 성과 지표 분석 197 | - 거래 패턴 인식 198 | - 기간별 수익률 계산 199 | 200 | - **포지션 관리**: 201 | 202 | - 자본 대비 비율 매매 (예: 계정 자본의 5% 진입) 203 | - 선물 시장 레버리지 설정 (1-100x) 204 | - 동적 포지션 사이징 (변동성 기반) 205 | - 분할 매수/매도 전략 구현 206 | 207 | - **리스크 관리**: 208 | - 기술적 지표 기반 손절매 설정 (예: 5분봉 기준 10개 캔들 중 저점) 209 | - 변동성 기반 손절매/익절매 (ATR 배수) 210 | - 최대 허용 손실 제한 (일별/주별) 211 | - 동적 익절매 설정 (추종형 이익 확정) 212 | 213 | ## 작동 방식 214 | 215 | ``` 216 | 사용자 <--> AI 모델(Claude/GPT) <--> MCP 프로토콜 <--> CCXT MCP 서버 <--> 암호화폐 거래소 API 217 | ``` 218 | 219 | 1. **사용자**: "비트코인 가격을 알려줘" 또는 "내 바이낸스 계정에서 이더리움 구매해줘"와 같은 요청 220 | 2. **AI 모델**: 사용자 요청을 이해하고 어떤 MCP 도구/리소스를 사용할지 결정 221 | 3. **MCP 프로토콜**: AI와 CCXT MCP 서버 간의 표준화된 통신 222 | 4. **CCXT MCP 서버**: CCXT 라이브러리를 사용하여 암호화폐 거래소 API와 통신 223 | 5. **거래소 API**: 실제 데이터 제공 및 거래 주문 실행 224 | 225 | ## AI 모델과 함께 사용하기 226 | 227 | Claude Desktop에 등록하면 AI 모델에게 다음과 같은 요청을 할 수 있습니다: 228 | 229 | ### 주의사항 및 추천 프롬프트 230 | 231 | AI 모델을 사용할 때 다음 주의사항을 고려하고, 효과적인 거래를 위해 아래와 같은 프롬프트를 사용하는 것이 좋습니다: 232 | 233 | ``` 234 | ccxt 툴을 최대한 이용해서 매매를 실행하는게 너의 목표야 235 | 주의사항 236 | - 선물 시장인지 현물 시장인지 정확하게 파악하고 매매 진행 237 | - 만약 자본의 몇프로 혹은 얼마 라는 지침이 없다면 무조건 사용가능한 전체 자본을 사용해서 계산해서 매매를 진행해 238 | ``` 239 | 240 | **참고 사항:** 241 | 242 | - AI 모델은 종종 선물 매매와 현물 매매를 혼동할 수 있습니다. 243 | - 거래 자본 규모에 대한 명확한 지침 없이는 AI가 혼란을 겪을 수 있습니다. 244 | - 위의 프롬프트를 사용하면 거래 의도를 명확히 전달하는 데 도움이 됩니다. 245 | 246 | ### 기본 쿼리 예시 247 | 248 | ``` 249 | 비트코인 현재 가격을 binance와 coinbase에서 조회하고 비교해줘. 250 | ``` 251 | 252 | ### 고급 트레이딩 쿼리 예시 253 | 254 | **포지션 관리** 255 | 256 | ``` 257 | 내 Bybit 계정(bybit_futures)에서 BTC/USDT 선물 시장에 자본의 5%로 10배 레버리지를 사용해 롱 포지션을 열어줘. 258 | 이동평균선 교차 전략을 기반으로 진입하고, 최근 12개 5분봉 중 저점에 손절을 설정해. 259 | ``` 260 | 261 | **성과 분석** 262 | 263 | ``` 264 | 지난 7일간의 내 Binance 계정(bybit_main) 거래 기록을 분석해서 승률, 평균 수익률, 최대 연속 손실을 보여줘. 265 | ``` 266 | 267 | **상세 거래 분석** 268 | 269 | ``` 270 | 지난 30일간 내 bybit_futures 계정의 BTC/USDT 거래 성과를 분석해줘. 승률, 수익 요소, 그리고 내 성공적인 거래들의 패턴을 파악해줘. 271 | ``` 272 | 273 | ``` 274 | 지난 90일간 내 bybit_main 계정의 월별 수익률을 보여주고, 가장 좋았던 달과 가장 나빴던 달을 알려줘. 275 | ``` 276 | 277 | ``` 278 | 내 bybit_futures 계정의 연속적인 성공과 실패를 분석하고, 손실 후에 내 심리적 패턴이 거래에 영향을 미치는지 알려줘. 279 | ``` 280 | 281 | ## 개발 282 | 283 | ### 소스에서 빌드하기 284 | 285 | ```bash 286 | # 저장소 클론 287 | git clone https://github.com/lazy-dinosaur/ccxt-mcp.git 288 | 289 | # 프로젝트 디렉토리로 이동 290 | cd ccxt-mcp 291 | 292 | # 의존성 설치 293 | npm install 294 | 295 | # 빌드 296 | npm run build 297 | ``` 298 | 299 | ## 🤝 기여하기 300 | 301 | 기여는 언제나 환영합니다! Pull Request를 자유롭게 제출해 주세요. 302 | 303 | ## 📄 라이센스 304 | 305 | MIT 라이센스로 배포됩니다. 자세한 내용은 LICENSE 파일을 참조하세요. 306 | 307 | ## ❤️ 지원하기 308 | 309 | 이 프로젝트가 유용하다고 생각하시면, GitHub에 ⭐️을 눌러주세요! 310 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # CCXT MCP Server 2 | 3 | [![npm version](https://img.shields.io/npm/v/@lazydino/ccxt-mcp.svg)](https://www.npmjs.com/package/@lazydino/ccxt-mcp) 4 | [![npm downloads](https://img.shields.io/npm/dm/@lazydino/ccxt-mcp.svg)](https://www.npmjs.com/package/@lazydino/ccxt-mcp) 5 | [![GitHub stars](https://img.shields.io/github/stars/lazy-dinosaur/ccxt-mcp.svg)](https://github.com/lazy-dinosaur/ccxt-mcp/stargazers) 6 | [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) 7 | 8 | [한국어 버전(Korean version)](README.ko.md) 9 | 10 | CCXT MCP Server is a server that allows AI models to interact with cryptocurrency exchange APIs through the [Model Context Protocol (MCP)](https://github.com/anthropics/anthropic-cookbook/tree/main/model-context-protocol). This server uses the [CCXT library](https://github.com/ccxt/ccxt) to provide access to more than 100 cryptocurrency exchanges and their trading capabilities. 11 | 12 | ## 🚀 Quick Start 13 | 14 | ```bash 15 | # Install the package globally 16 | npm install -g @lazydino/ccxt-mcp 17 | 18 | # Run with default settings 19 | ccxt-mcp 20 | 21 | # or run without installation 22 | npx @lazydino/ccxt-mcp 23 | ``` 24 | 25 | ## Installation and Usage 26 | 27 | ### Global Installation 28 | 29 | ```bash 30 | # Install the package globally 31 | npm install -g @lazydino/ccxt-mcp 32 | ``` 33 | 34 | ### Running with npx 35 | 36 | You can run it directly without installation: 37 | 38 | ```bash 39 | # Using default settings 40 | npx @lazydino/ccxt-mcp 41 | 42 | # Using custom configuration file 43 | npx @lazydino/ccxt-mcp --config /path/to/config.json 44 | ``` 45 | 46 | View help: 47 | 48 | ```bash 49 | npx @lazydino/ccxt-mcp --help 50 | ``` 51 | 52 | ## Configuration 53 | 54 | ### Registering the MCP Server in Claude Desktop 55 | 56 | 1. **Open Claude Desktop Settings**: 57 | 58 | - Go to the Settings menu in the Claude Desktop app 59 | - Find the "MCP Servers" section 60 | 61 | 2. **Add a New MCP Server**: 62 | 63 | - Click the "Add Server" button 64 | - Server name: `ccxt-mcp` 65 | - Command: `npx @lazydino/ccxt-mcp` 66 | - Additional arguments (optional): `--config /path/to/config.json` 67 | 68 | 3. **Save and Test the Server**: 69 | - Save the settings 70 | - Test the connection with the "Test Connection" button 71 | 72 | ### Configuration Methods - Two Options 73 | 74 | #### Option 1: Include Account Information Directly in Claude Desktop Settings (Basic Method) 75 | 76 | This method includes CCXT account information directly in the Claude Desktop settings file (claude_desktop_config.json): 77 | 78 | ```json 79 | { 80 | "mcpServers": { 81 | "ccxt-mcp": { 82 | "command": "npx", 83 | "args": ["-y", "@lazydino/ccxt-mcp"], 84 | "accounts": [ 85 | { 86 | "name": "bybit_main", 87 | "exchangeId": "bybit", 88 | "apiKey": "YOUR_API_KEY", 89 | "secret": "YOUR_SECRET_KEY", 90 | "defaultType": "spot" 91 | }, 92 | { 93 | "name": "bybit_futures", 94 | "exchangeId": "bybit", 95 | "apiKey": "YOUR_API_KEY", 96 | "secret": "YOUR_SECRET_KEY", 97 | "defaultType": "swap" 98 | } 99 | ] 100 | } 101 | } 102 | } 103 | ``` 104 | 105 | Using this method, you don't need a separate configuration file. All settings are integrated into the Claude Desktop configuration file. 106 | 107 | #### Option 2: Using a Separate Configuration File (Advanced Method) 108 | 109 | To separate account information into a separate configuration file, set up as follows: 110 | 111 | 1. **Create a Separate Configuration File** (e.g., `ccxt-accounts.json`): 112 | 113 | ```json 114 | { 115 | "accounts": [ 116 | { 117 | "name": "bybit_main", 118 | "exchangeId": "bybit", 119 | "apiKey": "YOUR_API_KEY", 120 | "secret": "YOUR_SECRET_KEY", 121 | "defaultType": "spot" 122 | }, 123 | { 124 | "name": "bybit_futures", 125 | "exchangeId": "bybit", 126 | "apiKey": "YOUR_API_KEY", 127 | "secret": "YOUR_SECRET_KEY", 128 | "defaultType": "swap" 129 | } 130 | ] 131 | } 132 | ``` 133 | 134 | > **Important**: The configuration file must contain an `accounts` array at the root level, as shown above. 135 | 136 | 2. **Specify the Configuration File Path in Claude Desktop Settings**: 137 | 138 | ```json 139 | { 140 | "mcpServers": { 141 | "ccxt-mcp": { 142 | "command": "npx", 143 | "args": [ 144 | "-y", 145 | "@lazydino/ccxt-mcp", 146 | "--config", 147 | "/path/to/ccxt-accounts.json" 148 | ] 149 | } 150 | } 151 | } 152 | ``` 153 | 154 | > **Note**: When using a separate configuration file with the `--config` option, the server will look for the `accounts` array directly in the root of the JSON file, not in `mcpServers.ccxt-mcp.accounts` path. 155 | 156 | 3. **Running with External Configuration File from Command Line**: 157 | 158 | ```bash 159 | # Using custom configuration file 160 | npx @lazydino/ccxt-mcp --config /path/to/ccxt-accounts.json 161 | ``` 162 | 163 | You can find an example configuration file at `examples/config-example.json` in the repository. 164 | 165 | > **Reasons to Use a Separate Configuration File**: 166 | > 167 | > - Prevents recursive reference issues 168 | > - Separates sensitive information like API keys 169 | > - Easier multi-environment configuration (development, testing, production) 170 | > - Improved configuration file version control 171 | 172 | ## Key Features 173 | 174 | - **Market Information Retrieval**: 175 | 176 | - List exchanges 177 | - View market information by exchange 178 | - Get price information for specific symbols 179 | - View order book information for specific symbols 180 | - Search historical OHLCV data 181 | 182 | - **Trading Functions**: 183 | 184 | - Create market/limit orders 185 | - Cancel orders and check status 186 | - View account balances 187 | - Check trading history 188 | 189 | - **Trading Analysis**: 190 | 191 | - Daily/weekly/monthly performance analysis 192 | - Win rate calculation (last 7 days, 30 days, all time) 193 | - Average profit/loss ratio (R-multiple) 194 | - Maximum consecutive loss/profit series analysis 195 | - Asset variation tracking 196 | - Comprehensive performance metrics 197 | - Trade pattern recognition 198 | - Period-based return calculations 199 | 200 | - **Position Management**: 201 | 202 | - Capital ratio trading (e.g., enter with 5% of account capital) 203 | - Futures market leverage setting (1-100x) 204 | - Dynamic position sizing (volatility-based) 205 | - Split buy/sell strategy implementation 206 | 207 | - **Risk Management**: 208 | - Technical indicator-based stop loss setting (e.g., lowest point among 10 candles on 5-minute chart) 209 | - Volatility-based stop loss/take profit (ATR multiples) 210 | - Maximum allowable loss limit (daily/weekly) 211 | - Dynamic take profit setting (trailing profit) 212 | 213 | ## How It Works 214 | 215 | ``` 216 | User <--> AI Model(Claude/GPT) <--> MCP Protocol <--> CCXT MCP Server <--> Cryptocurrency Exchange API 217 | ``` 218 | 219 | 1. **User**: Requests like "Tell me the Bitcoin price" or "Buy Ethereum on my Binance account" 220 | 2. **AI Model**: Understands user requests and determines which MCP tools/resources to use 221 | 3. **MCP Protocol**: Standardized communication between AI and CCXT MCP server 222 | 4. **CCXT MCP Server**: Communicates with cryptocurrency exchange APIs using the CCXT library 223 | 5. **Exchange API**: Provides actual data and executes trade orders 224 | 225 | ## Using with AI Models 226 | 227 | When registered with Claude Desktop, you can make the following types of requests to AI models: 228 | 229 | ### Cautions and Recommended Prompts 230 | 231 | When using AI models, consider the following cautions and use the prompt below for effective trading: 232 | 233 | ``` 234 | Your goal is to execute trades using the ccxt tools as much as possible 235 | Cautions: 236 | - Accurately identify whether it's a futures market or spot market before proceeding with trades 237 | - If there's no instruction about percentage of capital or amount to use, always calculate and execute trades using the entire available capital 238 | ``` 239 | 240 | **Notes:** 241 | 242 | - AI models sometimes confuse futures trading with spot trading. 243 | - Without clear guidance on trading capital size, AI might get confused. 244 | - Using the above prompt helps clearly communicate your trading intentions. 245 | 246 | ### Basic Query Examples 247 | 248 | ``` 249 | Check and compare the current Bitcoin price on binance and coinbase. 250 | ``` 251 | 252 | ### Advanced Trading Query Examples 253 | 254 | **Position Management** 255 | 256 | ``` 257 | Open a long position on BTC/USDT futures market in my Bybit account (bybit_futures) with 5% of capital using 10x leverage. 258 | Enter based on moving average crossover strategy and set stop loss at the lowest point among the 12 most recent 5-minute candles. 259 | ``` 260 | 261 | **Performance Analysis** 262 | 263 | ``` 264 | Analyze my Binance account (bybit_main) trading records for the last 7 days and show me the win rate, average profit, and maximum consecutive losses. 265 | ``` 266 | 267 | **Detailed Trading Analytics** 268 | 269 | ``` 270 | Analyze my trading performance on the bybit_futures account for BTC/USDT over the last 30 days. Calculate win rate, profit factor, and identify any patterns in my winning trades. 271 | ``` 272 | 273 | ``` 274 | Show me the monthly returns for my bybit_main account over the past 90 days and identify my best and worst trading months. 275 | ``` 276 | 277 | ``` 278 | Analyze my consecutive wins and losses on my bybit_futures account and tell me if I have any psychological patterns affecting my trading after losses. 279 | ``` 280 | 281 | ## Development 282 | 283 | ### Building from Source 284 | 285 | ```bash 286 | # Clone repository 287 | git clone https://github.com/lazy-dinosaur/ccxt-mcp.git 288 | 289 | # Navigate to project directory 290 | cd ccxt-mcp 291 | 292 | # Install dependencies 293 | npm install 294 | 295 | # Build 296 | npm run build 297 | ``` 298 | 299 | ## 🤝 Contributing 300 | 301 | Contributions are welcome! Please feel free to submit a Pull Request. 302 | 303 | ## 📄 License 304 | 305 | Distributed under the MIT License. See the LICENSE file for more information. 306 | 307 | ## ❤️ Support 308 | 309 | If you find this project useful, please consider giving it a ⭐️ on GitHub! 310 | -------------------------------------------------------------------------------- /bin/ccxt-mcp.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | /** 4 | * ccxt-mcp CLI 실행 파일 5 | * 이 파일은 npx로 ccxt-mcp를 실행할 수 있게 해줍니다. 6 | */ 7 | 8 | import { CcxtMcpServer } from "../dist/server.js"; 9 | import { parseArgs } from "node:util"; 10 | 11 | // 명령행 인수 파싱 12 | const options = { 13 | config: { 14 | type: "string", 15 | short: "c", 16 | default: undefined, 17 | }, 18 | help: { 19 | type: "boolean", 20 | short: "h", 21 | default: false, 22 | }, 23 | }; 24 | 25 | try { 26 | const { values } = parseArgs({ options, allowPositionals: false }); 27 | 28 | // 서버 인스턴스 생성 및 시작 29 | const server = new CcxtMcpServer(values.config); 30 | server.start().catch((error) => { 31 | console.error("서버 시작 실패:", error); 32 | process.exit(1); 33 | }); 34 | } catch (error) { 35 | console.error("CCXT MCP 서버 초기화 실패:", error); 36 | process.exit(1); 37 | } 38 | -------------------------------------------------------------------------------- /docs/getting-started.md: -------------------------------------------------------------------------------- 1 | # CCXT MCP 시작하기 2 | 3 | 이 가이드는 CCXT MCP 서버를 설정하고 사용하는 기본적인 방법을 설명합니다. 4 | 5 | ## 설치 6 | 7 | CCXT MCP는 npm을 통해 설치할 수 있습니다: 8 | 9 | ```bash 10 | # 글로벌 설치 11 | npm install -g @lazydino/ccxt-mcp 12 | 13 | # 또는 프로젝트 내 설치 14 | npm install @lazydino/ccxt-mcp 15 | ``` 16 | 17 | ## 설정 18 | 19 | ### 1. 설정 파일 생성 20 | 21 | `ccxt-accounts.json` 파일을 만들어 API 키 및 계정 정보를 저장합니다: 22 | 23 | ```json 24 | { 25 | "accounts": [ 26 | { 27 | "name": "bybit_main", 28 | "exchangeId": "bybit", 29 | "apiKey": "YOUR_API_KEY", 30 | "secret": "YOUR_SECRET_KEY", 31 | "defaultType": "spot" 32 | }, 33 | { 34 | "name": "bybit_futures", 35 | "exchangeId": "bybit", 36 | "apiKey": "YOUR_API_KEY", 37 | "secret": "YOUR_SECRET_KEY", 38 | "defaultType": "swap" 39 | } 40 | ] 41 | } 42 | ``` 43 | 44 | ### 2. 서버 실행 45 | 46 | ```bash 47 | # 기본 설정으로 실행 48 | ccxt-mcp 49 | 50 | # 또는 사용자 지정 설정 파일 사용 51 | ccxt-mcp --config /path/to/ccxt-accounts.json 52 | ``` 53 | 54 | ### 3. Claude Desktop에 등록 55 | 56 | 1. Claude Desktop 설정 메뉴 열기 57 | 2. MCP Servers 섹션 찾기 58 | 3. 새 서버 추가: 59 | - 서버 이름: `ccxt-mcp` 60 | - 명령어: `npx @lazydino/ccxt-mcp` 61 | - 추가 인수 (선택사항): `--config /path/to/ccxt-accounts.json` 62 | 4. 저장 및 연결 테스트 63 | 64 | ## 기본 사용법 65 | 66 | ### 시세 확인 67 | 68 | ``` 69 | 비트코인 현재 가격을 binance와 coinbase에서 조회하고 비교해줘. 70 | ``` 71 | 72 | ### 계정 조회 73 | 74 | ``` 75 | 내 bybit_main 계정의 잔액을 보여줘. 76 | ``` 77 | 78 | ### 주문 생성 79 | 80 | ``` 81 | 내 bybit_main 계정에서 BTC/USDT 시장에 100 USDT 상당의 비트코인을 시장가로 구매해줘. 82 | ``` 83 | 84 | ### 고급 기능 사용 85 | 86 | ``` 87 | 내 bybit_futures 계정에서 BTC/USDT 선물 시장에 자본의 5%로 10배 레버리지를 사용해 롱 포지션을 열어줘. 88 | 최근 10개 5분봉 중 저점에 손절을 설정해. 89 | ``` 90 | 91 | ## 주요 기능 92 | 93 | ### 시장 정보 94 | 95 | - `fetchMarkets`: 거래소의 사용 가능한 시장 목록 조회 96 | - `fetchTicker`: 특정 심볼의 최신 가격 정보 조회 97 | - `fetchTickers`: 모든 심볼의 가격 정보 조회 98 | - `fetchOrderBook`: 주문장 조회 99 | - `fetchTrades`: 최근 거래 내역 조회 100 | - `fetchOHLCV`: 캔들스틱(OHLCV) 데이터 조회 101 | 102 | ### 계정 및 거래 103 | 104 | - `fetchBalance`: 계정 잔액 조회 105 | - `createOrder`: 주문 생성 106 | - `cancelOrder`: 주문 취소 107 | - `fetchOrder`: 특정 주문 정보 조회 108 | - `fetchOpenOrders`: 미체결 주문 조회 109 | - `fetchClosedOrders`: 체결된 주문 조회 110 | - `fetchMyTrades`: 내 거래 내역 조회 111 | 112 | ## 예제 113 | 114 | 더 많은 예제는 `examples` 디렉토리에서 찾을 수 있습니다: 115 | 116 | - `simple_price_check.js`: 기본적인 가격 조회 예제 117 | - `trading_example.js`: 거래 주문 생성 예제 118 | 119 | ## 문제 해결 120 | 121 | ### 일반적인 오류 122 | 123 | - **연결 오류**: MCP 서버가 실행 중인지 확인하세요 124 | - **인증 오류**: API 키와 시크릿이 올바르게 설정되었는지 확인하세요 125 | - **주문 오류**: 충분한 잔액이 있는지, 주문 형식이 올바른지 확인하세요 126 | 127 | ### 로그 확인 128 | 129 | 문제 해결을 위해 서버 로그를 확인하세요: 130 | 131 | ```bash 132 | ccxt-mcp --verbose 133 | ``` 134 | -------------------------------------------------------------------------------- /examples/config-example.json: -------------------------------------------------------------------------------- 1 | { 2 | "accounts": [ 3 | { 4 | "name": "bybit_main", 5 | "exchangeId": "bybit", 6 | "apiKey": "YOUR_API_KEY", 7 | "secret": "YOUR_SECRET_KEY", 8 | "defaultType": "spot" 9 | }, 10 | { 11 | "name": "bybit_futures", 12 | "exchangeId": "bybit", 13 | "apiKey": "YOUR_API_KEY", 14 | "secret": "YOUR_SECRET_KEY", 15 | "defaultType": "swap" 16 | } 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ccxt-mcp", 3 | "version": "0.4.0", 4 | "lockfileVersion": 3, 5 | "requires": true, 6 | "packages": { 7 | "": { 8 | "name": "ccxt-mcp", 9 | "version": "0.4.0", 10 | "license": "MIT", 11 | "dependencies": { 12 | "@modelcontextprotocol/sdk": "^1.8.0", 13 | "ccxt": "^4.4.0", 14 | "zod": "^3.23.8", 15 | "zod-to-json-schema": "^3.24.1" 16 | }, 17 | "devDependencies": { 18 | "@types/node": "^20.17.28", 19 | "tsx": "^4.7.0", 20 | "typescript": "^5.5.0" 21 | }, 22 | "engines": { 23 | "node": ">=18.0.0" 24 | } 25 | }, 26 | "node_modules/@esbuild/linux-x64": { 27 | "version": "0.25.1", 28 | "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.25.1.tgz", 29 | "integrity": "sha512-xbfUhu/gnvSEg+EGovRc+kjBAkrvtk38RlerAzQxvMzlB4fXpCFCeUAYzJvrnhFtdeyVCDANSjJvOvGYoeKzFA==", 30 | "cpu": [ 31 | "x64" 32 | ], 33 | "dev": true, 34 | "license": "MIT", 35 | "optional": true, 36 | "os": [ 37 | "linux" 38 | ], 39 | "engines": { 40 | "node": ">=18" 41 | } 42 | }, 43 | "node_modules/@modelcontextprotocol/sdk": { 44 | "version": "1.8.0", 45 | "resolved": "https://registry.npmjs.org/@modelcontextprotocol/sdk/-/sdk-1.8.0.tgz", 46 | "integrity": "sha512-e06W7SwrontJDHwCawNO5SGxG+nU9AAx+jpHHZqGl/WrDBdWOpvirC+s58VpJTB5QemI4jTRcjWT4Pt3Q1NPQQ==", 47 | "license": "MIT", 48 | "dependencies": { 49 | "content-type": "^1.0.5", 50 | "cors": "^2.8.5", 51 | "cross-spawn": "^7.0.3", 52 | "eventsource": "^3.0.2", 53 | "express": "^5.0.1", 54 | "express-rate-limit": "^7.5.0", 55 | "pkce-challenge": "^4.1.0", 56 | "raw-body": "^3.0.0", 57 | "zod": "^3.23.8", 58 | "zod-to-json-schema": "^3.24.1" 59 | }, 60 | "engines": { 61 | "node": ">=18" 62 | } 63 | }, 64 | "node_modules/@types/node": { 65 | "version": "20.17.28", 66 | "resolved": "https://registry.npmjs.org/@types/node/-/node-20.17.28.tgz", 67 | "integrity": "sha512-DHlH/fNL6Mho38jTy7/JT7sn2wnXI+wULR6PV4gy4VHLVvnrV/d3pHAMQHhc4gjdLmK2ZiPoMxzp6B3yRajLSQ==", 68 | "dev": true, 69 | "license": "MIT", 70 | "dependencies": { 71 | "undici-types": "~6.19.2" 72 | } 73 | }, 74 | "node_modules/accepts": { 75 | "version": "2.0.0", 76 | "resolved": "https://registry.npmjs.org/accepts/-/accepts-2.0.0.tgz", 77 | "integrity": "sha512-5cvg6CtKwfgdmVqY1WIiXKc3Q1bkRqGLi+2W/6ao+6Y7gu/RCwRuAhGEzh5B4KlszSuTLgZYuqFqo5bImjNKng==", 78 | "license": "MIT", 79 | "dependencies": { 80 | "mime-types": "^3.0.0", 81 | "negotiator": "^1.0.0" 82 | }, 83 | "engines": { 84 | "node": ">= 0.6" 85 | } 86 | }, 87 | "node_modules/atomic-sleep": { 88 | "version": "1.0.0", 89 | "resolved": "https://registry.npmjs.org/atomic-sleep/-/atomic-sleep-1.0.0.tgz", 90 | "integrity": "sha512-kNOjDqAh7px0XWNI+4QbzoiR/nTkHAWNud2uvnJquD1/x5a7EQZMJT0AczqK0Qn67oY/TTQ1LbUKajZpp3I9tQ==", 91 | "license": "MIT", 92 | "engines": { 93 | "node": ">=8.0.0" 94 | } 95 | }, 96 | "node_modules/body-parser": { 97 | "version": "2.2.0", 98 | "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-2.2.0.tgz", 99 | "integrity": "sha512-02qvAaxv8tp7fBa/mw1ga98OGm+eCbqzJOKoRt70sLmfEEi+jyBYVTDGfCL/k06/4EMk/z01gCe7HoCH/f2LTg==", 100 | "license": "MIT", 101 | "dependencies": { 102 | "bytes": "^3.1.2", 103 | "content-type": "^1.0.5", 104 | "debug": "^4.4.0", 105 | "http-errors": "^2.0.0", 106 | "iconv-lite": "^0.6.3", 107 | "on-finished": "^2.4.1", 108 | "qs": "^6.14.0", 109 | "raw-body": "^3.0.0", 110 | "type-is": "^2.0.0" 111 | }, 112 | "engines": { 113 | "node": ">=18" 114 | } 115 | }, 116 | "node_modules/body-parser/node_modules/debug": { 117 | "version": "4.4.0", 118 | "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.0.tgz", 119 | "integrity": "sha512-6WTZ/IxCY/T6BALoZHaE4ctp9xm+Z5kY/pzYaCHRFeyVhojxlrm+46y68HA6hr0TcwEssoxNiDEUJQjfPZ/RYA==", 120 | "license": "MIT", 121 | "dependencies": { 122 | "ms": "^2.1.3" 123 | }, 124 | "engines": { 125 | "node": ">=6.0" 126 | }, 127 | "peerDependenciesMeta": { 128 | "supports-color": { 129 | "optional": true 130 | } 131 | } 132 | }, 133 | "node_modules/body-parser/node_modules/ms": { 134 | "version": "2.1.3", 135 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", 136 | "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", 137 | "license": "MIT" 138 | }, 139 | "node_modules/body-parser/node_modules/qs": { 140 | "version": "6.14.0", 141 | "resolved": "https://registry.npmjs.org/qs/-/qs-6.14.0.tgz", 142 | "integrity": "sha512-YWWTjgABSKcvs/nWBi9PycY/JiPJqOD4JA6o9Sej2AtvSGarXxKC3OQSk4pAarbdQlKAh5D4FCQkJNkW+GAn3w==", 143 | "license": "BSD-3-Clause", 144 | "dependencies": { 145 | "side-channel": "^1.1.0" 146 | }, 147 | "engines": { 148 | "node": ">=0.6" 149 | }, 150 | "funding": { 151 | "url": "https://github.com/sponsors/ljharb" 152 | } 153 | }, 154 | "node_modules/bytes": { 155 | "version": "3.1.2", 156 | "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", 157 | "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==", 158 | "license": "MIT", 159 | "engines": { 160 | "node": ">= 0.8" 161 | } 162 | }, 163 | "node_modules/call-bind-apply-helpers": { 164 | "version": "1.0.2", 165 | "resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz", 166 | "integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==", 167 | "license": "MIT", 168 | "dependencies": { 169 | "es-errors": "^1.3.0", 170 | "function-bind": "^1.1.2" 171 | }, 172 | "engines": { 173 | "node": ">= 0.4" 174 | } 175 | }, 176 | "node_modules/call-bound": { 177 | "version": "1.0.4", 178 | "resolved": "https://registry.npmjs.org/call-bound/-/call-bound-1.0.4.tgz", 179 | "integrity": "sha512-+ys997U96po4Kx/ABpBCqhA9EuxJaQWDQg7295H4hBphv3IZg0boBKuwYpt4YXp6MZ5AmZQnU/tyMTlRpaSejg==", 180 | "license": "MIT", 181 | "dependencies": { 182 | "call-bind-apply-helpers": "^1.0.2", 183 | "get-intrinsic": "^1.3.0" 184 | }, 185 | "engines": { 186 | "node": ">= 0.4" 187 | }, 188 | "funding": { 189 | "url": "https://github.com/sponsors/ljharb" 190 | } 191 | }, 192 | "node_modules/ccxt": { 193 | "version": "4.4.70", 194 | "resolved": "https://registry.npmjs.org/ccxt/-/ccxt-4.4.70.tgz", 195 | "integrity": "sha512-XfFxcTmCFULyRMuf8uVjhywlGXXjoSkzwArfNDe/oEWNTHTT2dRARNfT5FvcGFTCItTCpXliUGZR4Keux0VZOQ==", 196 | "hasInstallScript": true, 197 | "license": "MIT", 198 | "dependencies": { 199 | "ws": "^8.8.1" 200 | }, 201 | "bin": { 202 | "ccxt": "examples/js/cli.js" 203 | }, 204 | "engines": { 205 | "node": ">=15.0.0" 206 | } 207 | }, 208 | "node_modules/colorette": { 209 | "version": "2.0.20", 210 | "resolved": "https://registry.npmjs.org/colorette/-/colorette-2.0.20.tgz", 211 | "integrity": "sha512-IfEDxwoWIjkeXL1eXcDiow4UbKjhLdq6/EuSVR9GMN7KVH3r9gQ83e73hsz1Nd1T3ijd5xv1wcWRYO+D6kCI2w==", 212 | "license": "MIT" 213 | }, 214 | "node_modules/content-disposition": { 215 | "version": "1.0.0", 216 | "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-1.0.0.tgz", 217 | "integrity": "sha512-Au9nRL8VNUut/XSzbQA38+M78dzP4D+eqg3gfJHMIHHYa3bg067xj1KxMUWj+VULbiZMowKngFFbKczUrNJ1mg==", 218 | "license": "MIT", 219 | "dependencies": { 220 | "safe-buffer": "5.2.1" 221 | }, 222 | "engines": { 223 | "node": ">= 0.6" 224 | } 225 | }, 226 | "node_modules/content-type": { 227 | "version": "1.0.5", 228 | "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz", 229 | "integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==", 230 | "license": "MIT", 231 | "engines": { 232 | "node": ">= 0.6" 233 | } 234 | }, 235 | "node_modules/cookie": { 236 | "version": "0.7.1", 237 | "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.1.tgz", 238 | "integrity": "sha512-6DnInpx7SJ2AK3+CTUE/ZM0vWTUboZCegxhC2xiIydHR9jNuTAASBrfEpHhiGOZw/nX51bHt6YQl8jsGo4y/0w==", 239 | "license": "MIT", 240 | "engines": { 241 | "node": ">= 0.6" 242 | } 243 | }, 244 | "node_modules/cookie-signature": { 245 | "version": "1.2.2", 246 | "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.2.2.tgz", 247 | "integrity": "sha512-D76uU73ulSXrD1UXF4KE2TMxVVwhsnCgfAyTg9k8P6KGZjlXKrOLe4dJQKI3Bxi5wjesZoFXJWElNWBjPZMbhg==", 248 | "license": "MIT", 249 | "engines": { 250 | "node": ">=6.6.0" 251 | } 252 | }, 253 | "node_modules/cors": { 254 | "version": "2.8.5", 255 | "resolved": "https://registry.npmjs.org/cors/-/cors-2.8.5.tgz", 256 | "integrity": "sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==", 257 | "license": "MIT", 258 | "dependencies": { 259 | "object-assign": "^4", 260 | "vary": "^1" 261 | }, 262 | "engines": { 263 | "node": ">= 0.10" 264 | } 265 | }, 266 | "node_modules/cross-spawn": { 267 | "version": "7.0.6", 268 | "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", 269 | "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==", 270 | "license": "MIT", 271 | "dependencies": { 272 | "path-key": "^3.1.0", 273 | "shebang-command": "^2.0.0", 274 | "which": "^2.0.1" 275 | }, 276 | "engines": { 277 | "node": ">= 8" 278 | } 279 | }, 280 | "node_modules/dateformat": { 281 | "version": "4.6.3", 282 | "resolved": "https://registry.npmjs.org/dateformat/-/dateformat-4.6.3.tgz", 283 | "integrity": "sha512-2P0p0pFGzHS5EMnhdxQi7aJN+iMheud0UhG4dlE1DLAlvL8JHjJJTX/CSm4JXwV0Ka5nGk3zC5mcb5bUQUxxMA==", 284 | "license": "MIT", 285 | "engines": { 286 | "node": "*" 287 | } 288 | }, 289 | "node_modules/debug": { 290 | "version": "4.3.6", 291 | "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.6.tgz", 292 | "integrity": "sha512-O/09Bd4Z1fBrU4VzkhFqVgpPzaGbw6Sm9FEkBT1A/YBXQFGuuSxa1dN2nxgxS34JmKXqYx8CZAwEVoJFImUXIg==", 293 | "license": "MIT", 294 | "dependencies": { 295 | "ms": "2.1.2" 296 | }, 297 | "engines": { 298 | "node": ">=6.0" 299 | }, 300 | "peerDependenciesMeta": { 301 | "supports-color": { 302 | "optional": true 303 | } 304 | } 305 | }, 306 | "node_modules/depd": { 307 | "version": "2.0.0", 308 | "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", 309 | "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==", 310 | "license": "MIT", 311 | "engines": { 312 | "node": ">= 0.8" 313 | } 314 | }, 315 | "node_modules/dunder-proto": { 316 | "version": "1.0.1", 317 | "resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz", 318 | "integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==", 319 | "license": "MIT", 320 | "dependencies": { 321 | "call-bind-apply-helpers": "^1.0.1", 322 | "es-errors": "^1.3.0", 323 | "gopd": "^1.2.0" 324 | }, 325 | "engines": { 326 | "node": ">= 0.4" 327 | } 328 | }, 329 | "node_modules/ee-first": { 330 | "version": "1.1.1", 331 | "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", 332 | "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==", 333 | "license": "MIT" 334 | }, 335 | "node_modules/encodeurl": { 336 | "version": "2.0.0", 337 | "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.0.tgz", 338 | "integrity": "sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg==", 339 | "license": "MIT", 340 | "engines": { 341 | "node": ">= 0.8" 342 | } 343 | }, 344 | "node_modules/end-of-stream": { 345 | "version": "1.4.4", 346 | "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz", 347 | "integrity": "sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==", 348 | "license": "MIT", 349 | "dependencies": { 350 | "once": "^1.4.0" 351 | } 352 | }, 353 | "node_modules/es-define-property": { 354 | "version": "1.0.1", 355 | "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz", 356 | "integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==", 357 | "license": "MIT", 358 | "engines": { 359 | "node": ">= 0.4" 360 | } 361 | }, 362 | "node_modules/es-errors": { 363 | "version": "1.3.0", 364 | "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz", 365 | "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==", 366 | "license": "MIT", 367 | "engines": { 368 | "node": ">= 0.4" 369 | } 370 | }, 371 | "node_modules/es-object-atoms": { 372 | "version": "1.1.1", 373 | "resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.1.tgz", 374 | "integrity": "sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA==", 375 | "license": "MIT", 376 | "dependencies": { 377 | "es-errors": "^1.3.0" 378 | }, 379 | "engines": { 380 | "node": ">= 0.4" 381 | } 382 | }, 383 | "node_modules/esbuild": { 384 | "version": "0.25.1", 385 | "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.25.1.tgz", 386 | "integrity": "sha512-BGO5LtrGC7vxnqucAe/rmvKdJllfGaYWdyABvyMoXQlfYMb2bbRuReWR5tEGE//4LcNJj9XrkovTqNYRFZHAMQ==", 387 | "dev": true, 388 | "hasInstallScript": true, 389 | "license": "MIT", 390 | "bin": { 391 | "esbuild": "bin/esbuild" 392 | }, 393 | "engines": { 394 | "node": ">=18" 395 | }, 396 | "optionalDependencies": { 397 | "@esbuild/aix-ppc64": "0.25.1", 398 | "@esbuild/android-arm": "0.25.1", 399 | "@esbuild/android-arm64": "0.25.1", 400 | "@esbuild/android-x64": "0.25.1", 401 | "@esbuild/darwin-arm64": "0.25.1", 402 | "@esbuild/darwin-x64": "0.25.1", 403 | "@esbuild/freebsd-arm64": "0.25.1", 404 | "@esbuild/freebsd-x64": "0.25.1", 405 | "@esbuild/linux-arm": "0.25.1", 406 | "@esbuild/linux-arm64": "0.25.1", 407 | "@esbuild/linux-ia32": "0.25.1", 408 | "@esbuild/linux-loong64": "0.25.1", 409 | "@esbuild/linux-mips64el": "0.25.1", 410 | "@esbuild/linux-ppc64": "0.25.1", 411 | "@esbuild/linux-riscv64": "0.25.1", 412 | "@esbuild/linux-s390x": "0.25.1", 413 | "@esbuild/linux-x64": "0.25.1", 414 | "@esbuild/netbsd-arm64": "0.25.1", 415 | "@esbuild/netbsd-x64": "0.25.1", 416 | "@esbuild/openbsd-arm64": "0.25.1", 417 | "@esbuild/openbsd-x64": "0.25.1", 418 | "@esbuild/sunos-x64": "0.25.1", 419 | "@esbuild/win32-arm64": "0.25.1", 420 | "@esbuild/win32-ia32": "0.25.1", 421 | "@esbuild/win32-x64": "0.25.1" 422 | } 423 | }, 424 | "node_modules/escape-html": { 425 | "version": "1.0.3", 426 | "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", 427 | "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==", 428 | "license": "MIT" 429 | }, 430 | "node_modules/etag": { 431 | "version": "1.8.1", 432 | "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", 433 | "integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==", 434 | "license": "MIT", 435 | "engines": { 436 | "node": ">= 0.6" 437 | } 438 | }, 439 | "node_modules/eventsource": { 440 | "version": "3.0.6", 441 | "resolved": "https://registry.npmjs.org/eventsource/-/eventsource-3.0.6.tgz", 442 | "integrity": "sha512-l19WpE2m9hSuyP06+FbuUUf1G+R0SFLrtQfbRb9PRr+oimOfxQhgGCbVaXg5IvZyyTThJsxh6L/srkMiCeBPDA==", 443 | "license": "MIT", 444 | "dependencies": { 445 | "eventsource-parser": "^3.0.1" 446 | }, 447 | "engines": { 448 | "node": ">=18.0.0" 449 | } 450 | }, 451 | "node_modules/eventsource-parser": { 452 | "version": "3.0.1", 453 | "resolved": "https://registry.npmjs.org/eventsource-parser/-/eventsource-parser-3.0.1.tgz", 454 | "integrity": "sha512-VARTJ9CYeuQYb0pZEPbzi740OWFgpHe7AYJ2WFZVnUDUQp5Dk2yJUgF36YsZ81cOyxT0QxmXD2EQpapAouzWVA==", 455 | "license": "MIT", 456 | "engines": { 457 | "node": ">=18.0.0" 458 | } 459 | }, 460 | "node_modules/express": { 461 | "version": "5.0.1", 462 | "resolved": "https://registry.npmjs.org/express/-/express-5.0.1.tgz", 463 | "integrity": "sha512-ORF7g6qGnD+YtUG9yx4DFoqCShNMmUKiXuT5oWMHiOvt/4WFbHC6yCwQMTSBMno7AqntNCAzzcnnjowRkTL9eQ==", 464 | "license": "MIT", 465 | "dependencies": { 466 | "accepts": "^2.0.0", 467 | "body-parser": "^2.0.1", 468 | "content-disposition": "^1.0.0", 469 | "content-type": "~1.0.4", 470 | "cookie": "0.7.1", 471 | "cookie-signature": "^1.2.1", 472 | "debug": "4.3.6", 473 | "depd": "2.0.0", 474 | "encodeurl": "~2.0.0", 475 | "escape-html": "~1.0.3", 476 | "etag": "~1.8.1", 477 | "finalhandler": "^2.0.0", 478 | "fresh": "2.0.0", 479 | "http-errors": "2.0.0", 480 | "merge-descriptors": "^2.0.0", 481 | "methods": "~1.1.2", 482 | "mime-types": "^3.0.0", 483 | "on-finished": "2.4.1", 484 | "once": "1.4.0", 485 | "parseurl": "~1.3.3", 486 | "proxy-addr": "~2.0.7", 487 | "qs": "6.13.0", 488 | "range-parser": "~1.2.1", 489 | "router": "^2.0.0", 490 | "safe-buffer": "5.2.1", 491 | "send": "^1.1.0", 492 | "serve-static": "^2.1.0", 493 | "setprototypeof": "1.2.0", 494 | "statuses": "2.0.1", 495 | "type-is": "^2.0.0", 496 | "utils-merge": "1.0.1", 497 | "vary": "~1.1.2" 498 | }, 499 | "engines": { 500 | "node": ">= 18" 501 | } 502 | }, 503 | "node_modules/express-rate-limit": { 504 | "version": "7.5.0", 505 | "resolved": "https://registry.npmjs.org/express-rate-limit/-/express-rate-limit-7.5.0.tgz", 506 | "integrity": "sha512-eB5zbQh5h+VenMPM3fh+nw1YExi5nMr6HUCR62ELSP11huvxm/Uir1H1QEyTkk5QX6A58pX6NmaTMceKZ0Eodg==", 507 | "license": "MIT", 508 | "engines": { 509 | "node": ">= 16" 510 | }, 511 | "funding": { 512 | "url": "https://github.com/sponsors/express-rate-limit" 513 | }, 514 | "peerDependencies": { 515 | "express": "^4.11 || 5 || ^5.0.0-beta.1" 516 | } 517 | }, 518 | "node_modules/fast-copy": { 519 | "version": "3.0.2", 520 | "resolved": "https://registry.npmjs.org/fast-copy/-/fast-copy-3.0.2.tgz", 521 | "integrity": "sha512-dl0O9Vhju8IrcLndv2eU4ldt1ftXMqqfgN4H1cpmGV7P6jeB9FwpN9a2c8DPGE1Ys88rNUJVYDHq73CGAGOPfQ==", 522 | "license": "MIT" 523 | }, 524 | "node_modules/fast-redact": { 525 | "version": "3.5.0", 526 | "resolved": "https://registry.npmjs.org/fast-redact/-/fast-redact-3.5.0.tgz", 527 | "integrity": "sha512-dwsoQlS7h9hMeYUq1W++23NDcBLV4KqONnITDV9DjfS3q1SgDGVrBdvvTLUotWtPSD7asWDV9/CmsZPy8Hf70A==", 528 | "license": "MIT", 529 | "engines": { 530 | "node": ">=6" 531 | } 532 | }, 533 | "node_modules/fast-safe-stringify": { 534 | "version": "2.1.1", 535 | "resolved": "https://registry.npmjs.org/fast-safe-stringify/-/fast-safe-stringify-2.1.1.tgz", 536 | "integrity": "sha512-W+KJc2dmILlPplD/H4K9l9LcAHAfPtP6BY84uVLXQ6Evcz9Lcg33Y2z1IVblT6xdY54PXYVHEv+0Wpq8Io6zkA==", 537 | "license": "MIT" 538 | }, 539 | "node_modules/finalhandler": { 540 | "version": "2.1.0", 541 | "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-2.1.0.tgz", 542 | "integrity": "sha512-/t88Ty3d5JWQbWYgaOGCCYfXRwV1+be02WqYYlL6h0lEiUAMPM8o8qKGO01YIkOHzka2up08wvgYD0mDiI+q3Q==", 543 | "license": "MIT", 544 | "dependencies": { 545 | "debug": "^4.4.0", 546 | "encodeurl": "^2.0.0", 547 | "escape-html": "^1.0.3", 548 | "on-finished": "^2.4.1", 549 | "parseurl": "^1.3.3", 550 | "statuses": "^2.0.1" 551 | }, 552 | "engines": { 553 | "node": ">= 0.8" 554 | } 555 | }, 556 | "node_modules/finalhandler/node_modules/debug": { 557 | "version": "4.4.0", 558 | "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.0.tgz", 559 | "integrity": "sha512-6WTZ/IxCY/T6BALoZHaE4ctp9xm+Z5kY/pzYaCHRFeyVhojxlrm+46y68HA6hr0TcwEssoxNiDEUJQjfPZ/RYA==", 560 | "license": "MIT", 561 | "dependencies": { 562 | "ms": "^2.1.3" 563 | }, 564 | "engines": { 565 | "node": ">=6.0" 566 | }, 567 | "peerDependenciesMeta": { 568 | "supports-color": { 569 | "optional": true 570 | } 571 | } 572 | }, 573 | "node_modules/finalhandler/node_modules/ms": { 574 | "version": "2.1.3", 575 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", 576 | "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", 577 | "license": "MIT" 578 | }, 579 | "node_modules/forwarded": { 580 | "version": "0.2.0", 581 | "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz", 582 | "integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==", 583 | "license": "MIT", 584 | "engines": { 585 | "node": ">= 0.6" 586 | } 587 | }, 588 | "node_modules/fresh": { 589 | "version": "2.0.0", 590 | "resolved": "https://registry.npmjs.org/fresh/-/fresh-2.0.0.tgz", 591 | "integrity": "sha512-Rx/WycZ60HOaqLKAi6cHRKKI7zxWbJ31MhntmtwMoaTeF7XFH9hhBp8vITaMidfljRQ6eYWCKkaTK+ykVJHP2A==", 592 | "license": "MIT", 593 | "engines": { 594 | "node": ">= 0.8" 595 | } 596 | }, 597 | "node_modules/function-bind": { 598 | "version": "1.1.2", 599 | "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", 600 | "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", 601 | "license": "MIT", 602 | "funding": { 603 | "url": "https://github.com/sponsors/ljharb" 604 | } 605 | }, 606 | "node_modules/get-intrinsic": { 607 | "version": "1.3.0", 608 | "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz", 609 | "integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==", 610 | "license": "MIT", 611 | "dependencies": { 612 | "call-bind-apply-helpers": "^1.0.2", 613 | "es-define-property": "^1.0.1", 614 | "es-errors": "^1.3.0", 615 | "es-object-atoms": "^1.1.1", 616 | "function-bind": "^1.1.2", 617 | "get-proto": "^1.0.1", 618 | "gopd": "^1.2.0", 619 | "has-symbols": "^1.1.0", 620 | "hasown": "^2.0.2", 621 | "math-intrinsics": "^1.1.0" 622 | }, 623 | "engines": { 624 | "node": ">= 0.4" 625 | }, 626 | "funding": { 627 | "url": "https://github.com/sponsors/ljharb" 628 | } 629 | }, 630 | "node_modules/get-proto": { 631 | "version": "1.0.1", 632 | "resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz", 633 | "integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==", 634 | "license": "MIT", 635 | "dependencies": { 636 | "dunder-proto": "^1.0.1", 637 | "es-object-atoms": "^1.0.0" 638 | }, 639 | "engines": { 640 | "node": ">= 0.4" 641 | } 642 | }, 643 | "node_modules/get-tsconfig": { 644 | "version": "4.10.0", 645 | "resolved": "https://registry.npmjs.org/get-tsconfig/-/get-tsconfig-4.10.0.tgz", 646 | "integrity": "sha512-kGzZ3LWWQcGIAmg6iWvXn0ei6WDtV26wzHRMwDSzmAbcXrTEXxHy6IehI6/4eT6VRKyMP1eF1VqwrVUmE/LR7A==", 647 | "dev": true, 648 | "license": "MIT", 649 | "dependencies": { 650 | "resolve-pkg-maps": "^1.0.0" 651 | }, 652 | "funding": { 653 | "url": "https://github.com/privatenumber/get-tsconfig?sponsor=1" 654 | } 655 | }, 656 | "node_modules/gopd": { 657 | "version": "1.2.0", 658 | "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz", 659 | "integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==", 660 | "license": "MIT", 661 | "engines": { 662 | "node": ">= 0.4" 663 | }, 664 | "funding": { 665 | "url": "https://github.com/sponsors/ljharb" 666 | } 667 | }, 668 | "node_modules/has-symbols": { 669 | "version": "1.1.0", 670 | "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz", 671 | "integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==", 672 | "license": "MIT", 673 | "engines": { 674 | "node": ">= 0.4" 675 | }, 676 | "funding": { 677 | "url": "https://github.com/sponsors/ljharb" 678 | } 679 | }, 680 | "node_modules/hasown": { 681 | "version": "2.0.2", 682 | "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz", 683 | "integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==", 684 | "license": "MIT", 685 | "dependencies": { 686 | "function-bind": "^1.1.2" 687 | }, 688 | "engines": { 689 | "node": ">= 0.4" 690 | } 691 | }, 692 | "node_modules/help-me": { 693 | "version": "5.0.0", 694 | "resolved": "https://registry.npmjs.org/help-me/-/help-me-5.0.0.tgz", 695 | "integrity": "sha512-7xgomUX6ADmcYzFik0HzAxh/73YlKR9bmFzf51CZwR+b6YtzU2m0u49hQCqV6SvlqIqsaxovfwdvbnsw3b/zpg==", 696 | "license": "MIT" 697 | }, 698 | "node_modules/http-errors": { 699 | "version": "2.0.0", 700 | "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.0.tgz", 701 | "integrity": "sha512-FtwrG/euBzaEjYeRqOgly7G0qviiXoJWnvEH2Z1plBdXgbyjv34pHTSb9zoeHMyDy33+DWy5Wt9Wo+TURtOYSQ==", 702 | "license": "MIT", 703 | "dependencies": { 704 | "depd": "2.0.0", 705 | "inherits": "2.0.4", 706 | "setprototypeof": "1.2.0", 707 | "statuses": "2.0.1", 708 | "toidentifier": "1.0.1" 709 | }, 710 | "engines": { 711 | "node": ">= 0.8" 712 | } 713 | }, 714 | "node_modules/iconv-lite": { 715 | "version": "0.6.3", 716 | "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz", 717 | "integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==", 718 | "license": "MIT", 719 | "dependencies": { 720 | "safer-buffer": ">= 2.1.2 < 3.0.0" 721 | }, 722 | "engines": { 723 | "node": ">=0.10.0" 724 | } 725 | }, 726 | "node_modules/inherits": { 727 | "version": "2.0.4", 728 | "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", 729 | "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", 730 | "license": "ISC" 731 | }, 732 | "node_modules/ipaddr.js": { 733 | "version": "1.9.1", 734 | "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz", 735 | "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==", 736 | "license": "MIT", 737 | "engines": { 738 | "node": ">= 0.10" 739 | } 740 | }, 741 | "node_modules/is-promise": { 742 | "version": "4.0.0", 743 | "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-4.0.0.tgz", 744 | "integrity": "sha512-hvpoI6korhJMnej285dSg6nu1+e6uxs7zG3BYAm5byqDsgJNWwxzM6z6iZiAgQR4TJ30JmBTOwqZUw3WlyH3AQ==", 745 | "license": "MIT" 746 | }, 747 | "node_modules/isexe": { 748 | "version": "2.0.0", 749 | "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", 750 | "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", 751 | "license": "ISC" 752 | }, 753 | "node_modules/joycon": { 754 | "version": "3.1.1", 755 | "resolved": "https://registry.npmjs.org/joycon/-/joycon-3.1.1.tgz", 756 | "integrity": "sha512-34wB/Y7MW7bzjKRjUKTa46I2Z7eV62Rkhva+KkopW7Qvv/OSWBqvkSY7vusOPrNuZcUG3tApvdVgNB8POj3SPw==", 757 | "license": "MIT", 758 | "engines": { 759 | "node": ">=10" 760 | } 761 | }, 762 | "node_modules/math-intrinsics": { 763 | "version": "1.1.0", 764 | "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz", 765 | "integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==", 766 | "license": "MIT", 767 | "engines": { 768 | "node": ">= 0.4" 769 | } 770 | }, 771 | "node_modules/media-typer": { 772 | "version": "1.1.0", 773 | "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-1.1.0.tgz", 774 | "integrity": "sha512-aisnrDP4GNe06UcKFnV5bfMNPBUw4jsLGaWwWfnH3v02GnBuXX2MCVn5RbrWo0j3pczUilYblq7fQ7Nw2t5XKw==", 775 | "license": "MIT", 776 | "engines": { 777 | "node": ">= 0.8" 778 | } 779 | }, 780 | "node_modules/merge-descriptors": { 781 | "version": "2.0.0", 782 | "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-2.0.0.tgz", 783 | "integrity": "sha512-Snk314V5ayFLhp3fkUREub6WtjBfPdCPY1Ln8/8munuLuiYhsABgBVWsozAG+MWMbVEvcdcpbi9R7ww22l9Q3g==", 784 | "license": "MIT", 785 | "engines": { 786 | "node": ">=18" 787 | }, 788 | "funding": { 789 | "url": "https://github.com/sponsors/sindresorhus" 790 | } 791 | }, 792 | "node_modules/methods": { 793 | "version": "1.1.2", 794 | "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", 795 | "integrity": "sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w==", 796 | "license": "MIT", 797 | "engines": { 798 | "node": ">= 0.6" 799 | } 800 | }, 801 | "node_modules/mime-db": { 802 | "version": "1.54.0", 803 | "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.54.0.tgz", 804 | "integrity": "sha512-aU5EJuIN2WDemCcAp2vFBfp/m4EAhWJnUNSSw0ixs7/kXbd6Pg64EmwJkNdFhB8aWt1sH2CTXrLxo/iAGV3oPQ==", 805 | "license": "MIT", 806 | "engines": { 807 | "node": ">= 0.6" 808 | } 809 | }, 810 | "node_modules/mime-types": { 811 | "version": "3.0.1", 812 | "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-3.0.1.tgz", 813 | "integrity": "sha512-xRc4oEhT6eaBpU1XF7AjpOFD+xQmXNB5OVKwp4tqCuBpHLS/ZbBDrc07mYTDqVMg6PfxUjjNp85O6Cd2Z/5HWA==", 814 | "license": "MIT", 815 | "dependencies": { 816 | "mime-db": "^1.54.0" 817 | }, 818 | "engines": { 819 | "node": ">= 0.6" 820 | } 821 | }, 822 | "node_modules/minimist": { 823 | "version": "1.2.8", 824 | "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", 825 | "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==", 826 | "license": "MIT", 827 | "funding": { 828 | "url": "https://github.com/sponsors/ljharb" 829 | } 830 | }, 831 | "node_modules/ms": { 832 | "version": "2.1.2", 833 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", 834 | "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", 835 | "license": "MIT" 836 | }, 837 | "node_modules/negotiator": { 838 | "version": "1.0.0", 839 | "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-1.0.0.tgz", 840 | "integrity": "sha512-8Ofs/AUQh8MaEcrlq5xOX0CQ9ypTF5dl78mjlMNfOK08fzpgTHQRQPBxcPlEtIw0yRpws+Zo/3r+5WRby7u3Gg==", 841 | "license": "MIT", 842 | "engines": { 843 | "node": ">= 0.6" 844 | } 845 | }, 846 | "node_modules/object-assign": { 847 | "version": "4.1.1", 848 | "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", 849 | "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==", 850 | "license": "MIT", 851 | "engines": { 852 | "node": ">=0.10.0" 853 | } 854 | }, 855 | "node_modules/object-inspect": { 856 | "version": "1.13.4", 857 | "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.4.tgz", 858 | "integrity": "sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew==", 859 | "license": "MIT", 860 | "engines": { 861 | "node": ">= 0.4" 862 | }, 863 | "funding": { 864 | "url": "https://github.com/sponsors/ljharb" 865 | } 866 | }, 867 | "node_modules/on-exit-leak-free": { 868 | "version": "2.1.2", 869 | "resolved": "https://registry.npmjs.org/on-exit-leak-free/-/on-exit-leak-free-2.1.2.tgz", 870 | "integrity": "sha512-0eJJY6hXLGf1udHwfNftBqH+g73EU4B504nZeKpz1sYRKafAghwxEJunB2O7rDZkL4PGfsMVnTXZ2EjibbqcsA==", 871 | "license": "MIT", 872 | "engines": { 873 | "node": ">=14.0.0" 874 | } 875 | }, 876 | "node_modules/on-finished": { 877 | "version": "2.4.1", 878 | "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz", 879 | "integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==", 880 | "license": "MIT", 881 | "dependencies": { 882 | "ee-first": "1.1.1" 883 | }, 884 | "engines": { 885 | "node": ">= 0.8" 886 | } 887 | }, 888 | "node_modules/once": { 889 | "version": "1.4.0", 890 | "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", 891 | "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", 892 | "license": "ISC", 893 | "dependencies": { 894 | "wrappy": "1" 895 | } 896 | }, 897 | "node_modules/parseurl": { 898 | "version": "1.3.3", 899 | "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", 900 | "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==", 901 | "license": "MIT", 902 | "engines": { 903 | "node": ">= 0.8" 904 | } 905 | }, 906 | "node_modules/path-key": { 907 | "version": "3.1.1", 908 | "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", 909 | "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", 910 | "license": "MIT", 911 | "engines": { 912 | "node": ">=8" 913 | } 914 | }, 915 | "node_modules/path-to-regexp": { 916 | "version": "8.2.0", 917 | "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-8.2.0.tgz", 918 | "integrity": "sha512-TdrF7fW9Rphjq4RjrW0Kp2AW0Ahwu9sRGTkS6bvDi0SCwZlEZYmcfDbEsTz8RVk0EHIS/Vd1bv3JhG+1xZuAyQ==", 919 | "license": "MIT", 920 | "engines": { 921 | "node": ">=16" 922 | } 923 | }, 924 | "node_modules/pino": { 925 | "version": "9.6.0", 926 | "resolved": "https://registry.npmjs.org/pino/-/pino-9.6.0.tgz", 927 | "integrity": "sha512-i85pKRCt4qMjZ1+L7sy2Ag4t1atFcdbEt76+7iRJn1g2BvsnRMGu9p8pivl9fs63M2kF/A0OacFZhTub+m/qMg==", 928 | "license": "MIT", 929 | "dependencies": { 930 | "atomic-sleep": "^1.0.0", 931 | "fast-redact": "^3.1.1", 932 | "on-exit-leak-free": "^2.1.0", 933 | "pino-abstract-transport": "^2.0.0", 934 | "pino-std-serializers": "^7.0.0", 935 | "process-warning": "^4.0.0", 936 | "quick-format-unescaped": "^4.0.3", 937 | "real-require": "^0.2.0", 938 | "safe-stable-stringify": "^2.3.1", 939 | "sonic-boom": "^4.0.1", 940 | "thread-stream": "^3.0.0" 941 | }, 942 | "bin": { 943 | "pino": "bin.js" 944 | } 945 | }, 946 | "node_modules/pino-abstract-transport": { 947 | "version": "2.0.0", 948 | "resolved": "https://registry.npmjs.org/pino-abstract-transport/-/pino-abstract-transport-2.0.0.tgz", 949 | "integrity": "sha512-F63x5tizV6WCh4R6RHyi2Ml+M70DNRXt/+HANowMflpgGFMAym/VKm6G7ZOQRjqN7XbGxK1Lg9t6ZrtzOaivMw==", 950 | "license": "MIT", 951 | "dependencies": { 952 | "split2": "^4.0.0" 953 | } 954 | }, 955 | "node_modules/pino-pretty": { 956 | "version": "13.0.0", 957 | "resolved": "https://registry.npmjs.org/pino-pretty/-/pino-pretty-13.0.0.tgz", 958 | "integrity": "sha512-cQBBIVG3YajgoUjo1FdKVRX6t9XPxwB9lcNJVD5GCnNM4Y6T12YYx8c6zEejxQsU0wrg9TwmDulcE9LR7qcJqA==", 959 | "license": "MIT", 960 | "dependencies": { 961 | "colorette": "^2.0.7", 962 | "dateformat": "^4.6.3", 963 | "fast-copy": "^3.0.2", 964 | "fast-safe-stringify": "^2.1.1", 965 | "help-me": "^5.0.0", 966 | "joycon": "^3.1.1", 967 | "minimist": "^1.2.6", 968 | "on-exit-leak-free": "^2.1.0", 969 | "pino-abstract-transport": "^2.0.0", 970 | "pump": "^3.0.0", 971 | "secure-json-parse": "^2.4.0", 972 | "sonic-boom": "^4.0.1", 973 | "strip-json-comments": "^3.1.1" 974 | }, 975 | "bin": { 976 | "pino-pretty": "bin.js" 977 | } 978 | }, 979 | "node_modules/pino-std-serializers": { 980 | "version": "7.0.0", 981 | "resolved": "https://registry.npmjs.org/pino-std-serializers/-/pino-std-serializers-7.0.0.tgz", 982 | "integrity": "sha512-e906FRY0+tV27iq4juKzSYPbUj2do2X2JX4EzSca1631EB2QJQUqGbDuERal7LCtOpxl6x3+nvo9NPZcmjkiFA==", 983 | "license": "MIT" 984 | }, 985 | "node_modules/pkce-challenge": { 986 | "version": "4.1.0", 987 | "resolved": "https://registry.npmjs.org/pkce-challenge/-/pkce-challenge-4.1.0.tgz", 988 | "integrity": "sha512-ZBmhE1C9LcPoH9XZSdwiPtbPHZROwAnMy+kIFQVrnMCxY4Cudlz3gBOpzilgc0jOgRaiT3sIWfpMomW2ar2orQ==", 989 | "license": "MIT", 990 | "engines": { 991 | "node": ">=16.20.0" 992 | } 993 | }, 994 | "node_modules/process-warning": { 995 | "version": "4.0.1", 996 | "resolved": "https://registry.npmjs.org/process-warning/-/process-warning-4.0.1.tgz", 997 | "integrity": "sha512-3c2LzQ3rY9d0hc1emcsHhfT9Jwz0cChib/QN89oME2R451w5fy3f0afAhERFZAwrbDU43wk12d0ORBpDVME50Q==", 998 | "funding": [ 999 | { 1000 | "type": "github", 1001 | "url": "https://github.com/sponsors/fastify" 1002 | }, 1003 | { 1004 | "type": "opencollective", 1005 | "url": "https://opencollective.com/fastify" 1006 | } 1007 | ], 1008 | "license": "MIT" 1009 | }, 1010 | "node_modules/proxy-addr": { 1011 | "version": "2.0.7", 1012 | "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz", 1013 | "integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==", 1014 | "license": "MIT", 1015 | "dependencies": { 1016 | "forwarded": "0.2.0", 1017 | "ipaddr.js": "1.9.1" 1018 | }, 1019 | "engines": { 1020 | "node": ">= 0.10" 1021 | } 1022 | }, 1023 | "node_modules/pump": { 1024 | "version": "3.0.2", 1025 | "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.2.tgz", 1026 | "integrity": "sha512-tUPXtzlGM8FE3P0ZL6DVs/3P58k9nk8/jZeQCurTJylQA8qFYzHFfhBJkuqyE0FifOsQ0uKWekiZ5g8wtr28cw==", 1027 | "license": "MIT", 1028 | "dependencies": { 1029 | "end-of-stream": "^1.1.0", 1030 | "once": "^1.3.1" 1031 | } 1032 | }, 1033 | "node_modules/qs": { 1034 | "version": "6.13.0", 1035 | "resolved": "https://registry.npmjs.org/qs/-/qs-6.13.0.tgz", 1036 | "integrity": "sha512-+38qI9SOr8tfZ4QmJNplMUxqjbe7LKvvZgWdExBOmd+egZTtjLB67Gu0HRX3u/XOq7UU2Nx6nsjvS16Z9uwfpg==", 1037 | "license": "BSD-3-Clause", 1038 | "dependencies": { 1039 | "side-channel": "^1.0.6" 1040 | }, 1041 | "engines": { 1042 | "node": ">=0.6" 1043 | }, 1044 | "funding": { 1045 | "url": "https://github.com/sponsors/ljharb" 1046 | } 1047 | }, 1048 | "node_modules/quick-format-unescaped": { 1049 | "version": "4.0.4", 1050 | "resolved": "https://registry.npmjs.org/quick-format-unescaped/-/quick-format-unescaped-4.0.4.tgz", 1051 | "integrity": "sha512-tYC1Q1hgyRuHgloV/YXs2w15unPVh8qfu/qCTfhTYamaw7fyhumKa2yGpdSo87vY32rIclj+4fWYQXUMs9EHvg==", 1052 | "license": "MIT" 1053 | }, 1054 | "node_modules/range-parser": { 1055 | "version": "1.2.1", 1056 | "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", 1057 | "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==", 1058 | "license": "MIT", 1059 | "engines": { 1060 | "node": ">= 0.6" 1061 | } 1062 | }, 1063 | "node_modules/raw-body": { 1064 | "version": "3.0.0", 1065 | "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-3.0.0.tgz", 1066 | "integrity": "sha512-RmkhL8CAyCRPXCE28MMH0z2PNWQBNk2Q09ZdxM9IOOXwxwZbN+qbWaatPkdkWIKL2ZVDImrN/pK5HTRz2PcS4g==", 1067 | "license": "MIT", 1068 | "dependencies": { 1069 | "bytes": "3.1.2", 1070 | "http-errors": "2.0.0", 1071 | "iconv-lite": "0.6.3", 1072 | "unpipe": "1.0.0" 1073 | }, 1074 | "engines": { 1075 | "node": ">= 0.8" 1076 | } 1077 | }, 1078 | "node_modules/real-require": { 1079 | "version": "0.2.0", 1080 | "resolved": "https://registry.npmjs.org/real-require/-/real-require-0.2.0.tgz", 1081 | "integrity": "sha512-57frrGM/OCTLqLOAh0mhVA9VBMHd+9U7Zb2THMGdBUoZVOtGbJzjxsYGDJ3A9AYYCP4hn6y1TVbaOfzWtm5GFg==", 1082 | "license": "MIT", 1083 | "engines": { 1084 | "node": ">= 12.13.0" 1085 | } 1086 | }, 1087 | "node_modules/resolve-pkg-maps": { 1088 | "version": "1.0.0", 1089 | "resolved": "https://registry.npmjs.org/resolve-pkg-maps/-/resolve-pkg-maps-1.0.0.tgz", 1090 | "integrity": "sha512-seS2Tj26TBVOC2NIc2rOe2y2ZO7efxITtLZcGSOnHHNOQ7CkiUBfw0Iw2ck6xkIhPwLhKNLS8BO+hEpngQlqzw==", 1091 | "dev": true, 1092 | "license": "MIT", 1093 | "funding": { 1094 | "url": "https://github.com/privatenumber/resolve-pkg-maps?sponsor=1" 1095 | } 1096 | }, 1097 | "node_modules/router": { 1098 | "version": "2.2.0", 1099 | "resolved": "https://registry.npmjs.org/router/-/router-2.2.0.tgz", 1100 | "integrity": "sha512-nLTrUKm2UyiL7rlhapu/Zl45FwNgkZGaCpZbIHajDYgwlJCOzLSk+cIPAnsEqV955GjILJnKbdQC1nVPz+gAYQ==", 1101 | "license": "MIT", 1102 | "dependencies": { 1103 | "debug": "^4.4.0", 1104 | "depd": "^2.0.0", 1105 | "is-promise": "^4.0.0", 1106 | "parseurl": "^1.3.3", 1107 | "path-to-regexp": "^8.0.0" 1108 | }, 1109 | "engines": { 1110 | "node": ">= 18" 1111 | } 1112 | }, 1113 | "node_modules/router/node_modules/debug": { 1114 | "version": "4.4.0", 1115 | "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.0.tgz", 1116 | "integrity": "sha512-6WTZ/IxCY/T6BALoZHaE4ctp9xm+Z5kY/pzYaCHRFeyVhojxlrm+46y68HA6hr0TcwEssoxNiDEUJQjfPZ/RYA==", 1117 | "license": "MIT", 1118 | "dependencies": { 1119 | "ms": "^2.1.3" 1120 | }, 1121 | "engines": { 1122 | "node": ">=6.0" 1123 | }, 1124 | "peerDependenciesMeta": { 1125 | "supports-color": { 1126 | "optional": true 1127 | } 1128 | } 1129 | }, 1130 | "node_modules/router/node_modules/ms": { 1131 | "version": "2.1.3", 1132 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", 1133 | "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", 1134 | "license": "MIT" 1135 | }, 1136 | "node_modules/safe-buffer": { 1137 | "version": "5.2.1", 1138 | "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", 1139 | "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", 1140 | "funding": [ 1141 | { 1142 | "type": "github", 1143 | "url": "https://github.com/sponsors/feross" 1144 | }, 1145 | { 1146 | "type": "patreon", 1147 | "url": "https://www.patreon.com/feross" 1148 | }, 1149 | { 1150 | "type": "consulting", 1151 | "url": "https://feross.org/support" 1152 | } 1153 | ], 1154 | "license": "MIT" 1155 | }, 1156 | "node_modules/safe-stable-stringify": { 1157 | "version": "2.5.0", 1158 | "resolved": "https://registry.npmjs.org/safe-stable-stringify/-/safe-stable-stringify-2.5.0.tgz", 1159 | "integrity": "sha512-b3rppTKm9T+PsVCBEOUR46GWI7fdOs00VKZ1+9c1EWDaDMvjQc6tUwuFyIprgGgTcWoVHSKrU8H31ZHA2e0RHA==", 1160 | "license": "MIT", 1161 | "engines": { 1162 | "node": ">=10" 1163 | } 1164 | }, 1165 | "node_modules/safer-buffer": { 1166 | "version": "2.1.2", 1167 | "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", 1168 | "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", 1169 | "license": "MIT" 1170 | }, 1171 | "node_modules/secure-json-parse": { 1172 | "version": "2.7.0", 1173 | "resolved": "https://registry.npmjs.org/secure-json-parse/-/secure-json-parse-2.7.0.tgz", 1174 | "integrity": "sha512-6aU+Rwsezw7VR8/nyvKTx8QpWH9FrcYiXXlqC4z5d5XQBDRqtbfsRjnwGyqbi3gddNtWHuEk9OANUotL26qKUw==", 1175 | "license": "BSD-3-Clause" 1176 | }, 1177 | "node_modules/send": { 1178 | "version": "1.2.0", 1179 | "resolved": "https://registry.npmjs.org/send/-/send-1.2.0.tgz", 1180 | "integrity": "sha512-uaW0WwXKpL9blXE2o0bRhoL2EGXIrZxQ2ZQ4mgcfoBxdFmQold+qWsD2jLrfZ0trjKL6vOw0j//eAwcALFjKSw==", 1181 | "license": "MIT", 1182 | "dependencies": { 1183 | "debug": "^4.3.5", 1184 | "encodeurl": "^2.0.0", 1185 | "escape-html": "^1.0.3", 1186 | "etag": "^1.8.1", 1187 | "fresh": "^2.0.0", 1188 | "http-errors": "^2.0.0", 1189 | "mime-types": "^3.0.1", 1190 | "ms": "^2.1.3", 1191 | "on-finished": "^2.4.1", 1192 | "range-parser": "^1.2.1", 1193 | "statuses": "^2.0.1" 1194 | }, 1195 | "engines": { 1196 | "node": ">= 18" 1197 | } 1198 | }, 1199 | "node_modules/send/node_modules/ms": { 1200 | "version": "2.1.3", 1201 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", 1202 | "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", 1203 | "license": "MIT" 1204 | }, 1205 | "node_modules/serve-static": { 1206 | "version": "2.2.0", 1207 | "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-2.2.0.tgz", 1208 | "integrity": "sha512-61g9pCh0Vnh7IutZjtLGGpTA355+OPn2TyDv/6ivP2h/AdAVX9azsoxmg2/M6nZeQZNYBEwIcsne1mJd9oQItQ==", 1209 | "license": "MIT", 1210 | "dependencies": { 1211 | "encodeurl": "^2.0.0", 1212 | "escape-html": "^1.0.3", 1213 | "parseurl": "^1.3.3", 1214 | "send": "^1.2.0" 1215 | }, 1216 | "engines": { 1217 | "node": ">= 18" 1218 | } 1219 | }, 1220 | "node_modules/setprototypeof": { 1221 | "version": "1.2.0", 1222 | "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", 1223 | "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==", 1224 | "license": "ISC" 1225 | }, 1226 | "node_modules/shebang-command": { 1227 | "version": "2.0.0", 1228 | "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", 1229 | "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", 1230 | "license": "MIT", 1231 | "dependencies": { 1232 | "shebang-regex": "^3.0.0" 1233 | }, 1234 | "engines": { 1235 | "node": ">=8" 1236 | } 1237 | }, 1238 | "node_modules/shebang-regex": { 1239 | "version": "3.0.0", 1240 | "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", 1241 | "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", 1242 | "license": "MIT", 1243 | "engines": { 1244 | "node": ">=8" 1245 | } 1246 | }, 1247 | "node_modules/side-channel": { 1248 | "version": "1.1.0", 1249 | "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.1.0.tgz", 1250 | "integrity": "sha512-ZX99e6tRweoUXqR+VBrslhda51Nh5MTQwou5tnUDgbtyM0dBgmhEDtWGP/xbKn6hqfPRHujUNwz5fy/wbbhnpw==", 1251 | "license": "MIT", 1252 | "dependencies": { 1253 | "es-errors": "^1.3.0", 1254 | "object-inspect": "^1.13.3", 1255 | "side-channel-list": "^1.0.0", 1256 | "side-channel-map": "^1.0.1", 1257 | "side-channel-weakmap": "^1.0.2" 1258 | }, 1259 | "engines": { 1260 | "node": ">= 0.4" 1261 | }, 1262 | "funding": { 1263 | "url": "https://github.com/sponsors/ljharb" 1264 | } 1265 | }, 1266 | "node_modules/side-channel-list": { 1267 | "version": "1.0.0", 1268 | "resolved": "https://registry.npmjs.org/side-channel-list/-/side-channel-list-1.0.0.tgz", 1269 | "integrity": "sha512-FCLHtRD/gnpCiCHEiJLOwdmFP+wzCmDEkc9y7NsYxeF4u7Btsn1ZuwgwJGxImImHicJArLP4R0yX4c2KCrMrTA==", 1270 | "license": "MIT", 1271 | "dependencies": { 1272 | "es-errors": "^1.3.0", 1273 | "object-inspect": "^1.13.3" 1274 | }, 1275 | "engines": { 1276 | "node": ">= 0.4" 1277 | }, 1278 | "funding": { 1279 | "url": "https://github.com/sponsors/ljharb" 1280 | } 1281 | }, 1282 | "node_modules/side-channel-map": { 1283 | "version": "1.0.1", 1284 | "resolved": "https://registry.npmjs.org/side-channel-map/-/side-channel-map-1.0.1.tgz", 1285 | "integrity": "sha512-VCjCNfgMsby3tTdo02nbjtM/ewra6jPHmpThenkTYh8pG9ucZ/1P8So4u4FGBek/BjpOVsDCMoLA/iuBKIFXRA==", 1286 | "license": "MIT", 1287 | "dependencies": { 1288 | "call-bound": "^1.0.2", 1289 | "es-errors": "^1.3.0", 1290 | "get-intrinsic": "^1.2.5", 1291 | "object-inspect": "^1.13.3" 1292 | }, 1293 | "engines": { 1294 | "node": ">= 0.4" 1295 | }, 1296 | "funding": { 1297 | "url": "https://github.com/sponsors/ljharb" 1298 | } 1299 | }, 1300 | "node_modules/side-channel-weakmap": { 1301 | "version": "1.0.2", 1302 | "resolved": "https://registry.npmjs.org/side-channel-weakmap/-/side-channel-weakmap-1.0.2.tgz", 1303 | "integrity": "sha512-WPS/HvHQTYnHisLo9McqBHOJk2FkHO/tlpvldyrnem4aeQp4hai3gythswg6p01oSoTl58rcpiFAjF2br2Ak2A==", 1304 | "license": "MIT", 1305 | "dependencies": { 1306 | "call-bound": "^1.0.2", 1307 | "es-errors": "^1.3.0", 1308 | "get-intrinsic": "^1.2.5", 1309 | "object-inspect": "^1.13.3", 1310 | "side-channel-map": "^1.0.1" 1311 | }, 1312 | "engines": { 1313 | "node": ">= 0.4" 1314 | }, 1315 | "funding": { 1316 | "url": "https://github.com/sponsors/ljharb" 1317 | } 1318 | }, 1319 | "node_modules/sonic-boom": { 1320 | "version": "4.2.0", 1321 | "resolved": "https://registry.npmjs.org/sonic-boom/-/sonic-boom-4.2.0.tgz", 1322 | "integrity": "sha512-INb7TM37/mAcsGmc9hyyI6+QR3rR1zVRu36B0NeGXKnOOLiZOfER5SA+N7X7k3yUYRzLWafduTDvJAfDswwEww==", 1323 | "license": "MIT", 1324 | "dependencies": { 1325 | "atomic-sleep": "^1.0.0" 1326 | } 1327 | }, 1328 | "node_modules/split2": { 1329 | "version": "4.2.0", 1330 | "resolved": "https://registry.npmjs.org/split2/-/split2-4.2.0.tgz", 1331 | "integrity": "sha512-UcjcJOWknrNkF6PLX83qcHM6KHgVKNkV62Y8a5uYDVv9ydGQVwAHMKqHdJje1VTWpljG0WYpCDhrCdAOYH4TWg==", 1332 | "license": "ISC", 1333 | "engines": { 1334 | "node": ">= 10.x" 1335 | } 1336 | }, 1337 | "node_modules/statuses": { 1338 | "version": "2.0.1", 1339 | "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz", 1340 | "integrity": "sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==", 1341 | "license": "MIT", 1342 | "engines": { 1343 | "node": ">= 0.8" 1344 | } 1345 | }, 1346 | "node_modules/strip-json-comments": { 1347 | "version": "3.1.1", 1348 | "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", 1349 | "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", 1350 | "license": "MIT", 1351 | "engines": { 1352 | "node": ">=8" 1353 | }, 1354 | "funding": { 1355 | "url": "https://github.com/sponsors/sindresorhus" 1356 | } 1357 | }, 1358 | "node_modules/thread-stream": { 1359 | "version": "3.1.0", 1360 | "resolved": "https://registry.npmjs.org/thread-stream/-/thread-stream-3.1.0.tgz", 1361 | "integrity": "sha512-OqyPZ9u96VohAyMfJykzmivOrY2wfMSf3C5TtFJVgN+Hm6aj+voFhlK+kZEIv2FBh1X6Xp3DlnCOfEQ3B2J86A==", 1362 | "license": "MIT", 1363 | "dependencies": { 1364 | "real-require": "^0.2.0" 1365 | } 1366 | }, 1367 | "node_modules/toidentifier": { 1368 | "version": "1.0.1", 1369 | "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz", 1370 | "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==", 1371 | "license": "MIT", 1372 | "engines": { 1373 | "node": ">=0.6" 1374 | } 1375 | }, 1376 | "node_modules/tsx": { 1377 | "version": "4.19.3", 1378 | "resolved": "https://registry.npmjs.org/tsx/-/tsx-4.19.3.tgz", 1379 | "integrity": "sha512-4H8vUNGNjQ4V2EOoGw005+c+dGuPSnhpPBPHBtsZdGZBk/iJb4kguGlPWaZTZ3q5nMtFOEsY0nRDlh9PJyd6SQ==", 1380 | "dev": true, 1381 | "license": "MIT", 1382 | "dependencies": { 1383 | "esbuild": "~0.25.0", 1384 | "get-tsconfig": "^4.7.5" 1385 | }, 1386 | "bin": { 1387 | "tsx": "dist/cli.mjs" 1388 | }, 1389 | "engines": { 1390 | "node": ">=18.0.0" 1391 | }, 1392 | "optionalDependencies": { 1393 | "fsevents": "~2.3.3" 1394 | } 1395 | }, 1396 | "node_modules/type-is": { 1397 | "version": "2.0.1", 1398 | "resolved": "https://registry.npmjs.org/type-is/-/type-is-2.0.1.tgz", 1399 | "integrity": "sha512-OZs6gsjF4vMp32qrCbiVSkrFmXtG/AZhY3t0iAMrMBiAZyV9oALtXO8hsrHbMXF9x6L3grlFuwW2oAz7cav+Gw==", 1400 | "license": "MIT", 1401 | "dependencies": { 1402 | "content-type": "^1.0.5", 1403 | "media-typer": "^1.1.0", 1404 | "mime-types": "^3.0.0" 1405 | }, 1406 | "engines": { 1407 | "node": ">= 0.6" 1408 | } 1409 | }, 1410 | "node_modules/typescript": { 1411 | "version": "5.8.2", 1412 | "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.8.2.tgz", 1413 | "integrity": "sha512-aJn6wq13/afZp/jT9QZmwEjDqqvSGp1VT5GVg+f/t6/oVyrgXM6BY1h9BRh/O5p3PlUPAe+WuiEZOmb/49RqoQ==", 1414 | "dev": true, 1415 | "license": "Apache-2.0", 1416 | "bin": { 1417 | "tsc": "bin/tsc", 1418 | "tsserver": "bin/tsserver" 1419 | }, 1420 | "engines": { 1421 | "node": ">=14.17" 1422 | } 1423 | }, 1424 | "node_modules/undici-types": { 1425 | "version": "6.19.8", 1426 | "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.19.8.tgz", 1427 | "integrity": "sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==", 1428 | "dev": true, 1429 | "license": "MIT" 1430 | }, 1431 | "node_modules/unpipe": { 1432 | "version": "1.0.0", 1433 | "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", 1434 | "integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==", 1435 | "license": "MIT", 1436 | "engines": { 1437 | "node": ">= 0.8" 1438 | } 1439 | }, 1440 | "node_modules/utils-merge": { 1441 | "version": "1.0.1", 1442 | "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", 1443 | "integrity": "sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA==", 1444 | "license": "MIT", 1445 | "engines": { 1446 | "node": ">= 0.4.0" 1447 | } 1448 | }, 1449 | "node_modules/vary": { 1450 | "version": "1.1.2", 1451 | "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", 1452 | "integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==", 1453 | "license": "MIT", 1454 | "engines": { 1455 | "node": ">= 0.8" 1456 | } 1457 | }, 1458 | "node_modules/which": { 1459 | "version": "2.0.2", 1460 | "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", 1461 | "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", 1462 | "license": "ISC", 1463 | "dependencies": { 1464 | "isexe": "^2.0.0" 1465 | }, 1466 | "bin": { 1467 | "node-which": "bin/node-which" 1468 | }, 1469 | "engines": { 1470 | "node": ">= 8" 1471 | } 1472 | }, 1473 | "node_modules/wrappy": { 1474 | "version": "1.0.2", 1475 | "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", 1476 | "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", 1477 | "license": "ISC" 1478 | }, 1479 | "node_modules/ws": { 1480 | "version": "8.18.1", 1481 | "resolved": "https://registry.npmjs.org/ws/-/ws-8.18.1.tgz", 1482 | "integrity": "sha512-RKW2aJZMXeMxVpnZ6bck+RswznaxmzdULiBr6KY7XkTnW8uvt0iT9H5DkHUChXrc+uurzwa0rVI16n/Xzjdz1w==", 1483 | "license": "MIT", 1484 | "engines": { 1485 | "node": ">=10.0.0" 1486 | }, 1487 | "peerDependencies": { 1488 | "bufferutil": "^4.0.1", 1489 | "utf-8-validate": ">=5.0.2" 1490 | }, 1491 | "peerDependenciesMeta": { 1492 | "bufferutil": { 1493 | "optional": true 1494 | }, 1495 | "utf-8-validate": { 1496 | "optional": true 1497 | } 1498 | } 1499 | }, 1500 | "node_modules/zod": { 1501 | "version": "3.24.2", 1502 | "resolved": "https://registry.npmjs.org/zod/-/zod-3.24.2.tgz", 1503 | "integrity": "sha512-lY7CDW43ECgW9u1TcT3IoXHflywfVqDYze4waEz812jR/bZ8FHDsl7pFQoSZTz5N+2NqRXs8GBwnAwo3ZNxqhQ==", 1504 | "license": "MIT", 1505 | "funding": { 1506 | "url": "https://github.com/sponsors/colinhacks" 1507 | } 1508 | }, 1509 | "node_modules/zod-to-json-schema": { 1510 | "version": "3.24.5", 1511 | "resolved": "https://registry.npmjs.org/zod-to-json-schema/-/zod-to-json-schema-3.24.5.tgz", 1512 | "integrity": "sha512-/AuWwMP+YqiPbsJx5D6TfgRTc4kTLjsh5SOcd4bLsfUg2RcEXrFMJl1DGgdHy2aCfsIA/cr/1JM0xcB2GZji8g==", 1513 | "license": "ISC", 1514 | "peerDependencies": { 1515 | "zod": "^3.24.1" 1516 | } 1517 | } 1518 | } 1519 | } 1520 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@lazydino/ccxt-mcp", 3 | "version": "0.4.1", 4 | "description": "CCXT integration for Model Context Protocol", 5 | "type": "module", 6 | "main": "dist/index.js", 7 | "bin": { 8 | "ccxt-mcp": "./bin/ccxt-mcp.js" 9 | }, 10 | "scripts": { 11 | "build": "tsc", 12 | "start": "node dist/index.js", 13 | "dev": "tsx src/index.ts", 14 | "test": "echo \"No tests specified\" && exit 0" 15 | }, 16 | "keywords": [ 17 | "ccxt", 18 | "mcp", 19 | "modelcontextprotocol", 20 | "cryptocurrency", 21 | "trading", 22 | "exchange", 23 | "api" 24 | ], 25 | "author": "LazyDino", 26 | "license": "MIT", 27 | "dependencies": { 28 | "@modelcontextprotocol/sdk": "^1.8.0", 29 | "ccxt": "^4.4.0", 30 | "zod": "^3.23.8", 31 | "zod-to-json-schema": "^3.24.1" 32 | }, 33 | "devDependencies": { 34 | "@types/node": "^20.17.28", 35 | "tsx": "^4.7.0", 36 | "typescript": "^5.5.0" 37 | }, 38 | "engines": { 39 | "node": ">=18.0.0" 40 | }, 41 | "files": [ 42 | "dist", 43 | "bin" 44 | ], 45 | "publishConfig": { 46 | "access": "public" 47 | }, 48 | "repository": { 49 | "type": "git", 50 | "url": "https://github.com/lazy-dinosaur/ccxt-mcp.git" 51 | }, 52 | "bugs": { 53 | "url": "https://github.com/lazy-dinosaur/ccxt-mcp/issues" 54 | }, 55 | "homepage": "https://github.com/lazy-dinosaur/ccxt-mcp#readme" 56 | } 57 | -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * CCXT MCP Server - 메인 엔트리 포인트 3 | * 이 파일은 CCXT MCP 서버를 시작하는 스크립트입니다. 4 | */ 5 | 6 | import { CcxtMcpServer } from "./server.js"; 7 | 8 | // 명령줄 인수 처리 9 | const args = process.argv.slice(2); 10 | let configPath = null; 11 | 12 | // --config 옵션 처리 13 | const configIndex = args.indexOf('--config'); 14 | if (configIndex !== -1 && args.length > configIndex + 1) { 15 | configPath = args[configIndex + 1]; 16 | console.error(`[INFO] Using custom config file: ${configPath}`); 17 | } 18 | 19 | // 서버 인스턴스 생성 및 시작 20 | console.error(`[INFO] Starting CCXT MCP Server...`); 21 | const server = new CcxtMcpServer(configPath); 22 | server.start().catch((error) => { 23 | console.error("Failed to start server:", error); 24 | process.exit(1); 25 | }); 26 | -------------------------------------------------------------------------------- /src/resources/exchanges.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * 거래소 관련 리소스를 정의합니다. 3 | */ 4 | 5 | import { McpServer, ResourceTemplate } from "@modelcontextprotocol/sdk/server/mcp.js"; 6 | import ccxt from 'ccxt'; 7 | import { CcxtMcpServer } from '../server.js'; 8 | 9 | /** 10 | * 거래소 관련 리소스를 서버에 등록합니다. 11 | */ 12 | export function registerExchangeResources(server: McpServer, ccxtServer: CcxtMcpServer) { 13 | // 거래소 목록 리소스 14 | server.resource( 15 | "exchanges", 16 | "exchanges://list", 17 | async (uri) => { 18 | const exchanges = ccxt.exchanges; 19 | return { 20 | contents: [ 21 | { 22 | uri: uri.href, 23 | text: JSON.stringify(exchanges), 24 | contentType: "application/json" 25 | } 26 | ] 27 | }; 28 | } 29 | ); 30 | 31 | // 특정 거래소 정보 리소스 32 | server.resource( 33 | "exchange-info", 34 | new ResourceTemplate("exchange://info/{exchangeId}", { 35 | list: async () => { 36 | // 모든 거래소의 기본 정보 반환 37 | const exchanges = ccxt.exchanges.slice(0, 20); // 처음 20개만 38 | return { 39 | resources: exchanges.map(exchangeId => ({ 40 | uri: `exchange://info/${exchangeId}`, 41 | name: `${exchangeId} Info` 42 | })) 43 | }; 44 | }, 45 | complete: { 46 | exchangeId: async (value) => { 47 | // 거래소 ID 자동완성 제공 48 | return ccxt.exchanges.filter(exchange => 49 | exchange.toLowerCase().includes(value.toLowerCase()) 50 | ).slice(0, 10); 51 | } 52 | } 53 | }), 54 | async (uri, variables) => { 55 | const { exchangeId } = variables; 56 | try { 57 | // 공개 인스턴스 사용 58 | const exchange = ccxtServer.getPublicExchangeInstance(exchangeId as string); 59 | 60 | // 거래소 기본 정보 61 | const info = { 62 | id: exchange.id, 63 | name: exchange.name, 64 | countries: exchange.countries, 65 | urls: exchange.urls, 66 | version: exchange.version, 67 | certified: exchange.certified, 68 | pro: exchange.pro, 69 | has: exchange.has, 70 | timeframes: exchange.timeframes, 71 | requiredCredentials: exchange.requiredCredentials, 72 | precisionMode: exchange.precisionMode, 73 | limitRate: exchange.rateLimit, 74 | fees: exchange.fees 75 | }; 76 | 77 | return { 78 | contents: [ 79 | { 80 | uri: uri.href, 81 | text: JSON.stringify(info), 82 | contentType: "application/json" 83 | } 84 | ] 85 | }; 86 | } catch (error) { 87 | return { 88 | contents: [ 89 | { 90 | uri: uri.href, 91 | text: JSON.stringify({ error: (error as Error).message }), 92 | contentType: "application/json" 93 | } 94 | ] 95 | }; 96 | } 97 | } 98 | ); 99 | } 100 | -------------------------------------------------------------------------------- /src/resources/markets.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * 시장 관련 리소스를 정의합니다. 3 | */ 4 | 5 | import { 6 | McpServer, 7 | ResourceTemplate, 8 | } from "@modelcontextprotocol/sdk/server/mcp.js"; 9 | import ccxt from "ccxt"; 10 | import { CcxtMcpServer } from "../server.js"; 11 | 12 | /** 13 | * 시장 관련 리소스를 서버에 등록합니다. 14 | */ 15 | export function registerMarketResources( 16 | server: McpServer, 17 | ccxtServer: CcxtMcpServer 18 | ) { 19 | // 특정 거래소의 시장 정보 리소스 20 | server.resource( 21 | "markets", 22 | new ResourceTemplate("markets://exchange/{exchangeId}", { 23 | list: async () => { 24 | // 모든 거래소의 기본 정보 반환 25 | const exchanges = ccxt.exchanges.slice(0, 10); // 예제에서는 처음 10개만 26 | return { 27 | resources: exchanges.map((exchangeId) => ({ 28 | uri: `markets://exchange/${exchangeId}`, 29 | name: `${exchangeId} Markets`, 30 | })), 31 | }; 32 | }, 33 | complete: { 34 | exchangeId: async (value) => { 35 | // 거래소 ID 자동완성 제공 36 | return ccxt.exchanges 37 | .filter((exchange) => 38 | exchange.toLowerCase().includes(value.toLowerCase()) 39 | ) 40 | .slice(0, 10); 41 | }, 42 | }, 43 | }), 44 | async (uri, variables) => { 45 | const { exchangeId } = variables; 46 | try { 47 | // 공개 인스턴스 사용 48 | const exchange = ccxtServer.getPublicExchangeInstance(exchangeId as string); 49 | const markets = await exchange.loadMarkets(); 50 | 51 | return { 52 | contents: [ 53 | { 54 | uri: uri.href, 55 | text: JSON.stringify(markets), 56 | contentType: "application/json", 57 | }, 58 | ], 59 | }; 60 | } catch (error) { 61 | return { 62 | contents: [ 63 | { 64 | uri: uri.href, 65 | text: JSON.stringify({ error: (error as Error).message }), 66 | contentType: "application/json", 67 | }, 68 | ], 69 | }; 70 | } 71 | } 72 | ); 73 | 74 | // 특정 거래소의 특정 심볼에 대한 시장 정보 리소스 75 | server.resource( 76 | "market", 77 | new ResourceTemplate("market://exchange/{exchangeId}/{symbol}", { 78 | list: undefined, 79 | complete: { 80 | exchangeId: async (value) => { 81 | return ccxt.exchanges 82 | .filter((exchange) => 83 | exchange.toLowerCase().includes(value.toLowerCase()) 84 | ) 85 | .slice(0, 10); 86 | }, 87 | // @ts-ignore - Callback signature mismatch with SDK type 88 | symbol: async (value, variables, context) => { 89 | // Add third argument 'context' 90 | // Change signature to accept variables object 91 | const exchangeId = variables?.exchangeId; // Get exchangeId from variables 92 | if (!exchangeId) return []; 93 | 94 | try { 95 | // 공개 인스턴스 사용 (자동완성용) 96 | const exchange = ccxtServer.getPublicExchangeInstance( 97 | exchangeId as string 98 | ); 99 | await exchange.loadMarkets(); 100 | const symbols = exchange.symbols || []; 101 | 102 | return symbols 103 | .filter((symbol) => 104 | symbol.toLowerCase().includes(value.toLowerCase()) 105 | ) 106 | .slice(0, 10); 107 | } catch (error) { 108 | return []; 109 | } 110 | }, 111 | }, 112 | }), 113 | async (uri, variables) => { 114 | const { exchangeId, symbol } = variables; 115 | 116 | try { 117 | // 공개 인스턴스 사용 118 | const exchange = ccxtServer.getPublicExchangeInstance(exchangeId as string); 119 | await exchange.loadMarkets(); 120 | const market = exchange.market(symbol as string); 121 | 122 | return { 123 | contents: [ 124 | { 125 | uri: uri.href, 126 | text: JSON.stringify(market), 127 | contentType: "application/json", 128 | }, 129 | ], 130 | }; 131 | } catch (error) { 132 | return { 133 | contents: [ 134 | { 135 | uri: uri.href, 136 | text: JSON.stringify({ error: (error as Error).message }), 137 | contentType: "application/json", 138 | }, 139 | ], 140 | }; 141 | } 142 | } 143 | ); 144 | } 145 | -------------------------------------------------------------------------------- /src/resources/orderbooks.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * 주문장 관련 리소스를 정의합니다. 3 | */ 4 | 5 | import { 6 | McpServer, 7 | ResourceTemplate, 8 | } from "@modelcontextprotocol/sdk/server/mcp.js"; 9 | import ccxt from "ccxt"; 10 | import { CcxtMcpServer } from "../server.js"; 11 | 12 | /** 13 | * 주문장 관련 리소스를 서버에 등록합니다. 14 | */ 15 | export function registerOrderBookResources( 16 | server: McpServer, 17 | ccxtServer: CcxtMcpServer 18 | ) { 19 | // 특정 거래소의 특정 심볼에 대한 주문장 정보 리소스 20 | server.resource( 21 | "orderbook", 22 | new ResourceTemplate( 23 | "orderbook://exchange/{exchangeId}/{symbol}/{limit?}", 24 | { 25 | list: undefined, 26 | complete: { 27 | exchangeId: async (value) => { 28 | return ccxt.exchanges 29 | .filter((exchange) => 30 | exchange.toLowerCase().includes(value.toLowerCase()) 31 | ) 32 | .slice(0, 10); 33 | }, 34 | // @ts-ignore - Callback signature mismatch with SDK type 35 | symbol: async (value, variables, context) => { 36 | const exchangeId = variables?.exchangeId; 37 | if (!exchangeId) return []; 38 | 39 | try { 40 | // 공개 인스턴스 사용 (자동완성용) 41 | const exchange = ccxtServer.getPublicExchangeInstance( 42 | exchangeId as string 43 | ); 44 | await exchange.loadMarkets(); 45 | const symbols = exchange.symbols || []; 46 | 47 | return symbols 48 | .filter((symbol) => 49 | symbol.toLowerCase().includes(value.toLowerCase()) 50 | ) 51 | .slice(0, 10); 52 | } catch (error) { 53 | return []; 54 | } 55 | }, 56 | }, 57 | } 58 | ), 59 | async (uri, variables) => { 60 | const { exchangeId, symbol, limit } = variables; 61 | const limitNum = limit ? parseInt(limit as string, 10) : undefined; 62 | 63 | try { 64 | // 공개 인스턴스 사용 65 | const exchange = ccxtServer.getPublicExchangeInstance(exchangeId as string); 66 | const orderbook = await exchange.fetchOrderBook( 67 | symbol as string, 68 | limitNum 69 | ); 70 | 71 | return { 72 | contents: [ 73 | { 74 | uri: uri.href, 75 | text: JSON.stringify(orderbook), 76 | contentType: "application/json", 77 | }, 78 | ], 79 | }; 80 | } catch (error) { 81 | return { 82 | contents: [ 83 | { 84 | uri: uri.href, 85 | text: JSON.stringify({ error: (error as Error).message }), 86 | contentType: "application/json", 87 | }, 88 | ], 89 | }; 90 | } 91 | } 92 | ); 93 | 94 | // 특정 거래소의 특정 심볼에 대한 L2 주문장 정보 리소스 95 | server.resource( 96 | "l2orderbook", 97 | new ResourceTemplate("l2orderbook://exchange/{exchangeId}/{symbol}", { 98 | list: undefined, 99 | complete: { 100 | exchangeId: async (value) => { 101 | return ccxt.exchanges 102 | .filter((exchange) => 103 | exchange.toLowerCase().includes(value.toLowerCase()) 104 | ) 105 | .slice(0, 10); 106 | }, 107 | // @ts-ignore - Callback signature mismatch with SDK type 108 | symbol: async (value, variables, context) => { 109 | const exchangeId = variables?.exchangeId; 110 | if (!exchangeId) return []; 111 | 112 | try { 113 | // 공개 인스턴스 사용 (자동완성용) 114 | const exchange = ccxtServer.getPublicExchangeInstance( 115 | exchangeId as string 116 | ); 117 | await exchange.loadMarkets(); 118 | const symbols = exchange.symbols || []; 119 | 120 | return symbols 121 | .filter((symbol) => 122 | symbol.toLowerCase().includes(value.toLowerCase()) 123 | ) 124 | .slice(0, 10); 125 | } catch (error) { 126 | return []; 127 | } 128 | }, 129 | }, 130 | }), 131 | async (uri, variables) => { 132 | const { exchangeId, symbol } = variables; 133 | 134 | try { 135 | // 공개 인스턴스 사용 136 | const exchange = ccxtServer.getPublicExchangeInstance(exchangeId as string); 137 | // L2 주문장은 더 자세한 주문장 정보를 제공 138 | const orderbook = await exchange.fetchL2OrderBook(symbol as string); 139 | 140 | return { 141 | contents: [ 142 | { 143 | uri: uri.href, 144 | text: JSON.stringify(orderbook), 145 | contentType: "application/json", 146 | }, 147 | ], 148 | }; 149 | } catch (error) { 150 | return { 151 | contents: [ 152 | { 153 | uri: uri.href, 154 | text: JSON.stringify({ error: (error as Error).message }), 155 | contentType: "application/json", 156 | }, 157 | ], 158 | }; 159 | } 160 | } 161 | ); 162 | } 163 | -------------------------------------------------------------------------------- /src/resources/prices.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * 가격 관련 리소스를 정의합니다. 3 | */ 4 | 5 | import { 6 | McpServer, 7 | ResourceTemplate, 8 | } from "@modelcontextprotocol/sdk/server/mcp.js"; 9 | import ccxt from "ccxt"; 10 | import { CcxtMcpServer } from "../server.js"; 11 | 12 | /** 13 | * 가격 관련 리소스를 서버에 등록합니다. 14 | */ 15 | export function registerPriceResources( 16 | server: McpServer, 17 | ccxtServer: CcxtMcpServer 18 | ) { 19 | // 특정 거래소의 특정 심볼에 대한 티커 정보 리소스 20 | server.resource( 21 | "ticker", 22 | new ResourceTemplate("ticker://exchange/{exchangeId}/{symbol}", { 23 | list: undefined, 24 | complete: { 25 | exchangeId: async (value) => { 26 | // 거래소 ID 자동완성 27 | return ccxt.exchanges 28 | .filter((exchange) => 29 | exchange.toLowerCase().includes(value.toLowerCase()) 30 | ) 31 | .slice(0, 10); 32 | }, 33 | // @ts-ignore - Callback signature mismatch with SDK type 34 | symbol: async (value, variables, context) => { 35 | // 지정된 거래소의 심볼 자동완성 36 | const exchangeId = variables?.exchangeId; 37 | if (!exchangeId) return []; 38 | 39 | try { 40 | // 공개 인스턴스 사용 (자동완성용) 41 | const exchange = ccxtServer.getPublicExchangeInstance( 42 | exchangeId as string 43 | ); 44 | await exchange.loadMarkets(); 45 | const symbols = exchange.symbols || []; 46 | 47 | return symbols 48 | .filter((symbol) => 49 | symbol.toLowerCase().includes(value.toLowerCase()) 50 | ) 51 | .slice(0, 10); 52 | } catch (error) { 53 | return []; 54 | } 55 | }, 56 | }, 57 | }), 58 | async (uri, variables) => { 59 | const { exchangeId, symbol } = variables; 60 | 61 | try { 62 | // 공개 인스턴스 사용 63 | const exchange = ccxtServer.getPublicExchangeInstance(exchangeId as string); 64 | const ticker = await exchange.fetchTicker(symbol as string); 65 | 66 | return { 67 | contents: [ 68 | { 69 | uri: uri.href, 70 | text: JSON.stringify(ticker), 71 | contentType: "application/json", 72 | }, 73 | ], 74 | }; 75 | } catch (error) { 76 | return { 77 | contents: [ 78 | { 79 | uri: uri.href, 80 | text: JSON.stringify({ error: (error as Error).message }), 81 | contentType: "application/json", 82 | }, 83 | ], 84 | }; 85 | } 86 | } 87 | ); 88 | 89 | // 특정 거래소의 모든 티커 정보 90 | server.resource( 91 | "tickers", 92 | new ResourceTemplate("tickers://exchange/{exchangeId}", { 93 | list: undefined, 94 | complete: { 95 | exchangeId: async (value) => { 96 | return ccxt.exchanges 97 | .filter((exchange) => 98 | exchange.toLowerCase().includes(value.toLowerCase()) 99 | ) 100 | .slice(0, 10); 101 | }, 102 | }, 103 | }), 104 | async (uri, variables) => { 105 | const { exchangeId } = variables; 106 | 107 | try { 108 | // 공개 인스턴스 사용 109 | const exchange = ccxtServer.getPublicExchangeInstance(exchangeId as string); 110 | const tickers = await exchange.fetchTickers(); 111 | 112 | return { 113 | contents: [ 114 | { 115 | uri: uri.href, 116 | text: JSON.stringify(tickers), 117 | contentType: "application/json", 118 | }, 119 | ], 120 | }; 121 | } catch (error) { 122 | return { 123 | contents: [ 124 | { 125 | uri: uri.href, 126 | text: JSON.stringify({ error: (error as Error).message }), 127 | contentType: "application/json", 128 | }, 129 | ], 130 | }; 131 | } 132 | } 133 | ); 134 | } 135 | -------------------------------------------------------------------------------- /src/server.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * CCXT MCP 서버 클래스 구현 3 | * 이 파일은 MCP 서버와 CCXT 라이브러리 통합을 구현합니다. 4 | */ 5 | 6 | import { 7 | McpServer, 8 | ResourceTemplate, 9 | } from "@modelcontextprotocol/sdk/server/mcp.js"; // Restore original path 10 | import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"; // Restore original path 11 | import { URL } from "url"; 12 | import { z } from "zod"; 13 | import ccxt, { Exchange } from "ccxt"; // Import Exchange type 14 | import fs from "fs"; 15 | import path from "path"; 16 | import os from "os"; 17 | 18 | import { registerExchangeResources } from "./resources/exchanges.js"; // Restore .js 19 | import { registerMarketResources } from "./resources/markets.js"; // Restore .js 20 | import { registerPriceResources } from "./resources/prices.js"; // Restore .js 21 | import { registerOrderBookResources } from "./resources/orderbooks.js"; // Restore .js 22 | import { registerMarketTools } from "./tools/market-tools.js"; // Restore .js 23 | import { registerOrderTools } from "./tools/order-tools.js"; // Restore .js 24 | import { registerAccountTools } from "./tools/account-tools.js"; // Restore .js 25 | import { registerAnalysisTools } from "./tools/analysis-tools.js"; // 거래 분석 도구 26 | 27 | // 설정 파일의 계정 구조 정의 28 | interface AccountConfig { 29 | name: string; 30 | exchangeId: string; 31 | apiKey: string; 32 | secret: string; 33 | password?: string; // Some exchanges require password (e.g. FTX) 34 | uid?: string; // Some exchanges require UID (e.g. Deribit) 35 | privateKey?: string; // For exchanges using private key auth 36 | walletAddress?: string; // For DEX exchanges 37 | subaccount?: string; // For exchanges with subaccount support 38 | defaultType?: "spot" | "margin" | "future" | "swap" | "option"; // Extended market types 39 | enableRateLimit?: boolean; // Rate limiter control 40 | timeout?: number; // Custom timeout 41 | verbose?: boolean; // Debug mode 42 | proxy?: string; // Proxy settings 43 | options?: { 44 | [key: string]: any; // Exchange-specific options 45 | }; 46 | } 47 | 48 | /** 49 | * CCXT MCP 서버 클래스 50 | * MCP 프로토콜을 통해 CCXT 기능을 노출합니다. 51 | */ 52 | export class CcxtMcpServer { 53 | private server: McpServer; 54 | // Key: account name from config, Value: Authenticated CCXT Exchange instance 55 | private exchangeInstances: Record = {}; 56 | // Key: `${exchangeId}-${marketType}`, Value: Public (unauthenticated) CCXT Exchange instance 57 | private publicExchangeInstances: Record = {}; 58 | // 설정 파일 경로 59 | private configPath: string; 60 | 61 | /** 62 | * @param configPath 사용자 지정 설정 파일 경로 (선택 사항) 63 | */ 64 | constructor(configPath?: string) { 65 | // MCP 서버 초기화 66 | this.server = new McpServer({ 67 | name: "CCXT MCP", 68 | version: "4.0.0", 69 | }); 70 | 71 | // 설정 파일 경로 설정 72 | this.configPath = 73 | configPath || 74 | path.join( 75 | os.homedir(), 76 | ".config", 77 | "Claude", 78 | "claude_desktop_config.json", 79 | ); 80 | 81 | // 설정 파일에서 계정 로드 및 거래소 인스턴스 초기화 82 | this.loadAccountsFromConfig(); 83 | 84 | // 리소스 및 도구 등록 85 | this.registerResources(); 86 | this.registerTools(); 87 | } 88 | 89 | /** 90 | * 설정 파일에서 계정 정보를 로드하고 CCXT 인스턴스를 생성합니다. 91 | */ 92 | private async loadAccountsFromConfig() { 93 | try { 94 | console.error(`[DEBUG] Loading config from: ${this.configPath}`); 95 | 96 | // 파일 존재 확인 97 | if (!fs.existsSync(this.configPath)) { 98 | console.error(`[ERROR] Config file not found: ${this.configPath}`); 99 | return; 100 | } 101 | 102 | const configContent = fs.readFileSync(this.configPath, "utf-8"); 103 | console.error(`[DEBUG] Config file size: ${configContent.length} bytes`); 104 | 105 | let config; 106 | try { 107 | config = JSON.parse(configContent); 108 | console.error(`[DEBUG] Successfully parsed JSON config`); 109 | } catch (jsonError) { 110 | console.error(`[ERROR] Invalid JSON in config file: ${jsonError.message}`); 111 | throw new Error( 112 | `Invalid JSON format in config file: ${jsonError.message}`, 113 | ); 114 | } 115 | 116 | let accounts: AccountConfig[] = []; 117 | 118 | // 먼저 직접 외부 설정 파일에서 계정 정보를 확인 119 | if (Array.isArray(config.accounts)) { 120 | console.error(`[DEBUG] Found ${config.accounts.length} accounts directly in config file`); 121 | accounts = config.accounts; 122 | } 123 | // 외부 설정 파일에 계정 정보가 없으면 Claude Desktop 설정 구조 확인 124 | else { 125 | console.error(`[DEBUG] No direct 'accounts' array found, checking mcpServers structure`); 126 | // 새로운 구조에서는 mcpServers.ccxt-mcp.accounts에 계정 정보가 있습니다 127 | const mcpConfig = config?.mcpServers?.["ccxt-mcp"]; 128 | if (!mcpConfig || !Array.isArray(mcpConfig.accounts)) { 129 | console.error( 130 | `[ERROR] Neither 'accounts' array nor 'mcpServers.ccxt-mcp.accounts' found in config` 131 | ); 132 | console.error(`[DEBUG] Config structure: ${JSON.stringify(Object.keys(config))}`); 133 | return; 134 | } 135 | console.error(`[DEBUG] Found ${mcpConfig.accounts.length} accounts in mcpServers.ccxt-mcp.accounts`); 136 | accounts = mcpConfig.accounts; 137 | } 138 | 139 | // 계정이 없는 경우 로그 출력 140 | if (accounts.length === 0) { 141 | console.error(`[ERROR] No accounts found in configuration file: ${this.configPath}`); 142 | return; 143 | } 144 | 145 | console.error(`[INFO] Found ${accounts.length} account(s) in configuration`); 146 | console.error(`[DEBUG] Account names: ${accounts.map(a => a.name).join(', ')}`); 147 | 148 | const loadedAccountNames = new Set(); 149 | for (const account of accounts) { 150 | // 필수 필드 검증 151 | if ( 152 | !account.name || 153 | !account.exchangeId || 154 | !account.apiKey || 155 | !account.secret 156 | ) { 157 | console.warn( 158 | `Skipping account due to missing fields: ${JSON.stringify(account)}`, 159 | ); 160 | continue; 161 | } 162 | 163 | // 중복 계정 이름 검사 164 | if (loadedAccountNames.has(account.name)) { 165 | console.error(`Duplicate account name '${account.name}'. Skipping.`); 166 | continue; 167 | } 168 | loadedAccountNames.add(account.name); 169 | 170 | // 지원되는 거래소인지 확인 171 | if (!ccxt.exchanges.includes(account.exchangeId)) { 172 | console.error( 173 | `Unsupported exchange ID '${account.exchangeId}' for account '${account.name}'. Supported exchanges: ${ccxt.exchanges.join(", ")}`, 174 | ); 175 | continue; 176 | } 177 | 178 | try { 179 | const exchangeOptions = { 180 | apiKey: account.apiKey, 181 | secret: account.secret, 182 | options: { 183 | defaultType: account.defaultType || "spot", // Use defaultType or fallback to 'spot' 184 | }, 185 | }; 186 | 187 | // @ts-ignore - CCXT dynamic instantiation 188 | const exchangeInstance = new ccxt[account.exchangeId]( 189 | exchangeOptions, 190 | ); 191 | 192 | // 특정 마켓 타입이 지원되는지 검증 193 | if (account.defaultType) { 194 | await exchangeInstance.loadMarkets(); 195 | const supportedTypes = { 196 | spot: exchangeInstance.has.spot, 197 | margin: exchangeInstance.has.margin, 198 | future: exchangeInstance.has.future, 199 | swap: exchangeInstance.has.swap, 200 | option: exchangeInstance.has.option, 201 | }; 202 | 203 | if (!supportedTypes[account.defaultType]) { 204 | console.error( 205 | `${account.exchangeId} does not support ${account.defaultType} trading. ` + 206 | `Supported types: ${Object.entries(supportedTypes) 207 | .filter(([_, supported]) => supported) 208 | .map(([type]) => type) 209 | .join(", ")}`, 210 | ); 211 | continue; 212 | } 213 | } 214 | 215 | // Store the instance using the account name as the key 216 | this.exchangeInstances[account.name] = exchangeInstance; 217 | } catch (error) { 218 | // console.error( 219 | // `Failed to create CCXT instance for account '${account.name}' (${account.exchangeId}):`, 220 | // error, 221 | // ); 222 | } 223 | } 224 | } catch (error) { 225 | console.error( 226 | `Failed to load or parse configuration file ${this.configPath}:`, 227 | error, 228 | ); 229 | } 230 | } // loadAccountsFromConfig 메소드 닫는 괄호 231 | 232 | /** 233 | * 선물 주문을 위한 거래소별 파라미터 반환 234 | */ 235 | private getFutureParams(exchangeId: string) { 236 | return ( 237 | { 238 | binance: { type: "future", marginMode: "cross" }, 239 | bybit: { category: "linear" }, 240 | okx: { instType: "SWAP" }, 241 | kucoin: { type: "future" }, 242 | }[exchangeId.toLowerCase()] || {} 243 | ); 244 | } 245 | 246 | /** 247 | * 선물 주문 실행 (자동 재시도 포함) 248 | */ 249 | async executeFutureOrder( 250 | accountName: string, 251 | orderParams: { 252 | symbol: string; 253 | type: string; 254 | side: string; 255 | amount: number; 256 | price?: number; 257 | params?: any; 258 | }, 259 | ) { 260 | const exchange = this.getExchangeInstance(accountName); 261 | const futureParams = this.getFutureParams(exchange.id); 262 | 263 | for (let attempt = 0; attempt < 3; attempt++) { 264 | try { 265 | return await exchange.createOrder( 266 | orderParams.symbol, 267 | orderParams.type, 268 | orderParams.side, 269 | orderParams.amount, 270 | orderParams.price, 271 | { 272 | ...(orderParams.params || {}), 273 | ...futureParams, 274 | }, 275 | ); 276 | } catch (error) { 277 | if (attempt === 2) throw error; 278 | await new Promise((resolve) => 279 | setTimeout(resolve, 1000 * (attempt + 1)), 280 | ); 281 | } 282 | } 283 | } 284 | 285 | /** 286 | * 설정 파일에서 미리 로드된 특정 계정 이름에 해당하는 인증된 거래소 인스턴스를 가져옵니다. 287 | * @param accountName 설정 파일에 정의된 계정의 'name' 288 | * @returns 요청된 계정에 대한 CCXT 거래소 인스턴스 289 | * @throws 계정을 찾을 수 없는 경우 오류 발생 290 | */ 291 | getExchangeInstance(accountName: string): Exchange { 292 | const instance = this.exchangeInstances[accountName]; 293 | if (!instance) { 294 | console.error( 295 | `No pre-loaded exchange instance found for account name: ${accountName}`, 296 | ); 297 | // Consider listing available account names: Object.keys(this.exchangeInstances).join(', ') 298 | throw new Error( 299 | `Account configuration not found or failed to load for: ${accountName}`, 300 | ); 301 | } 302 | return instance; 303 | } 304 | 305 | /** 306 | * 공개 데이터 접근을 위한 인증되지 않은 거래소 인스턴스를 가져오거나 생성합니다. 307 | * @param exchangeId 거래소 ID (e.g., 'binance') 308 | * @param marketType 시장 유형 ('spot' or 'futures'), 기본값 'spot' 309 | * @returns 요청된 거래소/시장 유형에 대한 공개 CCXT 인스턴스 310 | * @throws 지원되지 않는 거래소 ID인 경우 오류 발생 311 | */ 312 | /** 313 | * 로드된 모든 계정 이름 목록을 반환합니다. 314 | */ 315 | getAccountNames(): string[] { 316 | const accountNames = Object.keys(this.exchangeInstances); 317 | console.error(`[DEBUG] getAccountNames() called, returning ${accountNames.length} accounts: ${accountNames.join(', ')}`); 318 | return accountNames; 319 | } 320 | 321 | getPublicExchangeInstance( 322 | exchangeId: string, 323 | marketType: "spot" | "futures" = "spot", 324 | ): Exchange { 325 | const instanceKey = `${exchangeId}-${marketType}`; 326 | 327 | if (!this.publicExchangeInstances[instanceKey]) { 328 | if (!ccxt.exchanges.includes(exchangeId)) { 329 | console.error( 330 | `Exchange ID '${exchangeId}' not found in ccxt.exchanges for public instance.`, 331 | ); 332 | throw new Error(`Unsupported exchange for public data: ${exchangeId}`); 333 | } 334 | 335 | const exchangeOptions = { 336 | options: { 337 | defaultType: marketType, 338 | }, 339 | }; 340 | 341 | try { 342 | // @ts-ignore - CCXT dynamic instantiation without credentials 343 | this.publicExchangeInstances[instanceKey] = new ccxt[exchangeId]( 344 | exchangeOptions, 345 | ); 346 | } catch (error) { 347 | console.error( 348 | `Failed to create public CCXT instance for ${exchangeId} (${marketType}):`, 349 | error, 350 | ); 351 | throw error; // Re-throw the error after logging 352 | } 353 | } 354 | 355 | return this.publicExchangeInstances[instanceKey]; 356 | } 357 | 358 | /** 359 | * MCP 리소스를 등록합니다. 360 | */ 361 | private registerResources() { 362 | registerExchangeResources(this.server, this); 363 | registerMarketResources(this.server, this); 364 | registerPriceResources(this.server, this); 365 | registerOrderBookResources(this.server, this); 366 | } 367 | 368 | /** 369 | * MCP 도구를 등록합니다. 370 | */ 371 | private registerTools() { 372 | registerMarketTools(this.server, this); 373 | registerOrderTools(this.server, this); 374 | registerAccountTools(this.server, this); 375 | registerAnalysisTools(this.server, this); 376 | } 377 | 378 | /** 379 | * 서버를 시작합니다. 380 | */ 381 | async start() { 382 | const transport = new StdioServerTransport(); 383 | await this.server.connect(transport); 384 | console.error("CCXT MCP Server started"); 385 | } 386 | } 387 | -------------------------------------------------------------------------------- /src/tools/account-tools.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * 계정 관련 도구들을 정의합니다. 3 | */ 4 | 5 | import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; 6 | import { z } from "zod"; 7 | import { CcxtMcpServer } from "../server.js"; 8 | 9 | /** 10 | * 계정 관련 도구들을 서버에 등록합니다. 11 | */ 12 | export function registerAccountTools( 13 | server: McpServer, 14 | ccxtServer: CcxtMcpServer 15 | ) { 16 | // 계정 목록 조회 도구 17 | server.tool( 18 | "listAccounts", 19 | "List all configured account names", 20 | {}, 21 | async () => { 22 | console.error(`[DEBUG] listAccounts tool called`); 23 | const accountNames = ccxtServer.getAccountNames(); 24 | 25 | if (accountNames.length === 0) { 26 | console.error(`[WARN] No accounts found in listAccounts tool`); 27 | return { 28 | content: [ 29 | { 30 | type: "text", 31 | text: `No accounts were loaded from the configuration. Please check your config file at: ${ccxtServer['configPath']} 32 | 33 | Possible issues: 34 | 1. The config file doesn't exist 35 | 2. The config file doesn't have the correct format (should have an 'accounts' array) 36 | 3. API keys in the config file are invalid 37 | 4. Permission issues with accessing the config file 38 | 39 | Your config should look like: 40 | { 41 | "accounts": [ 42 | { 43 | "name": "account_name", 44 | "exchangeId": "exchange_id", 45 | "apiKey": "your_api_key", 46 | "secret": "your_secret_key", 47 | "defaultType": "spot" 48 | } 49 | ] 50 | }`, 51 | }, 52 | ], 53 | }; 54 | } 55 | 56 | console.error(`[DEBUG] Returning ${accountNames.length} accounts from listAccounts tool`); 57 | return { 58 | content: [ 59 | { 60 | type: "text", 61 | text: `Configured accounts (${accountNames.length}):\n${accountNames.join("\n")}`, 62 | }, 63 | ], 64 | }; 65 | } 66 | ); 67 | // 계정 잔액 조회 도구 68 | server.tool( 69 | "fetchBalance", 70 | "Fetch account balance for a configured account", 71 | { 72 | accountName: z 73 | .string() 74 | .describe( 75 | "Account name defined in the configuration file (e.g., 'bybit_main')" 76 | ), 77 | }, 78 | async ({ accountName }) => { 79 | try { 80 | // 설정 파일에서 로드된 인스턴스 가져오기 81 | const exchange = ccxtServer.getExchangeInstance(accountName); 82 | 83 | // getExchangeInstance가 성공하면 인증은 보장됨 84 | 85 | const balance = await exchange.fetchBalance(); 86 | 87 | return { 88 | content: [ 89 | { 90 | type: "text", 91 | text: JSON.stringify(balance, null, 2), 92 | }, 93 | ], 94 | }; 95 | } catch (error) { 96 | return { 97 | content: [ 98 | { 99 | type: "text", 100 | text: `Error fetching balance for account '${accountName}': ${ 101 | (error as Error).message 102 | }`, 103 | }, 104 | ], 105 | isError: true, 106 | }; 107 | } 108 | } 109 | ); 110 | 111 | // 입금 내역 조회 도구 112 | server.tool( 113 | "fetchDeposits", 114 | "Fetch deposit history for a configured account", 115 | { 116 | accountName: z 117 | .string() 118 | .describe( 119 | "Account name defined in the configuration file (e.g., 'bybit_main')" 120 | ), 121 | code: z 122 | .string() 123 | .optional() 124 | .describe("Currency code (e.g., 'BTC', 'ETH')"), 125 | since: z 126 | .number() 127 | .optional() 128 | .describe("Timestamp in ms to fetch deposits since (optional)"), 129 | limit: z 130 | .number() 131 | .optional() 132 | .describe("Limit the number of deposits returned (optional)"), 133 | }, 134 | async ({ accountName, code, since, limit }) => { 135 | try { 136 | const exchange = ccxtServer.getExchangeInstance(accountName); 137 | 138 | // getExchangeInstance가 성공하면 인증은 보장됨 139 | 140 | // fetchDeposits 메서드가 지원되는지 확인 141 | if (!exchange.has["fetchDeposits"]) { 142 | return { 143 | content: [ 144 | { 145 | type: "text", 146 | text: `Account '${accountName}' (Exchange: ${exchange.id}) does not support fetching deposits`, 147 | }, 148 | ], 149 | isError: true, 150 | }; 151 | } 152 | 153 | const deposits = await exchange.fetchDeposits(code, since, limit); 154 | 155 | return { 156 | content: [ 157 | { 158 | type: "text", 159 | text: JSON.stringify(deposits, null, 2), 160 | }, 161 | ], 162 | }; 163 | } catch (error) { 164 | return { 165 | content: [ 166 | { 167 | type: "text", 168 | text: `Error fetching deposits for account '${accountName}': ${ 169 | (error as Error).message 170 | }`, 171 | }, 172 | ], 173 | isError: true, 174 | }; 175 | } 176 | } 177 | ); 178 | 179 | // 출금 내역 조회 도구 180 | server.tool( 181 | "fetchWithdrawals", 182 | "Fetch withdrawal history for a configured account", 183 | { 184 | accountName: z 185 | .string() 186 | .describe( 187 | "Account name defined in the configuration file (e.g., 'bybit_main')" 188 | ), 189 | code: z 190 | .string() 191 | .optional() 192 | .describe("Currency code (e.g., 'BTC', 'ETH')"), 193 | since: z 194 | .number() 195 | .optional() 196 | .describe("Timestamp in ms to fetch withdrawals since (optional)"), 197 | limit: z 198 | .number() 199 | .optional() 200 | .describe("Limit the number of withdrawals returned (optional)"), 201 | }, 202 | async ({ accountName, code, since, limit }) => { 203 | try { 204 | const exchange = ccxtServer.getExchangeInstance(accountName); 205 | 206 | // getExchangeInstance가 성공하면 인증은 보장됨 207 | 208 | // fetchWithdrawals 메서드가 지원되는지 확인 209 | if (!exchange.has["fetchWithdrawals"]) { 210 | return { 211 | content: [ 212 | { 213 | type: "text", 214 | text: `Account '${accountName}' (Exchange: ${exchange.id}) does not support fetching withdrawals`, 215 | }, 216 | ], 217 | isError: true, 218 | }; 219 | } 220 | 221 | const withdrawals = await exchange.fetchWithdrawals(code, since, limit); 222 | 223 | return { 224 | content: [ 225 | { 226 | type: "text", 227 | text: JSON.stringify(withdrawals, null, 2), 228 | }, 229 | ], 230 | }; 231 | } catch (error) { 232 | return { 233 | content: [ 234 | { 235 | type: "text", 236 | text: `Error fetching withdrawals for account '${accountName}': ${ 237 | (error as Error).message 238 | }`, 239 | }, 240 | ], 241 | isError: true, 242 | }; 243 | } 244 | } 245 | ); 246 | 247 | // 내 거래 내역 조회 도구 248 | server.tool( 249 | "fetchMyTrades", 250 | "Fetch personal trade history for a configured account", 251 | { 252 | accountName: z 253 | .string() 254 | .describe( 255 | "Account name defined in the configuration file (e.g., 'bybit_main')" 256 | ), 257 | symbol: z 258 | .string() 259 | .optional() 260 | .describe("Trading symbol (e.g., 'BTC/USDT')"), 261 | since: z 262 | .number() 263 | .optional() 264 | .describe("Timestamp in ms to fetch trades since (optional)"), 265 | limit: z 266 | .number() 267 | .optional() 268 | .describe("Limit the number of trades returned (optional)"), 269 | }, 270 | async ({ accountName, symbol, since, limit }) => { 271 | try { 272 | const exchange = ccxtServer.getExchangeInstance(accountName); 273 | 274 | // getExchangeInstance가 성공하면 인증은 보장됨 275 | 276 | // fetchMyTrades 메서드가 지원되는지 확인 277 | if (!exchange.has["fetchMyTrades"]) { 278 | return { 279 | content: [ 280 | { 281 | type: "text", 282 | text: `Account '${accountName}' (Exchange: ${exchange.id}) does not support fetching personal trades`, 283 | }, 284 | ], 285 | isError: true, 286 | }; 287 | } 288 | 289 | const trades = await exchange.fetchMyTrades(symbol, since, limit); 290 | 291 | return { 292 | content: [ 293 | { 294 | type: "text", 295 | text: JSON.stringify(trades, null, 2), 296 | }, 297 | ], 298 | }; 299 | } catch (error) { 300 | return { 301 | content: [ 302 | { 303 | type: "text", 304 | text: `Error fetching personal trades for account '${accountName}': ${ 305 | (error as Error).message 306 | }`, 307 | }, 308 | ], 309 | isError: true, 310 | }; 311 | } 312 | } 313 | ); 314 | } 315 | -------------------------------------------------------------------------------- /src/tools/analysis-tools.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * 거래 분석 관련 도구들을 정의합니다. 3 | * 이 파일은 거래 성과 분석, 승률, 수익률 계산 등의 기능을 제공합니다. 4 | */ 5 | 6 | import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; 7 | import { z } from "zod"; 8 | import { CcxtMcpServer } from "../server.js"; 9 | 10 | /** 11 | * 거래 분석 관련 도구들을 서버에 등록합니다. 12 | */ 13 | export function registerAnalysisTools( 14 | server: McpServer, 15 | ccxtServer: CcxtMcpServer 16 | ) { 17 | // 거래 성과 요약 분석 도구 18 | server.tool( 19 | "analyzeTradingPerformance", 20 | "Analyze trading performance for a configured account", 21 | { 22 | accountName: z 23 | .string() 24 | .describe( 25 | "Account name defined in the configuration file (e.g., 'bybit_main')" 26 | ), 27 | symbol: z 28 | .string() 29 | .optional() 30 | .describe("Optional trading symbol (e.g., 'BTC/USDT') to filter trades"), 31 | period: z 32 | .enum(["7d", "30d", "90d", "all"]) 33 | .default("30d") 34 | .describe("Analysis period: '7d', '30d', '90d', or 'all'"), 35 | }, 36 | async ({ accountName, symbol, period }) => { 37 | try { 38 | const exchange = ccxtServer.getExchangeInstance(accountName); 39 | 40 | // fetchMyTrades 메서드가 지원되는지 확인 41 | if (!exchange.has["fetchMyTrades"]) { 42 | return { 43 | content: [ 44 | { 45 | type: "text", 46 | text: `Account '${accountName}' (Exchange: ${exchange.id}) does not support fetching personal trades for analysis`, 47 | }, 48 | ], 49 | isError: true, 50 | }; 51 | } 52 | 53 | // 기간에 따른 since 값 계산 54 | const now = Date.now(); 55 | let since; 56 | switch (period) { 57 | case "7d": 58 | since = now - 7 * 24 * 60 * 60 * 1000; // 7일 59 | break; 60 | case "30d": 61 | since = now - 30 * 24 * 60 * 60 * 1000; // 30일 62 | break; 63 | case "90d": 64 | since = now - 90 * 24 * 60 * 60 * 1000; // 90일 65 | break; 66 | case "all": 67 | since = undefined; // 전체 데이터 68 | break; 69 | } 70 | 71 | // 거래 데이터 가져오기 72 | const trades = await exchange.fetchMyTrades(symbol, since, undefined); 73 | 74 | // 기본 분석 지표 계산 75 | const analysis = analyzeTradeData(trades, period); 76 | 77 | return { 78 | content: [ 79 | { 80 | type: "text", 81 | text: JSON.stringify(analysis, null, 2), 82 | }, 83 | ], 84 | }; 85 | } catch (error) { 86 | return { 87 | content: [ 88 | { 89 | type: "text", 90 | text: `Error analyzing trading performance for account '${accountName}': ${ 91 | (error as Error).message 92 | }`, 93 | }, 94 | ], 95 | isError: true, 96 | }; 97 | } 98 | } 99 | ); 100 | 101 | // 승률 및 수익률 분석 도구 102 | server.tool( 103 | "calculateWinRate", 104 | "Calculate win rate and profit metrics for a configured account", 105 | { 106 | accountName: z 107 | .string() 108 | .describe( 109 | "Account name defined in the configuration file (e.g., 'bybit_main')" 110 | ), 111 | symbol: z 112 | .string() 113 | .optional() 114 | .describe("Optional trading symbol (e.g., 'BTC/USDT') to filter trades"), 115 | period: z 116 | .enum(["7d", "30d", "all"]) 117 | .default("30d") 118 | .describe("Analysis period: '7d', '30d', or 'all'"), 119 | }, 120 | async ({ accountName, symbol, period }) => { 121 | try { 122 | const exchange = ccxtServer.getExchangeInstance(accountName); 123 | 124 | // fetchMyTrades 메서드가 지원되는지 확인 125 | if (!exchange.has["fetchMyTrades"]) { 126 | return { 127 | content: [ 128 | { 129 | type: "text", 130 | text: `Account '${accountName}' (Exchange: ${exchange.id}) does not support fetching personal trades for win rate calculation`, 131 | }, 132 | ], 133 | isError: true, 134 | }; 135 | } 136 | 137 | // 기간에 따른 since 값 계산 138 | const now = Date.now(); 139 | let since; 140 | switch (period) { 141 | case "7d": 142 | since = now - 7 * 24 * 60 * 60 * 1000; // 7일 143 | break; 144 | case "30d": 145 | since = now - 30 * 24 * 60 * 60 * 1000; // 30일 146 | break; 147 | case "all": 148 | since = undefined; // 전체 데이터 149 | break; 150 | } 151 | 152 | // 거래 데이터 가져오기 153 | const trades = await exchange.fetchMyTrades(symbol, since, undefined); 154 | 155 | // 승률 및 수익률 계산 156 | const metrics = calculateWinRateAndProfitMetrics(trades); 157 | 158 | return { 159 | content: [ 160 | { 161 | type: "text", 162 | text: JSON.stringify(metrics, null, 2), 163 | }, 164 | ], 165 | }; 166 | } catch (error) { 167 | return { 168 | content: [ 169 | { 170 | type: "text", 171 | text: `Error calculating win rate for account '${accountName}': ${ 172 | (error as Error).message 173 | }`, 174 | }, 175 | ], 176 | isError: true, 177 | }; 178 | } 179 | } 180 | ); 181 | 182 | // 최대 연속 손실/이익 분석 도구 183 | server.tool( 184 | "analyzeConsecutiveProfitLoss", 185 | "Analyze consecutive winning and losing trades", 186 | { 187 | accountName: z 188 | .string() 189 | .describe( 190 | "Account name defined in the configuration file (e.g., 'bybit_main')" 191 | ), 192 | symbol: z 193 | .string() 194 | .optional() 195 | .describe("Optional trading symbol (e.g., 'BTC/USDT') to filter trades"), 196 | period: z 197 | .enum(["30d", "all"]) 198 | .default("all") 199 | .describe("Analysis period: '30d' or 'all'"), 200 | }, 201 | async ({ accountName, symbol, period }) => { 202 | try { 203 | const exchange = ccxtServer.getExchangeInstance(accountName); 204 | 205 | // fetchMyTrades 메서드가 지원되는지 확인 206 | if (!exchange.has["fetchMyTrades"]) { 207 | return { 208 | content: [ 209 | { 210 | type: "text", 211 | text: `Account '${accountName}' (Exchange: ${exchange.id}) does not support fetching personal trades for consecutive analysis`, 212 | }, 213 | ], 214 | isError: true, 215 | }; 216 | } 217 | 218 | // 기간에 따른 since 값 계산 219 | const now = Date.now(); 220 | let since; 221 | switch (period) { 222 | case "30d": 223 | since = now - 30 * 24 * 60 * 60 * 1000; // 30일 224 | break; 225 | case "all": 226 | default: 227 | since = undefined; // 전체 데이터 228 | break; 229 | } 230 | 231 | // 거래 내역 가져오기 232 | const trades = await exchange.fetchMyTrades(symbol, since, undefined); 233 | 234 | // 최대 연속 손실/이익 계산 235 | const analysis = analyzeConsecutiveTrades(trades); 236 | 237 | return { 238 | content: [ 239 | { 240 | type: "text", 241 | text: JSON.stringify(analysis, null, 2), 242 | }, 243 | ], 244 | }; 245 | } catch (error) { 246 | return { 247 | content: [ 248 | { 249 | type: "text", 250 | text: `Error analyzing consecutive trades for account '${accountName}': ${ 251 | (error as Error).message 252 | }`, 253 | }, 254 | ], 255 | isError: true, 256 | }; 257 | } 258 | } 259 | ); 260 | 261 | // 월간/일간 수익률 분석 도구 262 | server.tool( 263 | "analyzePeriodicReturns", 264 | "Analyze daily and monthly returns for a configured account", 265 | { 266 | accountName: z 267 | .string() 268 | .describe( 269 | "Account name defined in the configuration file (e.g., 'bybit_main')" 270 | ), 271 | symbol: z 272 | .string() 273 | .optional() 274 | .describe("Optional trading symbol (e.g., 'BTC/USDT') to filter trades"), 275 | period: z 276 | .enum(["30d", "90d", "180d", "1y"]) 277 | .default("90d") 278 | .describe("Analysis period: '30d', '90d', '180d', or '1y'"), 279 | interval: z 280 | .enum(["daily", "weekly", "monthly"]) 281 | .default("daily") 282 | .describe("Return calculation interval"), 283 | }, 284 | async ({ accountName, symbol, period, interval }) => { 285 | try { 286 | const exchange = ccxtServer.getExchangeInstance(accountName); 287 | 288 | // fetchMyTrades 메서드가 지원되는지 확인 289 | if (!exchange.has["fetchMyTrades"]) { 290 | return { 291 | content: [ 292 | { 293 | type: "text", 294 | text: `Account '${accountName}' (Exchange: ${exchange.id}) does not support fetching personal trades for periodic returns analysis`, 295 | }, 296 | ], 297 | isError: true, 298 | }; 299 | } 300 | 301 | // 기간에 따른 since 값 계산 302 | const now = Date.now(); 303 | let since; 304 | switch (period) { 305 | case "30d": 306 | since = now - 30 * 24 * 60 * 60 * 1000; 307 | break; 308 | case "90d": 309 | since = now - 90 * 24 * 60 * 60 * 1000; 310 | break; 311 | case "180d": 312 | since = now - 180 * 24 * 60 * 60 * 1000; 313 | break; 314 | case "1y": 315 | since = now - 365 * 24 * 60 * 60 * 1000; 316 | break; 317 | } 318 | 319 | // 거래 내역 가져오기 320 | const trades = await exchange.fetchMyTrades(symbol, since, undefined); 321 | 322 | // 기간별 수익률 계산 323 | const returns = calculatePeriodicReturns(trades, interval); 324 | 325 | return { 326 | content: [ 327 | { 328 | type: "text", 329 | text: JSON.stringify(returns, null, 2), 330 | }, 331 | ], 332 | }; 333 | } catch (error) { 334 | return { 335 | content: [ 336 | { 337 | type: "text", 338 | text: `Error analyzing periodic returns for account '${accountName}': ${ 339 | (error as Error).message 340 | }`, 341 | }, 342 | ], 343 | isError: true, 344 | }; 345 | } 346 | } 347 | ); 348 | } 349 | 350 | /** 351 | * 거래 데이터를 분석하여 성과 지표를 계산합니다. 352 | */ 353 | function analyzeTradeData(trades: any[], period: string) { 354 | if (!trades || trades.length === 0) { 355 | return { 356 | period, 357 | totalTrades: 0, 358 | message: "No trades found for the specified period.", 359 | }; 360 | } 361 | 362 | // 거래 데이터 정렬 (시간순) 363 | trades.sort((a, b) => a.timestamp - b.timestamp); 364 | 365 | // 기본 지표 계산 366 | let totalProfit = 0; 367 | let totalLoss = 0; 368 | let winCount = 0; 369 | let lossCount = 0; 370 | let totalFees = 0; 371 | let largestWin = 0; 372 | let largestLoss = 0; 373 | let totalVolume = 0; 374 | 375 | // 거래별 분석 376 | trades.forEach((trade) => { 377 | // 수수료 계산 378 | const fee = trade.fee?.cost || 0; 379 | totalFees += fee; 380 | 381 | // 거래량 계산 382 | totalVolume += trade.amount * trade.price; 383 | 384 | // 손익 계산 (단순화된 버전 - 실제로는 포지션 추적 필요) 385 | const cost = trade.amount * trade.price; 386 | const profit = trade.side === "buy" ? -cost : cost; // 매우 단순화된 계산 387 | 388 | if (profit > 0) { 389 | totalProfit += profit; 390 | winCount++; 391 | largestWin = Math.max(largestWin, profit); 392 | } else if (profit < 0) { 393 | totalLoss += Math.abs(profit); 394 | lossCount++; 395 | largestLoss = Math.max(largestLoss, Math.abs(profit)); 396 | } 397 | }); 398 | 399 | const totalTrades = trades.length; 400 | const winRate = totalTrades > 0 ? (winCount / totalTrades) * 100 : 0; 401 | const netProfit = totalProfit - totalLoss - totalFees; 402 | const profitFactor = totalLoss > 0 ? totalProfit / totalLoss : totalProfit > 0 ? Infinity : 0; 403 | 404 | // 거래 패턴 분석 405 | const firstTradeDate = new Date(trades[0].timestamp); 406 | const lastTradeDate = new Date(trades[trades.length - 1].timestamp); 407 | const tradingDurationDays = (lastTradeDate.getTime() - firstTradeDate.getTime()) / (1000 * 60 * 60 * 24); 408 | const tradesPerDay = tradingDurationDays > 0 ? totalTrades / tradingDurationDays : totalTrades; 409 | 410 | return { 411 | period, 412 | totalTrades, 413 | winCount, 414 | lossCount, 415 | winRate: winRate.toFixed(2) + "%", 416 | totalProfit: totalProfit.toFixed(8), 417 | totalLoss: totalLoss.toFixed(8), 418 | netProfit: netProfit.toFixed(8), 419 | totalFees: totalFees.toFixed(8), 420 | profitFactor: profitFactor.toFixed(2), 421 | largestWin: largestWin.toFixed(8), 422 | largestLoss: largestLoss.toFixed(8), 423 | totalVolume: totalVolume.toFixed(2), 424 | tradingPeriod: { 425 | firstTrade: firstTradeDate.toISOString(), 426 | lastTrade: lastTradeDate.toISOString(), 427 | durationDays: tradingDurationDays.toFixed(1), 428 | tradesPerDay: tradesPerDay.toFixed(1), 429 | } 430 | }; 431 | } 432 | 433 | /** 434 | * 거래 데이터를 분석하여 승률과 수익률 지표를 계산합니다. 435 | */ 436 | function calculateWinRateAndProfitMetrics(trades: any[]) { 437 | if (!trades || trades.length === 0) { 438 | return { 439 | totalTrades: 0, 440 | message: "No trades found for the specified period.", 441 | }; 442 | } 443 | 444 | // 거래를 시간순으로 정렬 445 | trades.sort((a, b) => a.timestamp - b.timestamp); 446 | 447 | // 포지션별 거래 그룹화 (매우 단순화된 버전) 448 | // 실제로는 더 복잡한 포지션 추적 로직이 필요할 수 있음 449 | const positions: any[] = []; 450 | let currentPosition: any = null; 451 | 452 | trades.forEach((trade) => { 453 | if (!currentPosition) { 454 | currentPosition = { 455 | symbol: trade.symbol, 456 | side: trade.side, 457 | entryTime: trade.datetime, 458 | entryPrice: trade.price, 459 | amount: trade.amount, 460 | cost: trade.amount * trade.price, 461 | fees: trade.fee?.cost || 0, 462 | exitTime: null, 463 | exitPrice: null, 464 | profit: null, 465 | }; 466 | } else if (currentPosition.side !== trade.side && currentPosition.symbol === trade.symbol) { 467 | // 반대 방향 거래는 포지션 종료로 간주 468 | currentPosition.exitTime = trade.datetime; 469 | currentPosition.exitPrice = trade.price; 470 | 471 | // 손익 계산 (매우 단순화된 버전) 472 | if (currentPosition.side === "buy") { 473 | // 매수 후 매도 474 | currentPosition.profit = (trade.price - currentPosition.entryPrice) * currentPosition.amount - currentPosition.fees - (trade.fee?.cost || 0); 475 | } else { 476 | // 매도 후 매수 477 | currentPosition.profit = (currentPosition.entryPrice - trade.price) * currentPosition.amount - currentPosition.fees - (trade.fee?.cost || 0); 478 | } 479 | 480 | positions.push(currentPosition); 481 | currentPosition = null; 482 | } else { 483 | // 같은 방향 거래는 포지션에 추가 (average down/up) 484 | const newAmount = currentPosition.amount + trade.amount; 485 | const newCost = currentPosition.cost + (trade.amount * trade.price); 486 | currentPosition.entryPrice = newCost / newAmount; 487 | currentPosition.amount = newAmount; 488 | currentPosition.cost = newCost; 489 | currentPosition.fees += trade.fee?.cost || 0; 490 | } 491 | }); 492 | 493 | // 완료된 포지션만 분석 494 | const completedPositions = positions.filter(p => p.exitTime !== null); 495 | 496 | if (completedPositions.length === 0) { 497 | return { 498 | totalTrades: trades.length, 499 | completedPositions: 0, 500 | message: "No completed positions found for analysis.", 501 | }; 502 | } 503 | 504 | // 기본 지표 계산 505 | let winCount = 0; 506 | let lossCount = 0; 507 | let totalProfit = 0; 508 | let totalLoss = 0; 509 | let maxConsecutiveWins = 0; 510 | let maxConsecutiveLosses = 0; 511 | let currentConsecutiveWins = 0; 512 | let currentConsecutiveLosses = 0; 513 | 514 | completedPositions.forEach(position => { 515 | if (position.profit > 0) { 516 | winCount++; 517 | totalProfit += position.profit; 518 | currentConsecutiveWins++; 519 | currentConsecutiveLosses = 0; 520 | maxConsecutiveWins = Math.max(maxConsecutiveWins, currentConsecutiveWins); 521 | } else { 522 | lossCount++; 523 | totalLoss += Math.abs(position.profit); 524 | currentConsecutiveLosses++; 525 | currentConsecutiveWins = 0; 526 | maxConsecutiveLosses = Math.max(maxConsecutiveLosses, currentConsecutiveLosses); 527 | } 528 | }); 529 | 530 | const totalPositions = completedPositions.length; 531 | const winRate = (winCount / totalPositions) * 100; 532 | const averageWin = winCount > 0 ? totalProfit / winCount : 0; 533 | const averageLoss = lossCount > 0 ? totalLoss / lossCount : 0; 534 | const profitFactor = totalLoss > 0 ? totalProfit / totalLoss : totalProfit > 0 ? Infinity : 0; 535 | const expectancy = (winRate / 100 * averageWin) - ((100 - winRate) / 100 * averageLoss); 536 | 537 | // R-multiple 계산 (평균 수익 / 평균 손실) 538 | const rMultiple = averageLoss > 0 ? averageWin / averageLoss : 0; 539 | 540 | return { 541 | totalTrades: trades.length, 542 | completedPositions: totalPositions, 543 | winCount, 544 | lossCount, 545 | winRate: winRate.toFixed(2) + "%", 546 | profitFactor: profitFactor.toFixed(2), 547 | netProfit: (totalProfit - totalLoss).toFixed(8), 548 | averageWin: averageWin.toFixed(8), 549 | averageLoss: averageLoss.toFixed(8), 550 | rMultiple: rMultiple.toFixed(2), 551 | expectancy: expectancy.toFixed(8), 552 | maxConsecutiveWins, 553 | maxConsecutiveLosses, 554 | firstTradeDate: completedPositions[0].entryTime, 555 | lastTradeDate: completedPositions[completedPositions.length - 1].exitTime, 556 | }; 557 | } 558 | 559 | /** 560 | * 최대 연속 손실/이익 분석을 수행합니다. 561 | */ 562 | function analyzeConsecutiveTrades(trades: any[]) { 563 | if (!trades || trades.length === 0) { 564 | return { 565 | totalTrades: 0, 566 | message: "No trades found for the specified period.", 567 | }; 568 | } 569 | 570 | // 거래를 시간순으로 정렬 571 | trades.sort((a, b) => a.timestamp - b.timestamp); 572 | 573 | // 간단한 분석을 위해 거래를 승/패로 변환 (단순화된 버전) 574 | const tradeResults: boolean[] = []; 575 | let currentSide = null; 576 | let entryPrice = 0; 577 | 578 | trades.forEach((trade) => { 579 | if (currentSide === null) { 580 | // 첫 거래는 진입으로 간주 581 | currentSide = trade.side; 582 | entryPrice = trade.price; 583 | } else if (currentSide !== trade.side) { 584 | // 반대 방향 거래는 포지션 종료로 간주 585 | const isWin = (currentSide === 'buy' && trade.price > entryPrice) || 586 | (currentSide === 'sell' && trade.price < entryPrice); 587 | tradeResults.push(isWin); 588 | 589 | // 새로운 포지션 시작 590 | currentSide = trade.side; 591 | entryPrice = trade.price; 592 | } 593 | }); 594 | 595 | // 연속 승/패 분석 596 | let maxConsecutiveWins = 0; 597 | let maxConsecutiveLosses = 0; 598 | let currentConsecutiveWins = 0; 599 | let currentConsecutiveLosses = 0; 600 | let currentWinStreak = 0; 601 | let currentLossStreak = 0; 602 | let maxWinStreak = { count: 0, startIndex: 0, endIndex: 0 }; 603 | let maxLossStreak = { count: 0, startIndex: 0, endIndex: 0 }; 604 | 605 | tradeResults.forEach((isWin, index) => { 606 | if (isWin) { 607 | currentConsecutiveWins++; 608 | currentConsecutiveLosses = 0; 609 | 610 | if (currentWinStreak === 0) { 611 | currentWinStreak = 1; 612 | currentLossStreak = 0; 613 | } else { 614 | currentWinStreak++; 615 | } 616 | 617 | if (currentWinStreak > maxWinStreak.count) { 618 | maxWinStreak = { 619 | count: currentWinStreak, 620 | startIndex: index - currentWinStreak + 1, 621 | endIndex: index 622 | }; 623 | } 624 | } else { 625 | currentConsecutiveLosses++; 626 | currentConsecutiveWins = 0; 627 | 628 | if (currentLossStreak === 0) { 629 | currentLossStreak = 1; 630 | currentWinStreak = 0; 631 | } else { 632 | currentLossStreak++; 633 | } 634 | 635 | if (currentLossStreak > maxLossStreak.count) { 636 | maxLossStreak = { 637 | count: currentLossStreak, 638 | startIndex: index - currentLossStreak + 1, 639 | endIndex: index 640 | }; 641 | } 642 | } 643 | 644 | maxConsecutiveWins = Math.max(maxConsecutiveWins, currentConsecutiveWins); 645 | maxConsecutiveLosses = Math.max(maxConsecutiveLosses, currentConsecutiveLosses); 646 | }); 647 | 648 | // 최대 연속 승/패 시 총 손익 계산 649 | const maxWinStreakTrades = maxWinStreak.count > 0 650 | ? tradeResults.slice(maxWinStreak.startIndex, maxWinStreak.endIndex + 1) 651 | : []; 652 | 653 | const maxLossStreakTrades = maxLossStreak.count > 0 654 | ? tradeResults.slice(maxLossStreak.startIndex, maxLossStreak.endIndex + 1) 655 | : []; 656 | 657 | return { 658 | totalCompletedTrades: tradeResults.length, 659 | winCount: tradeResults.filter(result => result).length, 660 | lossCount: tradeResults.filter(result => !result).length, 661 | maxConsecutiveWins, 662 | maxConsecutiveLosses, 663 | maxWinStreak: { 664 | count: maxWinStreak.count, 665 | startDate: maxWinStreak.count > 0 ? trades[maxWinStreak.startIndex].datetime : null, 666 | endDate: maxWinStreak.count > 0 ? trades[maxWinStreak.endIndex].datetime : null, 667 | }, 668 | maxLossStreak: { 669 | count: maxLossStreak.count, 670 | startDate: maxLossStreak.count > 0 ? trades[maxLossStreak.startIndex].datetime : null, 671 | endDate: maxLossStreak.count > 0 ? trades[maxLossStreak.endIndex].datetime : null, 672 | }, 673 | currentStreakType: currentConsecutiveWins > 0 ? "win" : "loss", 674 | currentStreakCount: Math.max(currentConsecutiveWins, currentConsecutiveLosses), 675 | }; 676 | } 677 | 678 | /** 679 | * 일간/주간/월간 수익률을 계산합니다. 680 | */ 681 | function calculatePeriodicReturns(trades: any[], interval: string) { 682 | if (!trades || trades.length === 0) { 683 | return { 684 | totalTrades: 0, 685 | message: "No trades found for the specified period.", 686 | }; 687 | } 688 | 689 | // 거래를 시간순으로 정렬 690 | trades.sort((a, b) => a.timestamp - b.timestamp); 691 | 692 | // 기간별로 그룹화 693 | const periodicData: Record = {}; 694 | 695 | trades.forEach(trade => { 696 | const date = new Date(trade.timestamp); 697 | let key: string; 698 | 699 | switch(interval) { 700 | case 'weekly': 701 | // 주차 계산 (ISO 주 - 1부터 53까지) 702 | const weekOfYear = getWeekNumber(date); 703 | key = `${date.getFullYear()}-W${weekOfYear}`; 704 | break; 705 | case 'monthly': 706 | // 월 (1월은 0) 707 | key = `${date.getFullYear()}-${(date.getMonth() + 1).toString().padStart(2, '0')}`; 708 | break; 709 | case 'daily': 710 | default: 711 | // 일 (YYYY-MM-DD) 712 | key = date.toISOString().split('T')[0]; 713 | } 714 | 715 | if (!periodicData[key]) { 716 | periodicData[key] = { profit: 0, trades: 0 }; 717 | } 718 | 719 | // 단순화된 손익 계산 720 | const profit = trade.side === 'buy' 721 | ? -(trade.amount * trade.price) 722 | : (trade.amount * trade.price); 723 | 724 | periodicData[key].profit += profit - (trade.fee?.cost || 0); 725 | periodicData[key].trades++; 726 | }); 727 | 728 | // 결과 처리 729 | const returns = Object.entries(periodicData).map(([period, data]) => ({ 730 | period, 731 | profit: data.profit.toFixed(8), 732 | trades: data.trades 733 | })).sort((a, b) => a.period.localeCompare(b.period)); 734 | 735 | // 통계 계산 736 | const profitValues = returns.map(r => parseFloat(r.profit)); 737 | const totalProfit = profitValues.reduce((sum, profit) => sum + profit, 0); 738 | const averagePeriodProfit = profitValues.length > 0 739 | ? totalProfit / profitValues.length 740 | : 0; 741 | 742 | const positiveReturns = profitValues.filter(p => p > 0); 743 | const negativeReturns = profitValues.filter(p => p < 0); 744 | 745 | return { 746 | interval, 747 | totalPeriods: returns.length, 748 | totalProfit: totalProfit.toFixed(8), 749 | averagePeriodProfit: averagePeriodProfit.toFixed(8), 750 | profitablePeriods: positiveReturns.length, 751 | lossPeriods: negativeReturns.length, 752 | profitablePeriodRatio: returns.length > 0 753 | ? ((positiveReturns.length / returns.length) * 100).toFixed(2) + '%' 754 | : '0%', 755 | bestPeriod: profitValues.length > 0 756 | ? returns[profitValues.indexOf(Math.max(...profitValues))] 757 | : null, 758 | worstPeriod: profitValues.length > 0 759 | ? returns[profitValues.indexOf(Math.min(...profitValues))] 760 | : null, 761 | periodicReturns: returns 762 | }; 763 | } 764 | 765 | /** 766 | * 날짜의 ISO 주(week) 번호를 계산합니다. 767 | */ 768 | function getWeekNumber(date: Date): number { 769 | const d = new Date(date); 770 | d.setHours(0, 0, 0, 0); 771 | d.setDate(d.getDate() + 3 - ((d.getDay() + 6) % 7)); 772 | const week1 = new Date(d.getFullYear(), 0, 4); 773 | return 1 + Math.round(((d.getTime() - week1.getTime()) / 86400000 - 3 + ((week1.getDay() + 6) % 7)) / 7); 774 | } -------------------------------------------------------------------------------- /src/tools/market-tools.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * 시장 관련 도구들을 정의합니다. 3 | */ 4 | 5 | import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; 6 | import { z } from "zod"; 7 | import { CcxtMcpServer } from '../server.js'; 8 | 9 | /** 10 | * 시장 관련 도구들을 서버에 등록합니다. 11 | */ 12 | export function registerMarketTools(server: McpServer, ccxtServer: CcxtMcpServer) { 13 | // 시장 정보 조회 도구 14 | server.tool( 15 | "fetchMarkets", 16 | "Fetch markets from a cryptocurrency exchange", 17 | { 18 | exchangeId: z.string().describe("Exchange ID (e.g., 'binance', 'coinbase')") 19 | }, 20 | async ({ exchangeId }) => { 21 | try { 22 | // 공개 인스턴스 사용 23 | const exchange = ccxtServer.getPublicExchangeInstance(exchangeId); 24 | const markets = await exchange.loadMarkets(); 25 | 26 | return { 27 | content: [ 28 | { 29 | type: "text", 30 | text: JSON.stringify(markets, null, 2) 31 | } 32 | ] 33 | }; 34 | } catch (error) { 35 | return { 36 | content: [ 37 | { 38 | type: "text", 39 | text: `Error fetching markets: ${(error as Error).message}` 40 | } 41 | ], 42 | isError: true 43 | }; 44 | } 45 | } 46 | ); 47 | 48 | // 티커 정보 조회 도구 49 | server.tool( 50 | "fetchTicker", 51 | "Fetch ticker information for a symbol on an exchange", 52 | { 53 | exchangeId: z.string().describe("Exchange ID (e.g., 'binance', 'coinbase')"), 54 | symbol: z.string().describe("Trading symbol (e.g., 'BTC/USDT')") 55 | }, 56 | async ({ exchangeId, symbol }) => { 57 | try { 58 | // 공개 인스턴스 사용 59 | const exchange = ccxtServer.getPublicExchangeInstance(exchangeId); 60 | const ticker = await exchange.fetchTicker(symbol); 61 | 62 | return { 63 | content: [ 64 | { 65 | type: "text", 66 | text: JSON.stringify(ticker, null, 2) 67 | } 68 | ] 69 | }; 70 | } catch (error) { 71 | return { 72 | content: [ 73 | { 74 | type: "text", 75 | text: `Error fetching ticker: ${(error as Error).message}` 76 | } 77 | ], 78 | isError: true 79 | }; 80 | } 81 | } 82 | ); 83 | 84 | // 모든 티커 정보 조회 도구 85 | server.tool( 86 | "fetchTickers", 87 | "Fetch all tickers from an exchange", 88 | { 89 | exchangeId: z.string().describe("Exchange ID (e.g., 'binance', 'coinbase')"), 90 | symbols: z.array(z.string()).optional().describe("Optional list of specific symbols to fetch") 91 | }, 92 | async ({ exchangeId, symbols }) => { 93 | try { 94 | // 공개 인스턴스 사용 95 | const exchange = ccxtServer.getPublicExchangeInstance(exchangeId); 96 | const tickers = await exchange.fetchTickers(symbols); 97 | 98 | return { 99 | content: [ 100 | { 101 | type: "text", 102 | text: JSON.stringify(tickers, null, 2) 103 | } 104 | ] 105 | }; 106 | } catch (error) { 107 | return { 108 | content: [ 109 | { 110 | type: "text", 111 | text: `Error fetching tickers: ${(error as Error).message}` 112 | } 113 | ], 114 | isError: true 115 | }; 116 | } 117 | } 118 | ); 119 | 120 | // 주문장 정보 조회 도구 121 | server.tool( 122 | "fetchOrderBook", 123 | "Fetch order book for a symbol on an exchange", 124 | { 125 | exchangeId: z.string().describe("Exchange ID (e.g., 'binance', 'coinbase')"), 126 | symbol: z.string().describe("Trading symbol (e.g., 'BTC/USDT')"), 127 | limit: z.number().optional().describe("Limit the number of orders returned (optional)") 128 | }, 129 | async ({ exchangeId, symbol, limit }) => { 130 | try { 131 | // 공개 인스턴스 사용 132 | const exchange = ccxtServer.getPublicExchangeInstance(exchangeId); 133 | const orderbook = await exchange.fetchOrderBook(symbol, limit); 134 | 135 | return { 136 | content: [ 137 | { 138 | type: "text", 139 | text: JSON.stringify(orderbook, null, 2) 140 | } 141 | ] 142 | }; 143 | } catch (error) { 144 | return { 145 | content: [ 146 | { 147 | type: "text", 148 | text: `Error fetching order book: ${(error as Error).message}` 149 | } 150 | ], 151 | isError: true 152 | }; 153 | } 154 | } 155 | ); 156 | 157 | // 거래 내역 조회 도구 158 | server.tool( 159 | "fetchTrades", 160 | "Fetch recent trades for a symbol on an exchange", 161 | { 162 | exchangeId: z.string().describe("Exchange ID (e.g., 'binance', 'coinbase')"), 163 | symbol: z.string().describe("Trading symbol (e.g., 'BTC/USDT')"), 164 | since: z.number().optional().describe("Timestamp in ms to fetch trades since (optional)"), 165 | limit: z.number().optional().describe("Limit the number of trades returned (optional)") 166 | }, 167 | async ({ exchangeId, symbol, since, limit }) => { 168 | try { 169 | // 공개 인스턴스 사용 170 | const exchange = ccxtServer.getPublicExchangeInstance(exchangeId); 171 | const trades = await exchange.fetchTrades(symbol, since, limit); 172 | 173 | return { 174 | content: [ 175 | { 176 | type: "text", 177 | text: JSON.stringify(trades, null, 2) 178 | } 179 | ] 180 | }; 181 | } catch (error) { 182 | return { 183 | content: [ 184 | { 185 | type: "text", 186 | text: `Error fetching trades: ${(error as Error).message}` 187 | } 188 | ], 189 | isError: true 190 | }; 191 | } 192 | } 193 | ); 194 | 195 | // OHLCV 데이터 조회 도구 (캔들스틱 차트) 196 | server.tool( 197 | "fetchOHLCV", 198 | "Fetch OHLCV candlestick data for a symbol on an exchange", 199 | { 200 | exchangeId: z.string().describe("Exchange ID (e.g., 'binance', 'coinbase')"), 201 | symbol: z.string().describe("Trading symbol (e.g., 'BTC/USDT')"), 202 | timeframe: z.string().default("1h").describe("Timeframe (e.g., '1m', '5m', '1h', '1d')"), 203 | since: z.number().optional().describe("Timestamp in ms to fetch data since (optional)"), 204 | limit: z.number().optional().describe("Limit the number of candles returned (optional)") 205 | }, 206 | async ({ exchangeId, symbol, timeframe, since, limit }) => { 207 | try { 208 | // 공개 인스턴스 사용 209 | const exchange = ccxtServer.getPublicExchangeInstance(exchangeId); 210 | 211 | // 거래소가 OHLCV 데이터를 지원하는지 확인 212 | if (!exchange.has['fetchOHLCV']) { 213 | return { 214 | content: [ 215 | { 216 | type: "text", 217 | text: `Exchange ${exchangeId} does not support OHLCV data fetching` 218 | } 219 | ], 220 | isError: true 221 | }; 222 | } 223 | 224 | const ohlcv = await exchange.fetchOHLCV(symbol, timeframe, since, limit); 225 | 226 | return { 227 | content: [ 228 | { 229 | type: "text", 230 | text: JSON.stringify(ohlcv, null, 2) 231 | } 232 | ] 233 | }; 234 | } catch (error) { 235 | return { 236 | content: [ 237 | { 238 | type: "text", 239 | text: `Error fetching OHLCV data: ${(error as Error).message}` 240 | } 241 | ], 242 | isError: true 243 | }; 244 | } 245 | } 246 | ); 247 | } 248 | -------------------------------------------------------------------------------- /src/tools/order-tools.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * 주문 관련 도구들을 정의합니다. 3 | */ 4 | 5 | import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; 6 | import { z } from "zod"; 7 | import { CcxtMcpServer } from "../server.js"; 8 | 9 | /** 10 | * 주문 관련 도구들을 서버에 등록합니다. 11 | */ 12 | export function registerOrderTools( 13 | server: McpServer, 14 | ccxtServer: CcxtMcpServer, 15 | ) { 16 | // 주문 생성 도구 17 | server.tool( 18 | "createOrder", 19 | "Create a new order using a configured account", 20 | { 21 | accountName: z 22 | .string() 23 | .describe( 24 | "Account name defined in the configuration file (e.g., 'bybit_main')" 25 | ), 26 | symbol: z.string().describe("Trading symbol (e.g., 'BTC/USDT')"), 27 | type: z 28 | .enum(["market", "limit"]) 29 | .describe("Order type: 'market' or 'limit'"), 30 | side: z.enum(["buy", "sell"]).describe("Order side: 'buy' or 'sell'"), 31 | amount: z.number().describe("Amount of base currency to trade"), 32 | price: z 33 | .number() 34 | .optional() 35 | .describe("Price per unit (required for limit orders)"), 36 | params: z 37 | .record(z.any()) 38 | .optional() 39 | .describe("Additional exchange-specific parameters"), 40 | }, 41 | async ({ 42 | accountName, 43 | symbol, 44 | type, 45 | side, 46 | amount, 47 | price, 48 | params, 49 | }) => { 50 | try { 51 | const exchange = ccxtServer.getExchangeInstance(accountName); 52 | 53 | // getExchangeInstance가 성공하면 인증은 보장됨 54 | 55 | // 주문 유형이 limit인데 가격이 없는 경우 56 | if (type === "limit" && price === undefined) { 57 | return { 58 | content: [ 59 | { 60 | type: "text", 61 | text: "Price is required for limit orders", 62 | }, 63 | ], 64 | isError: true, 65 | }; 66 | } 67 | 68 | const order = await exchange.createOrder( 69 | symbol, 70 | type, 71 | side, 72 | amount, 73 | price, 74 | params, 75 | ); 76 | 77 | return { 78 | content: [ 79 | { 80 | type: "text", 81 | text: JSON.stringify(order, null, 2), 82 | }, 83 | ], 84 | }; 85 | } catch (error) { 86 | return { 87 | content: [ 88 | { 89 | type: "text", 90 | text: `Error creating order for account '${accountName}': ${ 91 | (error as Error).message 92 | }`, 93 | }, 94 | ], 95 | isError: true, 96 | }; 97 | } 98 | }, 99 | ); 100 | 101 | // 주문 취소 도구 102 | server.tool( 103 | "cancelOrder", 104 | "Cancel an existing order using a configured account", 105 | { 106 | accountName: z 107 | .string() 108 | .describe( 109 | "Account name defined in the configuration file (e.g., 'bybit_main')" 110 | ), 111 | id: z.string().describe("Order ID to cancel"), 112 | symbol: z.string().describe("Trading symbol (e.g., 'BTC/USDT')"), 113 | params: z 114 | .record(z.any()) 115 | .optional() 116 | .describe("Additional exchange-specific parameters"), 117 | }, 118 | async ({ accountName, id, symbol, params }) => { 119 | try { 120 | const exchange = ccxtServer.getExchangeInstance(accountName); 121 | 122 | // getExchangeInstance가 성공하면 인증은 보장됨 123 | 124 | const result = await exchange.cancelOrder(id, symbol, params); 125 | 126 | return { 127 | content: [ 128 | { 129 | type: "text", 130 | text: JSON.stringify(result, null, 2), 131 | }, 132 | ], 133 | }; 134 | } catch (error) { 135 | return { 136 | content: [ 137 | { 138 | type: "text", 139 | text: `Error canceling order for account '${accountName}': ${ 140 | (error as Error).message 141 | }`, 142 | }, 143 | ], 144 | isError: true, 145 | }; 146 | } 147 | }, 148 | ); 149 | 150 | // 주문 조회 도구 151 | server.tool( 152 | "fetchOrder", 153 | "Fetch information about a specific order using a configured account", 154 | { 155 | accountName: z 156 | .string() 157 | .describe( 158 | "Account name defined in the configuration file (e.g., 'bybit_main')" 159 | ), 160 | id: z.string().describe("Order ID to fetch"), 161 | symbol: z.string().describe("Trading symbol (e.g., 'BTC/USDT')"), 162 | params: z 163 | .record(z.any()) 164 | .optional() 165 | .describe("Additional exchange-specific parameters"), 166 | }, 167 | async ({ accountName, id, symbol, params }) => { 168 | try { 169 | const exchange = ccxtServer.getExchangeInstance(accountName); 170 | 171 | // getExchangeInstance가 성공하면 인증은 보장됨 172 | 173 | // fetchOrder 메서드가 지원되는지 확인 174 | if (!exchange.has["fetchOrder"]) { 175 | return { 176 | content: [ 177 | { 178 | type: "text", 179 | text: `Account '${accountName}' (Exchange: ${exchange.id}) does not support fetching order details`, 180 | }, 181 | ], 182 | isError: true, 183 | }; 184 | } 185 | 186 | const order = await exchange.fetchOrder(id, symbol, params); 187 | 188 | return { 189 | content: [ 190 | { 191 | type: "text", 192 | text: JSON.stringify(order, null, 2), 193 | }, 194 | ], 195 | }; 196 | } catch (error) { 197 | return { 198 | content: [ 199 | { 200 | type: "text", 201 | text: `Error fetching order for account '${accountName}': ${ 202 | (error as Error).message 203 | }`, 204 | }, 205 | ], 206 | isError: true, 207 | }; 208 | } 209 | }, 210 | ); 211 | 212 | // 열린 주문 조회 도구 213 | server.tool( 214 | "fetchOpenOrders", 215 | "Fetch all open orders using a configured account", 216 | { 217 | accountName: z 218 | .string() 219 | .describe( 220 | "Account name defined in the configuration file (e.g., 'bybit_main')" 221 | ), 222 | symbol: z 223 | .string() 224 | .optional() 225 | .describe("Trading symbol (e.g., 'BTC/USDT')"), 226 | since: z 227 | .number() 228 | .optional() 229 | .describe("Timestamp in ms to fetch orders since (optional)"), 230 | limit: z 231 | .number() 232 | .optional() 233 | .describe("Limit the number of orders returned (optional)"), 234 | params: z 235 | .record(z.any()) 236 | .optional() 237 | .describe("Additional exchange-specific parameters"), 238 | }, 239 | async ({ accountName, symbol, since, limit, params }) => { 240 | try { 241 | const exchange = ccxtServer.getExchangeInstance(accountName); 242 | 243 | // getExchangeInstance가 성공하면 인증은 보장됨 244 | 245 | // fetchOpenOrders 메서드가 지원되는지 확인 246 | if (!exchange.has["fetchOpenOrders"]) { 247 | return { 248 | content: [ 249 | { 250 | type: "text", 251 | text: `Account '${accountName}' (Exchange: ${exchange.id}) does not support fetching open orders`, 252 | }, 253 | ], 254 | isError: true, 255 | }; 256 | } 257 | 258 | const openOrders = await exchange.fetchOpenOrders( 259 | symbol, 260 | since, 261 | limit, 262 | params, 263 | ); 264 | 265 | return { 266 | content: [ 267 | { 268 | type: "text", 269 | text: JSON.stringify(openOrders, null, 2), 270 | }, 271 | ], 272 | }; 273 | } catch (error) { 274 | return { 275 | content: [ 276 | { 277 | type: "text", 278 | text: `Error fetching open orders for account '${accountName}': ${ 279 | (error as Error).message 280 | }`, 281 | }, 282 | ], 283 | isError: true, 284 | }; 285 | } 286 | }, 287 | ); 288 | 289 | // 마감된 주문 조회 도구 290 | server.tool( 291 | "fetchClosedOrders", 292 | "Fetch all closed orders using a configured account", 293 | { 294 | accountName: z 295 | .string() 296 | .describe( 297 | "Account name defined in the configuration file (e.g., 'bybit_main')" 298 | ), 299 | symbol: z 300 | .string() 301 | .optional() 302 | .describe("Trading symbol (e.g., 'BTC/USDT')"), 303 | since: z 304 | .number() 305 | .optional() 306 | .describe("Timestamp in ms to fetch orders since (optional)"), 307 | limit: z 308 | .number() 309 | .optional() 310 | .describe("Limit the number of orders returned (optional)"), 311 | params: z 312 | .record(z.any()) 313 | .optional() 314 | .describe("Additional exchange-specific parameters"), 315 | }, 316 | async ({ accountName, symbol, since, limit, params }) => { 317 | try { 318 | const exchange = ccxtServer.getExchangeInstance(accountName); 319 | 320 | // getExchangeInstance가 성공하면 인증은 보장됨 321 | 322 | // fetchClosedOrders 메서드가 지원되는지 확인 323 | if (!exchange.has["fetchClosedOrders"]) { 324 | return { 325 | content: [ 326 | { 327 | type: "text", 328 | text: `Account '${accountName}' (Exchange: ${exchange.id}) does not support fetching closed orders`, 329 | }, 330 | ], 331 | isError: true, 332 | }; 333 | } 334 | 335 | const closedOrders = await exchange.fetchClosedOrders( 336 | symbol, 337 | since, 338 | limit, 339 | params, 340 | ); 341 | 342 | return { 343 | content: [ 344 | { 345 | type: "text", 346 | text: JSON.stringify(closedOrders, null, 2), 347 | }, 348 | ], 349 | }; 350 | } catch (error) { 351 | return { 352 | content: [ 353 | { 354 | type: "text", 355 | text: `Error fetching closed orders for account '${accountName}': ${ 356 | (error as Error).message 357 | }`, 358 | }, 359 | ], 360 | isError: true, 361 | }; 362 | } 363 | }, 364 | ); 365 | } 366 | -------------------------------------------------------------------------------- /test-config.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 설정 파일 로드 테스트 스크립트 3 | * 이 스크립트는 설정 파일을 로드하고 구조를 출력합니다. 4 | */ 5 | 6 | import fs from "fs"; 7 | import path from "path"; 8 | import { fileURLToPath } from "url"; 9 | 10 | const __filename = fileURLToPath(import.meta.url); 11 | const __dirname = path.dirname(__filename); 12 | 13 | // 명령줄 인수 처리 14 | const args = process.argv.slice(2); 15 | let configPath = path.join(__dirname, "examples", "config-example.json"); 16 | 17 | // --config 옵션 처리 18 | const configIndex = args.indexOf("--config"); 19 | if (configIndex !== -1 && args.length > configIndex + 1) { 20 | configPath = args[configIndex + 1]; 21 | } 22 | 23 | // console.log(`설정 파일 경로: ${configPath}`); 24 | 25 | try { 26 | // 설정 파일 읽기 27 | const configContent = fs.readFileSync(configPath, "utf-8"); 28 | 29 | // JSON 파싱 30 | const config = JSON.parse(configContent); 31 | 32 | // 계정 정보 확인 33 | if (Array.isArray(config.accounts)) { 34 | // console.log(`직접 accounts 배열 발견: ${config.accounts.length}개의 계정`); 35 | config.accounts.forEach((account, index) => { 36 | // console.log(`계정 ${index + 1}: ${account.name} (${account.exchangeId})`); 37 | }); 38 | } else if ( 39 | config.mcpServers && 40 | config.mcpServers["ccxt-mcp"] && 41 | Array.isArray(config.mcpServers["ccxt-mcp"].accounts) 42 | ) { 43 | const accounts = config.mcpServers["ccxt-mcp"].accounts; 44 | // console.log(`mcpServers.ccxt-mcp.accounts 경로에서 ${accounts.length}개의 계정 발견`); 45 | accounts.forEach((account, index) => { 46 | // console.log(`계정 ${index + 1}: ${account.name} (${account.exchangeId})`); 47 | }); 48 | } else { 49 | console.error("설정 파일에서 계정 정보를 찾을 수 없습니다"); 50 | // console.log('설정 파일 내용:', JSON.stringify(config, null, 2)); 51 | } 52 | } catch (error) { 53 | console.error("설정 파일 처리 중 오류 발생:", error); 54 | } 55 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2020", 4 | "module": "NodeNext", 5 | "moduleResolution": "NodeNext", 6 | "esModuleInterop": true, 7 | "strict": false, // Disable strict mode temporarily to allow build 8 | "skipLibCheck": true, 9 | "outDir": "dist", 10 | "rootDir": "src", 11 | "declaration": true, 12 | "sourceMap": true, 13 | "lib": ["ES2020", "DOM"] 14 | }, 15 | "include": ["src/**/*"], 16 | "exclude": ["node_modules", "dist"] 17 | } 18 | --------------------------------------------------------------------------------