Loading...
    • 빌드
    • 관리
    • 모델 및 가격
    • 클라이언트 SDK
    • API 참조
    Search...
    ⌘K
    시작하기
    Claude 소개빠른 시작
    Claude로 구축하기
    기능 개요Messages API 사용중지 이유 처리
    모델 기능
    확장 사고적응형 사고노력빠른 모드 (베타: 리서치 프리뷰)구조화된 출력인용스트리밍 메시지일괄 처리검색 결과스트리밍 거부다국어 지원임베딩
    도구
    개요도구 사용 방법웹 검색 도구웹 가져오기 도구코드 실행 도구메모리 도구Bash 도구컴퓨터 사용 도구텍스트 편집기 도구
    도구 인프라
    도구 검색프로그래밍 방식 도구 호출세밀한 도구 스트리밍
    컨텍스트 관리
    컨텍스트 윈도우압축컨텍스트 편집프롬프트 캐싱토큰 계산
    파일 작업
    Files APIPDF 지원이미지 및 비전
    스킬
    개요빠른 시작모범 사례엔터프라이즈용 스킬API의 스킬
    MCP
    원격 MCP 서버MCP 커넥터
    프롬프트 엔지니어링
    개요프롬프트 모범 사례Console 프롬프트 도구
    테스트 및 평가
    성공 기준 정의 및 평가 구축Console의 평가 도구 사용지연 시간 줄이기
    가드레일 강화
    환각 줄이기출력 일관성 높이기탈옥 방지프롬프트 유출 줄이기
    리소스
    용어집
    릴리스 노트
    Claude Platform
    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
    에이전트에 작업 위임

    GitHub 접근

    GitHub 저장소에 에이전트를 연결하여 복제, 읽기 및 풀 요청 생성을 수행합니다.

    Was this page helpful?

    • GitHub MCP 및 세션 리소스

    세션 컨테이너에 GitHub 저장소를 마운트하고 GitHub MCP에 연결하여 풀 요청을 만들 수 있습니다.

    GitHub 저장소는 캐시되므로 동일한 저장소를 사용하는 향후 세션이 더 빠르게 시작됩니다.

    모든 Managed Agents API 요청에는 managed-agents-2026-04-01 베타 헤더가 필요합니다. SDK는 베타 헤더를 자동으로 설정합니다.

    GitHub MCP 및 세션 리소스

    먼저 GitHub MCP 서버를 선언하는 에이전트를 생성합니다. 에이전트 정의는 서버 URL을 포함하지만 인증 토큰은 포함하지 않습니다:

    agent_id=$(curl -fsS https://api.anthropic.com/v1/agents \
      -H "x-api-key: $ANTHROPIC_API_KEY" \
      -H "anthropic-version: 2023-06-01" \
      -H "anthropic-beta: managed-agents-2026-04-01" \
      -H "content-type: application/json" \
      --data @- <<JSON | jq -r '.id'
    {
      "name": "Code Reviewer",
      "model": "claude-sonnet-4-6",
      "system": "You are a code review assistant with access to GitHub.",
      "mcp_servers": [
        {
          "type": "url",
          "name": "github",
          "url": "https://api.githubcopilot.com/mcp/"
        }
      ],
      "tools": [
        {"type": "agent_toolset_20260401"},
        {
          "type": "mcp_toolset",
          "mcp_server_name": "github"
        }
      ]
    }
    JSON
    )

    그런 다음 GitHub 저장소를 마운트하는 세션을 생성합니다:

    resources[].authorization_token은 저장소 복제 작업을 인증하며 API 응답에서 반복되지 않습니다.

    토큰 권한

    GitHub 토큰을 제공할 때 필요한 최소 권한을 사용합니다:

    작업필수 범위
    비공개 저장소 복제repo
    PR 생성repo
    이슈 읽기repo (비공개) 또는 public_repo
    이슈 생성repo (비공개) 또는 public_repo

    필요한 최소 권한이 있는 세분화된 개인 액세스 토큰을 사용합니다. GitHub 계정에 광범위한 액세스 권한이 있는 토큰 사용을 피합니다.

    여러 저장소

    resources 배열에 항목을 추가하여 여러 저장소를 마운트합니다:

    실행 중인 세션에서 저장소 관리

    세션이 생성된 후 저장소 리소스를 나열하고 인증 토큰을 회전할 수 있습니다. 각 리소스에는 세션 생성 시간에 반환되는 id(또는 resources.list를 통해)가 있으며, 이를 업데이트에 사용합니다. 저장소는 세션의 수명 동안 연결되어 있습니다. 마운트된 저장소를 변경하려면 새 세션을 생성합니다.

    풀 요청 생성

    GitHub MCP 서버를 사용하면 에이전트가 브랜치를 생성하고, 변경 사항을 커밋하고, 푸시할 수 있습니다:

    session_id=$(curl -fsS https://api.anthropic.com/v1/sessions \
      -H "x-api-key: $ANTHROPIC_API_KEY" \
      -H "anthropic-version: 2023-06-01" \
      -H "anthropic-beta: managed-agents-2026-04-01" \
      -H "content-type: application/json" \
      --data @- <<JSON | jq -r '.id'
    {
      "agent": "$agent_id",
      "environment_id": "$environment_id",
      "resources": [
        {
          "type": "github_repository",
          "url": "https://github.com/org/repo",
          "mount_path": "/workspace/repo",
          "authorization_token": "ghp_your_github_token"
        }
      ]
    }
    JSON
    )
    resources='[
      {
        "type": "github_repository",
        "url": "https://github.com/org/frontend",
        "mount_path": "/workspace/frontend",
        "authorization_token": "ghp_your_github_token"
      },
      {
        "type": "github_repository",
        "url": "https://github.com/org/backend",
        "mount_path": "/workspace/backend",
        "authorization_token": "ghp_your_github_token"
      }
    ]'
    # List resources on the session
    repo_resource_id=$(curl -fsS "https://api.anthropic.com/v1/sessions/$session_id/resources" \
      -H "x-api-key: $ANTHROPIC_API_KEY" \
      -H "anthropic-version: 2023-06-01" \
      -H "anthropic-beta: managed-agents-2026-04-01" \
      -H "content-type: application/json" | jq -r '.data[0].id')
    echo "$repo_resource_id"  # "sesrsc_01ABC..."
    
    # Rotate the authorization token
    curl -fsS "https://api.anthropic.com/v1/sessions/$session_id/resources/$repo_resource_id" \
    # ...
      -o /dev/null \
      --data @- <<JSON
    {
      "authorization_token": "ghp_your_new_github_token"
    }
    JSON
    curl -fsS "https://api.anthropic.com/v1/sessions/$session_id/events" \
      -H "x-api-key: $ANTHROPIC_API_KEY" \
      -H "anthropic-version: 2023-06-01" \
      -H "anthropic-beta: managed-agents-2026-04-01" \
      -H "content-type: application/json" \
      -o /dev/null \
      --data @- <<JSON
    {
      "events": [
        {
          "type": "user.message",
          "content": [
            {
              "type": "text",
              "text": "Fix the type error in src/utils.ts, commit it to a new branch, and push it."
            }
          ]
        }
      ]
    }
    JSON