import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"; import { z } from "zod"; import { BasePrompt, GlossaryPrompt } from "./constants/base-prompt.js"; import { ServerInstructions } from "./constants/server-instructions.js"; import { buildIntegrationMethodPolicyText } from "./constants/integration-method.js"; import { GetDocumentSchema } from "./schema/get-document-schema.js"; import { getDocumentById, getDocumentsByKeyword, getGlossaryDocumentsByKeyword, } from "./tool/tools.js"; const server = new McpServer( { name: "tosspayments-integration-guide", description: "MCP-compatible toolset for integrating with tosspayments systems. Includes tools for retrieving LLM-structured text and fetching actual documentation through URLs. (토스페이먼츠 시스템과의 연동을 위한 MCP 도구 모음입니다. LLM이 활용할 수 있는 텍스트 및 관련 문서를 가져오는 기능을 포함합니다.)", version: "1.0.0", }, { instructions: ServerInstructions, } ); server.tool( "get-documents", `토스페이먼츠 연동 문서를 조회합니다. 기본은 v2 이고, 유저가 버전1을 명시할 때만 version 을 "v1" 로 넘기세요. ${BasePrompt} ${buildIntegrationMethodPolicyText()}`, GetDocumentSchema, async (params) => { return await getDocumentsByKeyword(params); } ); server.tool( "get-glossary-documents", `토스페이먼츠의 정책/용어/백서 문서(/resources/glossary/)를 조회합니다. 결제 도메인 용어의 정의, 정책적 제약, AML 등 주제 질의에 사용하세요. ${GlossaryPrompt}`, GetDocumentSchema, async (params) => { return await getGlossaryDocumentsByKeyword(params); } ); server.tool( "document-by-id", `문서의 원본 ID 로 해당 문서의 전체 내용을 조회합니다.`, { id: z.string().describe("문서별 id 값") }, async ({ id }) => { return await getDocumentById(id); } ); const transport = new StdioServerTransport(); await server.connect(transport);