MCP Tool Behavior 선언기
코딩입문
2025-06-18 스펙 기반으로 도구 동작 어노테이션을 추가해 클라이언트가 확인 대화상자, 자동 승인, 재시도 등을 적절히 처리하도록 합니다.
트리거
/mcp-tool-attr사용빈도per tool
MCP Server Author라면? Run /mcp-tool-attr to annotate all tools for safer client behavior
Security Engineer라면? Ensure destructive tools are properly flagged for UI gating
MCPTool Behavior안전UX
작동 흐름
/mcp-tool-attr [server-dir] run
↓
Phase 1: scan and classify tools
tool-scan
List all registered tools
classify
Auto-classify read/write/destructive
annotate
Add behavior attributes
↓
Generate behavior summary table
↓
✓ All tools annotated with behavior attributes
스킬 코드
# MCP Tool Behavior Declarator
## Trigger: /mcp-tool-attr [server-directory]
When invoked:
1. Scan tools and add behavior annotations:
```typescript
server.tool("list-files", {
description: "List files in a directory",
annotations: {
readOnlyHint: true, // Does not modify state
destructiveHint: false, // Cannot destroy data
idempotentHint: true, // Safe to retry
openWorldHint: false, // No external side effects
},
inputSchema: { /* ... */ }
}, handler);
server.tool("delete-record", {
description: "Permanently delete a database record",
annotations: {
readOnlyHint: false,
destructiveHint: true, // Irreversible action
idempotentHint: true, // Deleting twice = same result
openWorldHint: false,
},
inputSchema: { /* ... */ }
}, handler);
server.tool("send-email", {
description: "Send email to a recipient",
annotations: {
readOnlyHint: false,
destructiveHint: false,
idempotentHint: false, // Sending twice = two emails
openWorldHint: true, // External side effect (email sent)
},
inputSchema: { /* ... */ }
}, handler);
```
2. Behavior classification guide:
| Attribute | true | false |
|-----------|------|-------|
| readOnlyHint | Queries, listings, searches | Create, update, delete |
| destructiveHint | Delete, drop, purge, overwrite | Create, read, append |
| idempotentHint | GET-like, upsert, delete | POST-like, send, increment |
| openWorldHint | Email, API call, webhook | Local DB, file system |
3. Client behavior expectations:
- readOnly: may auto-approve without user confirmation
- destructive: should show confirmation dialog
- idempotent: safe to retry on network errors
- openWorld: warn about external side effects
복사해서 CLAUDE.md에 붙여넣으면 바로 사용할 수 있습니다.
MCP Tool Behavior 선언기 작동 방식
MCP Tool Behavior Declarator는 서버 디렉토리의 모든 tool을 스캔하여 readOnly, destructive, idempotent, openWorld 4가지 동작 속성을 자동 분류하고, annotations 객체로 추가합니다. 클라이언트는 이 속성을 기반으로 확인 대화상자 표시, 자동 승인, 재시도 최적화 등의 UX를 결정합니다.
MCP Tool Behavior 선언기이(가) 빛나는 순간
MCP 서버에 여러 tool이 있을 때 각각의 안전성 수준을 명시적으로 선언하고, 클라이언트가 적절한 UI 게이팅을 적용하도록 하고 싶을 때 필수적입니다.
핵심 특장점
- 4가지 행동 속성 자동 분류
- destructive tool에 확인 대화상자 자동 적용
- readOnly tool은 사용자 승인 없이 자동 실행 가능
- idempotent 표시로 네트워크 오류 시 안전한 재시도