MCP 서버 - 클러스터 API v1
이는 클러스터 API v1을 위한 모델 컨텍스트 프로토콜(MCP) 서버 구현입니다. 인증, 클러스터 관리, 이름 등록 등의 엔드포인트를 제공합니다.
종속성
지엑스피1
설정
- 종속성 설치:
- CLUSTERS_API_KEY={CLUSTERS_API_KEY}를 사용하여
.env
파일을 만듭니다. - 서버를 빌드하고 시작합니다.
테스트 엔드포인트
이 서버는 StdioServerTransport
사용하므로 stdin을 통해 JSON-RPC 메시지를 전송해야 합니다. 각 엔드포인트를 테스트하기 위한 명령 예시는 다음과 같습니다.
인증 엔드포인트
메시지 받기
echo '{"jsonrpc":"2.0","id":1,"method":"auth_get_message","params":{"address":"0x123...","chainId":1,"nonce":"abc123"}}' | node dist/index.js
토큰 받기
echo '{"jsonrpc":"2.0","id":1,"method":"auth_get_token","params":{"signature":"0x123...","signingDate":"2024-03-21","type":"evm","wallet":"0x123..."}}' | node dist/index.js
토큰 검증
echo '{"jsonrpc":"2.0","id":1,"method":"auth_validate_token","params":{"authKey":"your-auth-key"}}' | node dist/index.js
클러스터 관리 엔드포인트
클러스터 생성
echo '{"jsonrpc":"2.0","id":1,"method":"create_cluster","params":{"wallets":[{"address":"0x123...","name":"MyWallet","isPrivate":false}],"authKey":"your-auth-key","testnet":false}}' | node dist/index.js
ID로 클러스터 가져오기
echo '{"jsonrpc":"2.0","id":1,"method":"get_cluster_by_id","params":{"id":"cluster-id","testnet":false}}' | node dist/index.js
이름으로 클러스터 가져오기
echo '{"jsonrpc":"2.0","id":1,"method":"get_cluster_by_name","params":{"name":"cluster-name","testnet":false}}' | node dist/index.js
주소로 클러스터 ID 가져오기
echo '{"jsonrpc":"2.0","id":1,"method":"get_cluster_id_by_address","params":{"address":"0x123...","testnet":false}}' | node dist/index.js
지갑 추가
echo '{"jsonrpc":"2.0","id":1,"method":"add_wallets","params":{"wallets":[{"address":"0x123...","name":"NewWallet","isPrivate":false}],"authKey":"your-auth-key","testnet":false}}' | node dist/index.js
지갑 생성
echo '{"jsonrpc":"2.0","id":1,"method":"generate_wallet","params":{"type":"evm","name":"NewWallet","isPrivate":false,"authKey":"your-auth-key","testnet":false}}' | node dist/index.js
지갑 업데이트
echo '{"jsonrpc":"2.0","id":1,"method":"update_wallets","params":{"wallets":[{"address":"0x123...","name":"UpdatedName"}],"authKey":"your-auth-key","testnet":false}}' | node dist/index.js
지갑 제거
echo '{"jsonrpc":"2.0","id":1,"method":"remove_wallets","params":{"addresses":["0x123..."],"authKey":"your-auth-key","testnet":false}}' | node dist/index.js
지갑 확인
echo '{"jsonrpc":"2.0","id":1,"method":"verify_wallet","params":{"clusterId":"cluster-id","authKey":"your-auth-key","testnet":false}}' | node dist/index.js
주소 ↔ 이름 확인 엔드포인트
주소로 데이터 가져오기
echo '{"jsonrpc":"2.0","id":1,"method":"get_data_by_address","params":{"address":"0x123...","testnet":false}}' | node dist/index.js
주소별 대량 데이터 가져오기
echo '{"jsonrpc":"2.0","id":1,"method":"get_bulk_data_by_addresses","params":{"addresses":["0x123...","0x456..."],"testnet":false}}' | node dist/index.js
이름으로 대량 데이터 가져오기
echo '{"jsonrpc":"2.0","id":1,"method":"get_bulk_data_by_names","params":{"names":[{"name":"name1"}],"testnet":false}}' | node dist/index.js
등록 엔드포인트
이름 가용성 확인
echo '{"jsonrpc":"2.0","id":1,"method":"check_name_availability","params":{"names":["name1","name2"]}}' | node dist/index.js
등록 서명 데이터 가져오기
echo '{"jsonrpc":"2.0","id":1,"method":"get_registration_sign_data","params":{"network":"1","sender":"0x123...","names":[{"name":"name1","amountWei":"1000000000000000000"}],"referralClusterId":"optional-id","testnet":false}}' | node dist/index.js
거래 상태 가져오기
echo '{"jsonrpc":"2.0","id":1,"method":"get_transaction_status","params":{"txHash":"0x123..."}}' | node dist/index.js
노트
- 플레이스홀더 값(예:
0x123...
, your-auth-key
등)을 실제 값으로 교체합니다. testnet
매개변수는 대부분의 엔드포인트에 대해 선택 사항입니다.- 모든 응답은 JSON-RPC 2.0 형식이 됩니다.
- 인증된 엔드포인트의 경우 유효한
authKey
가져와 포함해야 합니다. - 서버는 구성을 위해 환경 변수를 사용합니다.
.env
파일이 올바르게 설정되었는지 확인하세요.
대체 테스트 방법
테스트를 더 쉽게 하려면 stdio 대신 HTTP 전송을 사용하도록 서버를 수정할 수 있습니다. 이렇게 하면 echo 파이프 대신 curl 명령을 사용할 수 있습니다. HTTP 전송으로 전환하고 싶으시면 알려주세요.