Claude Agent SDK 개발자 가이드
Claude Code SDK가 공식적으로 Claude Agent SDK로 이름이 바뀌었으며, 코딩 작업을 넘어 AI 에이전트를 구축하기 위한 더 넓은 기능을 제공해요. 이 가이드는 Python/TypeScript 빠른 시작, 핵심 개념, Managed Agents와의 비교, QCode를 통한 설정을 다뤄요.
업데이트됨 2026-11-26
Claude Agent SDK란
공식 이름 변경
공식 마이그레이션 가이드에 따르면 이름 변경과 함께 문서가 재구성되었고 설치 패키지 이름도 변경되었어요. 두 이름은 동일한 SDK를 가리켜요(2026-10-20 확인).
이름을 바꾼 이유
공식적인 이유는 범위예요. 이 라이브러리는 코딩 작업을 넘어 AI 에이전트를 구축하기 위한 것이에요(2026-10-20 확인).
통합 도구 인터페이스
Claude Code를 구동하는 것과 동일한 도구, 에이전트 루프, 컨텍스트 관리를 제공하며, 직접 운영하는 프로세스에서 Python 또는 TypeScript 애플리케이션에 라이브러리로 내장해 실행할 수 있어요.
프로덕션 준비 완료
파일 읽기, 쓰기, 편집, 명령 실행, 웹 검색을 위한 내장 도구와 세션, 권한, 훅, 서브에이전트, MCP 통합을 제공해요.
다국어 지원
Python용 claude-agent-sdk와 TypeScript용 @anthropic-ai/claude-agent-sdk 두 패키지로 공식 유지 관리되며, 둘 다 최신 상태로 유지돼요.
핵심 개념
도구
Agent가 호출할 수 있는 함수로, 데코레이터로 선언하면 Claude가 이해하고 호출할 수 있도록 JSON Schema가 자동 생성돼요.
에이전트 루프
Claude가 생각 → 도구 선택 → 실행 → 결과 관찰 → 계속 생각하는 과정을 작업이 완료될 때까지 반복해요.
메모리 / 컨텍스트
세션 내 단기 기억(대화 기록)과 세션 간 장기 기억(파일/데이터베이스 영속화)을 통합 관리해요.
권한
세밀한 권한 제어: 파일 시스템, 네트워크, 코드 실행, 외부 API 접근 범위를 모두 독립적으로 설정할 수 있어요.
Python 빠른 시작
세 단계로 첫 Claude Agent를 만들어 보세요. QCode에서는 QCode 키와 Anthropic 엔드포인트만 설정하면 돼요.
1단계: SDK 설치
python3 -m venv .venv && source .venv/bin/activate
pip install claude-agent-sdk
2단계: Agent 생성
import asyncio
from claude_agent_sdk import query, ClaudeAgentOptions
async def main():
options = ClaudeAgentOptions(
system_prompt="You are an expert Python developer",
permission_mode="acceptEdits",
)
async for message in query(
prompt="Create a Python web server", options=options
):
print(message)
asyncio.run(main())
3단계: 사용자 정의 도구 정의
import asyncio
from typing import Any
from claude_agent_sdk import (
ClaudeAgentOptions, create_sdk_mcp_server, query, tool
)
@tool("get_weather", "Get current weather for a city", {"city": str})
async def get_weather(args: dict[str, Any]) -> dict[str, Any]:
return {
"content": [
{"type": "text",
"text": f"Weather in {args['city']}: 22 C, sunny"}
]
}
weather_server = create_sdk_mcp_server(
name="weather",
version="1.0.0",
tools=[get_weather],
)
options = ClaudeAgentOptions(
mcp_servers={"weather": weather_server},
allowed_tools=["mcp__weather__get_weather"],
)
async def main():
async for message in query(
prompt="What's the weather in Beijing and Shanghai?",
options=options,
):
print(message)
asyncio.run(main())
TypeScript 빠른 시작
완전한 타입 지원으로 Node.js / Bun에서 Claude Agent를 개발해요.
1단계: SDK 설치
npm install @anthropic-ai/claude-agent-sdk
2단계: Agent 생성
import { query } from "@anthropic-ai/claude-agent-sdk";
for await (const message of query({
prompt: "Create a Python web server",
options: { systemPrompt: "You are an expert Python developer" },
})) {
console.log(message);
}
3단계: 전체 예제
import { tool, createSdkMcpServer, query } from "@anthropic-ai/claude-agent-sdk";
import { z } from "zod";
const getTemperature = tool(
"get_temperature",
"Get the current temperature at a location",
{
latitude: z.number().describe("Latitude coordinate"),
longitude: z.number().describe("Longitude coordinate")
},
async (args) => {
return {
content: [{ type: "text", text: `Temperature at ${args.latitude}` }]
};
}
);
const weatherServer = createSdkMcpServer({
name: "weather",
version: "1.0.0",
tools: [getTemperature]
});
for await (const message of query({
prompt: "What's the temperature in Beijing?",
options: {
mcpServers: { weather: weatherServer },
allowedTools: ["mcp__weather__get_temperature"]
}
})) {
console.log(message);
}
Agent SDK vs Managed Agents
| 비교 항목 |
Agent SDK
|
Managed Agents
|
|---|---|---|
| 실행 환경 | 셀프 호스팅(로컬 / 자체 서버) | Anthropic이 에이전트 루프를 호스팅하며, 세션은 Anthropic이 관리하는 클라우드 샌드박스 또는 자체 인프라의 샌드박스에서 실행될 수 있어요. |
| 확장 방식 | 수동 인스턴스 관리 | 자동 탄력 확장 |
| 적용 사례 | 프로토타이핑, 고도로 맞춤화된 시나리오 | 엔터프라이즈 프로덕션 Agent 배포 |
QCode.cc를 통해 사용하기
ANTHROPIC_BASE_URL을 https://api.qcode.cc/api로 지정하고 QCode 키로 Agent SDK를 호출하세요. 호출 가능한 모델은 /models에서 확인할 수 있어요. Managed Agents는 Anthropic이 에이전트 루프를 호스팅하며, 세션은 Anthropic이 관리하는 클라우드 샌드박스 또는 자체 인프라의 샌드박스에서 실행돼요(공식 문서 2026-10-20 확인). 해당 경로는 검증하지 않았으며 이에 대해 어떠한 약속도 하지 않아요.
# Python SDK
ANTHROPIC_BASE_URL=https://api.qcode.cc/api
ANTHROPIC_API_KEY=your-qcode-api-key
# TypeScript SDK
ANTHROPIC_BASE_URL=https://api.qcode.cc/api
ANTHROPIC_API_KEY=your-qcode-api-key
# Point the endpoint at your own gateway: the SDK reads it from env
from claude_agent_sdk import ClaudeAgentOptions
options = ClaudeAgentOptions(
env={
"ANTHROPIC_BASE_URL": "https://api.qcode.cc/api",
},
)
QCode에서는 Claude 모델 Fable 5 / Opus 4.8 / Sonnet 4.6을 호출할 수 있어요. Haiku 4.5 및 기타 모델의 호출 가능 여부는 /models를 따릅니다(2026-10-20 확인).
도구 호출(Function Calling) 완전 지원
스트리밍 출력 지원
공식 Messages API와 동일한 형태 — Agent SDK는 ANTHROPIC_BASE_URL만 필요해요
지금 바로 AI Agent 구축 시작하기
QCode.cc에서 회원가입하고 중국 내에서 안정적인 Claude API 접근을 누리세요. 모든 Agent SDK 기능을 지원해요.