Loading...
    • 개발자 가이드
    • API 참조
    • MCP
    • 리소스
    • 릴리스 노트
    Search...
    ⌘K
    첫 단계
    Claude 소개빠른 시작
    모델 및 가격
    모델 개요모델 선택Claude 4.5의 새로운 기능Claude 4.5로 마이그레이션모델 지원 중단가격
    Claude로 구축
    기능 개요Messages API 사용컨텍스트 윈도우프롬프트 작성 모범 사례
    기능
    프롬프트 캐싱컨텍스트 편집확장 사고노력메시지 스트리밍배치 처리인용다국어 지원토큰 계산임베딩비전PDF 지원Files API검색 결과구조화된 출력
    도구
    개요도구 사용 구현 방법세분화된 도구 스트리밍Bash 도구코드 실행 도구프로그래밍 방식 도구 호출컴퓨터 사용 도구텍스트 편집기 도구웹 가져오기 도구웹 검색 도구메모리 도구도구 검색 도구
    에이전트 스킬
    개요빠른 시작모범 사례API와 함께 스킬 사용
    에이전트 SDK
    개요빠른 시작TypeScript SDKTypeScript V2 (미리보기)Python SDK마이그레이션 가이드
    스트리밍 입력권한 처리훅으로 실행 제어세션 관리파일 체크포인팅SDK의 구조화된 출력에이전트 SDK 호스팅AI 에이전트 안전하게 배포시스템 프롬프트 수정SDK의 MCP사용자 정의 도구SDK의 서브에이전트SDK의 슬래시 명령SDK의 에이전트 스킬비용 및 사용량 추적할 일 목록SDK의 플러그인
    API의 MCP
    MCP 커넥터원격 MCP 서버
    타사 플랫폼의 Claude
    Amazon BedrockMicrosoft FoundryVertex AI
    프롬프트 엔지니어링
    개요프롬프트 생성기프롬프트 템플릿 사용프롬프트 개선기명확하고 직접적으로예제 사용 (다중 샷 프롬프팅)Claude가 생각하도록 하기 (CoT)XML 태그 사용Claude에게 역할 부여 (시스템 프롬프트)Claude의 응답 미리 채우기복잡한 프롬프트 연결긴 컨텍스트 팁확장 사고 팁
    테스트 및 평가
    성공 기준 정의테스트 케이스 개발평가 도구 사용지연 시간 감소
    가드레일 강화
    환각 감소출력 일관성 증가탈옥 완화거부 스트리밍프롬프트 유출 감소Claude를 캐릭터로 유지
    관리 및 모니터링
    Admin API 개요사용량 및 비용 APIClaude Code Analytics API
    Console
    Log in
    Loading...
    Loading...
    Loading...
    Loading...
    Loading...
    Loading...
    Loading...
    Loading...
    Loading...
    Loading...
    Loading...
    Loading...
    Loading...
    Loading...
    Loading...
    Loading...

    Solutions

    • AI agents
    • Code modernization
    • Coding
    • Customer support
    • Education
    • Financial services
    • Government
    • Life sciences

    Partners

    • Amazon Bedrock
    • Google Cloud's Vertex AI

    Learn

    • Blog
    • Catalog
    • Courses
    • Use cases
    • Connectors
    • Customer stories
    • Engineering at Anthropic
    • Events
    • Powered by Claude
    • Service partners
    • Startups program

    Company

    • Anthropic
    • Careers
    • Economic Futures
    • Research
    • News
    • Responsible Scaling Policy
    • Security and compliance
    • Transparency

    Learn

    • Blog
    • Catalog
    • Courses
    • Use cases
    • Connectors
    • Customer stories
    • Engineering at Anthropic
    • Events
    • Powered by Claude
    • Service partners
    • Startups program

    Help and security

    • Availability
    • Status
    • Support
    • Discord

    Terms and policies

    • Privacy policy
    • Responsible disclosure policy
    • Terms of service: Commercial
    • Terms of service: Consumer
    • Usage policy
    가이드

    SDK에서의 MCP

    Model Context Protocol 서버를 사용하여 사용자 정의 도구로 Claude Code를 확장하세요

    개요

    Model Context Protocol (MCP) 서버는 사용자 정의 도구와 기능으로 Claude Code를 확장합니다. MCP는 외부 프로세스로 실행되거나, HTTP/SSE를 통해 연결되거나, SDK 애플리케이션 내에서 직접 실행될 수 있습니다.

    구성

    기본 구성

    프로젝트 루트의 .mcp.json에서 MCP 서버를 구성하세요:

    {
      "mcpServers": {
        "filesystem": {
          "command": "npx",
          "args": ["@modelcontextprotocol/server-filesystem"],
          "env": {
            "ALLOWED_PATHS": "/Users/me/projects"
          }
        }
      }
    }

    SDK에서 MCP 서버 사용하기

    import { query } from "@anthropic-ai/claude-agent-sdk";
    
    for await (const message of query({
      prompt: "내 프로젝트의 파일들을 나열해줘",
      options: {
        mcpServers: {
          "filesystem": {
            command: "npx",
            args: ["@modelcontextprotocol/server-filesystem"],
            env: {
              ALLOWED_PATHS: "/Users/me/projects"
            }
          }
        },
        allowedTools: ["mcp__filesystem__list_files"]
      }
    })) {
      if (message.type === "result" && message.subtype === "success") {
        console.log(message.result);
      }
    }

    전송 유형

    stdio 서버

    stdin/stdout을 통해 통신하는 외부 프로세스:

    // .mcp.json 구성
    {
      "mcpServers": {
        "my-tool": {
          "command": "node",
          "args": ["./my-mcp-server.js"],
          "env": {
            "DEBUG": "${DEBUG:-false}"
          }
        }
      }
    }

    HTTP/SSE 서버

    네트워크 통신을 사용하는 원격 서버:

    // SSE 서버 구성
    {
      "mcpServers": {
        "remote-api": {
          "type": "sse",
          "url": "https://api.example.com/mcp/sse",
          "headers": {
            "Authorization": "Bearer ${API_TOKEN}"
          }
        }
      }
    }
    
    // HTTP 서버 구성
    {
      "mcpServers": {
        "http-service": {
          "type": "http",
          "url": "https://api.example.com/mcp",
          "headers": {
            "X-API-Key": "${API_KEY}"
          }
        }
      }
    }

    SDK MCP 서버

    애플리케이션 내에서 실행되는 인프로세스 서버. 사용자 정의 도구 생성에 대한 자세한 정보는 사용자 정의 도구 가이드를 참조하세요:

    리소스 관리

    MCP 서버는 Claude가 나열하고 읽을 수 있는 리소스를 노출할 수 있습니다:

    import { query } from "@anthropic-ai/claude-agent-sdk";
    
    // 사용 가능한 리소스 나열
    for await (const message of query({
      prompt: "데이터베이스 서버에서 사용 가능한 리소스는 무엇인가요?",
      options: {
        mcpServers: {
          "database": {
            command: "npx",
            args: ["@modelcontextprotocol/server-database"]
          }
        },
        allowedTools: ["mcp__list_resources", "mcp__read_resource"]
      }
    })) {
      if (message.type === "result") console.log(message.result);
    }

    인증

    환경 변수

    // 환경 변수가 포함된 .mcp.json
    {
      "mcpServers": {
        "secure-api": {
          "type": "sse",
          "url": "https://api.example.com/mcp",
          "headers": {
            "Authorization": "Bearer ${API_TOKEN}",
            "X-API-Key": "${API_KEY:-default-key}"
          }
        }
      }
    }
    
    // 환경 변수 설정
    process.env.API_TOKEN = "your-token";
    process.env.API_KEY = "your-key";

    OAuth2 인증

    클라이언트 내 OAuth2 MCP 인증은 현재 지원되지 않습니다.

    오류 처리

    MCP 연결 실패를 우아하게 처리하세요:

    import { query } from "@anthropic-ai/claude-agent-sdk";
    
    for await (const message of query({
      prompt: "데이터 처리",
      options: {
        mcpServers: {
          "data-processor": dataServer
        }
      }
    })) {
      if (message.type === "system" && message.subtype === "init") {
        // MCP 서버 상태 확인
        const failedServers = message.mcp_servers.filter(
          s => s.status !== "connected"
        );
        
        if (failedServers.length > 0) {
          console.warn("연결 실패:", failedServers);
        }
      }
      
      if (message.type === "result" && message.subtype === "error_during_execution") {
        console.error("실행 실패");
      }
    }

    관련 리소스

    • 사용자 정의 도구 가이드 - SDK MCP 서버 생성에 대한 자세한 가이드
    • TypeScript SDK 참조
    • Python SDK 참조
    • SDK 권한
    • 일반적인 워크플로우
    • SDK에서 MCP 서버 사용하기
    • stdio 서버
    • HTTP/SSE 서버
    • SDK MCP 서버
    • OAuth2 인증