import { Client } from "@modelcontextprotocol/sdk/client/index.js"; import { InMemoryTransport } from "@modelcontextprotocol/sdk/inMemory.js"; import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { describe, expect, it } from "vitest"; import { ServerInstructions } from "../constants/server-instructions.js"; // server.ts 와 같은 옵션으로 서버를 띄워, initialize 응답을 통해 클라이언트가 // instructions 를 실제로 받는지 프로토콜 계층에서 확인한다. describe("서버 instructions 전달", () => { it("클라이언트가 initialize 후 ServerInstructions 를 그대로 받는다", async () => { const server = new McpServer( { name: "tosspayments-integration-guide", version: "1.0.0" }, { instructions: ServerInstructions } ); const client = new Client({ name: "test-client", version: "1.0.0" }); const [clientTransport, serverTransport] = InMemoryTransport.createLinkedPair(); await Promise.all([ server.connect(serverTransport), client.connect(clientTransport), ]); expect(client.getInstructions()).toBe(ServerInstructions); await client.close(); await server.close(); }); });