import type { McpServer, ToolCallback } from '@modelcontextprotocol/sdk/server/mcp.js'; import type { ZodRawShapeCompat } from '@modelcontextprotocol/sdk/server/zod-compat.js'; import type { CallToolResult, ToolAnnotations } from '@modelcontextprotocol/sdk/types.js'; import type { ToolManifest } from './package-root.js'; import type { ToolsetSelection } from './toolsets.js'; /** * 도구 등록의 단일 관문. * * register 파일은 예전처럼 `server.tool(name, description, shape, handler)` 모양으로 부르지만, * 받는 `server` 는 McpServer 가 아니라 이 레지스트라다. 레지스트라가 tool-manifest.json(SSOT)을 * 보고 다음을 붙인 뒤 SDK 의 `registerTool` 로 등록한다 (deprecated `server.tool` 은 안 쓴다): * * 1. **annotations + title** — manifest 의 write / destructive / local / idempotent 목록에서 * readOnlyHint · destructiveHint · idempotentHint · openWorldHint 를 파생한다. * 2. **confirm 가드** — destructive 도구에는 `confirm` 을 스키마에 주입하고, confirm !== true 호출은 * 핸들러를 부르지 않고 dry-run preview 만 돌려준다 (인자에 따른 예외 없음). manifest `ownGate` 로 * "자기 confirm 이 모든 파괴적 경로를 막는다" 고 선언한 도구만 주입을 생략하고, 선언과 스키마가 * 어긋나면 throw — 파괴적 도구가 가드 없이 등록되는 경로를 구조적으로 없앤다. * 3. **toolset 필터** — MIMI_SEED_TOOLSETS 로 꺼진 도구는 등록하지 않는다 (도메인 + alsoInToolsets 소속 기준). * 4. **폐기 예정 별칭** — manifest `deprecated` 의 옛 이름을 정식 도구의 스키마·핸들러로 * 함께 등록한다 (설명에 [DEPRECATED …] 접두). * * manifest 에 없는 이름은 throw 한다 — manifest 가 곧 인벤토리이므로 빠지면 즉시 드러나야 한다. */ export type ToolKind = 'read' | 'write' | 'destructive'; export interface ToolMeta { name: string; domain: string; kind: ToolKind; /** 외부 서비스를 호출하지 않음 (openWorldHint: false). */ local: boolean; idempotent: boolean; /** * destructive 도구가 자기 confirm 류 파라미터로 **모든 파괴적 경로**를 스스로 막는다 (manifest `ownGate`). * 레지스트라는 이런 도구에만 가드 주입을 생략한다 — 선언 없이 confirm 파라미터만 있으면 throw. */ ownGate: boolean; /** 이 이름이 폐기 예정 별칭이면 정식 도구 이름. */ deprecatedFor?: string; /** 이 도구를 가리키는 폐기 예정 별칭들. */ aliases: string[]; } /** 자체 확인 파라미터 이름 — manifest `ownGate` 도구는 이 중 하나를 스키마에 가져야 한다. */ export declare const CONFIRM_KEYS: readonly ["confirm", "confirmPublish", "confirmVisible"]; /** 레지스트라가 주입한 가드의 preview 첫 줄. 테스트와 에이전트가 이 문자열로 dry-run 을 식별한다. */ export declare const CONFIRM_PREVIEW_MARKER = "\uD83D\uDED1 DRY-RUN"; export declare function buildToolIndex(manifest: ToolManifest): Map; /** `playstore_submit_release` → `Play Store: Submit release`. */ export declare function toolTitle(name: string): string; export declare function annotationsFor(meta: ToolMeta): ToolAnnotations & { title: string; }; export declare function previewValue(key: string, value: unknown): string; export declare function confirmPreview(name: string, args: Record): CallToolResult; export interface ToolRegistrar { /** `McpServer.tool(name, description, shape, handler)` 와 같은 모양 — register 파일 호출부는 그대로다. */ tool(name: string, description: string, shape: Args, handler: ToolCallback): void; /** 이 서버에서 켜진 toolset (mimi_seed_status 가 보고한다). */ readonly toolsets: ToolsetSelection; readonly manifest: ToolManifest; } export declare function createToolRegistrar(server: McpServer, options: { manifest: ToolManifest; toolsets: ToolsetSelection; }): ToolRegistrar;