SVM-MCP: SOON 모델 컨텍스트 프로토콜 서버
Claude AI를 SOON 및 기타 SVM 기반 블록체인과 통합하는 모델 컨텍스트 프로토콜(MCP) 서버입니다. 이 서버는 SOON 테스트넷 및 메인넷의 잔액 확인, 최근 거래 내역 조회, 토큰 보유량 조회 등의 도구를 제공하여 계정 잔액, 거래 내역 및 토큰 보유량을 확인할 수 있습니다.
개요
이 MCP 서버는 Claude를 SOON 생태계에 연결하도록 설계되었으며, 이를 통해 다음과 같은 작업이 가능합니다.
- 테스트넷과 메인넷에서 지갑 잔액 쿼리
- 주소에 대한 최신 거래를 가져옵니다.
- 모든 계정의 토큰 보유량을 확인하세요
현재 구현에서는 SOON의 RPC 엔드포인트를 사용하지만, 모든 Solana 호환 블록체인이나 사용자 정의 SVM 구현과 작동하도록 쉽게 수정할 수 있습니다.
특징
- 잔액 가져오기 : SOON 테스트넷 또는 메인넷의 모든 주소에 대한 기본 토큰 잔액을 가져옵니다.
- 마지막 거래 가져오기 : 주소에 대한 가장 최근 거래를 검색합니다.
- 토큰 계정 가져오기 : 주소가 소유한 모든 토큰 계정 나열
필수 조건
- Node.js(v16+)
- NPM 또는 Bun 패키지 관리자
- Claude Desktop(로컬 테스트용)
설치
- 저장소를 복제합니다.
지엑스피1
- 종속성 설치:
npm install
# or
bun install
- 프로젝트를 빌드하세요:
npm run build
# or
bun run build
프로젝트 구조
주요 서버 구현은 src/index.ts
에 있습니다.
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
import { Connection, PublicKey } from "@solana/web3.js";
import { z } from "zod";
const connectionTestnet = new Connection("https://rpc.testnet.soo.network/rpc");
const connectionMainnet = new Connection("https://rpc.mainnet.soo.network/rpc");
const server = new McpServer({
name: "svm-mcp",
version: "0.0.1",
capabilities: [
"get-soon-testnet-balance",
"get-soon-testnet-last-transaction",
"get-soon-testnet-account-tokens",
"get-soon-mainnet-balance",
"get-soon-mainnet-last-transaction",
"get-soon-mainnet-account-tokens",
],
});
도구 구현
균형을 잡으세요
server.tool(
"get-soon-testnet-balance",
"Get the balance of a address on the Soon testnet",
{
address: z.string().describe("The Solana address to get the balance of"),
},
async ({ address }) => {
try {
const balance = await connectionTestnet.getBalance(new PublicKey(address));
return {
content: [
{
type: "text",
text: `Balance: ${balance}`,
},
],
};
} catch (error) {
return {
content: [
{
type: "text",
text: `Error getting balance: ${error instanceof Error ? error.message : String(error)}`,
},
],
};
}
}
);
마지막 거래 가져오기
server.tool(
"get-soon-testnet-last-transaction",
"Get the last transaction of an address on the Soon testnet",
{
address: z
.string()
.describe("The Solana address to get the last transaction for"),
},
async ({ address }) => {
try {
// Fetch the most recent transaction signatures for the address
const signatures = await connectionTestnet.getSignaturesForAddress(
new PublicKey(address),
{ limit: 1 } // Limit to just the most recent transaction
);
if (signatures.length === 0) {
return {
content: [
{
type: "text",
text: "No transactions found for this address",
},
],
};
}
// Get the most recent transaction using its signature
const latestSignature = signatures[0].signature;
const transaction = await connectionTestnet.getConfirmedTransaction(
latestSignature
);
return {
content: [
{
type: "text",
text: JSON.stringify(transaction),
},
],
};
} catch (error) {
return {
content: [
{
type: "text",
text: `Error getting transaction: ${error instanceof Error ? error.message : String(error)}`,
},
],
};
}
}
);
토큰 계정 받기
server.tool(
"get-soon-testnet-account-tokens",
"Get the tokens of a address on the Soon testnet",
{
address: z.string().describe("The Solana address to get the tokens of"),
},
async ({ address }) => {
try {
const tokens = await connectionTestnet.getTokenAccountsByOwner(
new PublicKey(address),
{
programId: new PublicKey("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"),
}
);
return {
content: [
{
type: "text",
text: JSON.stringify(tokens),
},
],
};
} catch (error) {
return {
content: [
{
type: "text",
text: `Error getting tokens: ${error instanceof Error ? error.message : String(error)}`,
},
],
};
}
}
);
서버 초기화
async function main() {
try {
console.error("Starting MCP server...");
const transport = new StdioServerTransport();
console.error("Transport initialized, connecting to server...");
await server.connect(transport);
console.error("Server connection established successfully");
// The server will keep running in this state
} catch (error) {
console.error("There was an error connecting to the server:", error);
process.exit(1);
}
}
main().catch((err) => {
console.error("There was an error starting the server:", err);
process.exit(1);
});
구성
클로드 데스크톱 구성
Claude Desktop과 함께 이 MCP 서버를 사용하려면 claude_desktop_config.json
파일에 다음을 추가하세요.
{
"mcpServers": {
"svm-mcp": {
"command": "bun",
"args": ["/path/to/svm-mcp/build/index.js"]
}
}
}
RPC 엔드포인트 사용자 지정
다른 RPC 엔드포인트를 사용하거나 다른 Solana 호환 블록체인에 연결하려면 src/index.ts
에서 연결 URL을 편집하세요.
const connectionTestnet = new Connection("YOUR_TESTNET_RPC_URL");
const connectionMainnet = new Connection("YOUR_MAINNET_RPC_URL");
Claude와 함께 사용
MCP 서버가 실행 중이고 Claude에 연결되면 다음 명령을 사용할 수 있습니다.
주소 잔액 확인
Can you check the balance of this SOON testnet address: <address>
최근 거래 가져오기
What is the last transaction made by <address> on SOON testnet?
토큰 보유량 검색
What tokens does <address> hold on SOON mainnet?
감사의 말