import type { CanUseTool, McpSdkServerConfigWithInstance } from "@anthropic-ai/claude-agent-sdk"; import type { Files } from "../index.js"; import type { ApprovalConfig } from "../internal/ai-tools/approval.js"; import type { FileReadToolName, FileToolName, FileWriteToolName } from "../internal/ai-tools/schemas.js"; import type { ClaudeToolOverrides } from "./types.js"; export type { ApprovalConfig, FileReadToolName, FileToolName, FileWriteToolName, }; export interface ClaudeFileToolsOptions { /** * The configured `Files` instance the tools will operate against. */ files: Files; /** * When `true`, write tools (`uploadFile`, `deleteFile`, `copyFile`, * `signUploadUrl`) are omitted from the MCP server. The model cannot * mutate the bucket regardless of approval configuration. */ readOnly?: boolean; /** * Approval gating reflected by {@link ClaudeFileTools.needsApproval} and * the bundled {@link ClaudeFileTools.canUseTool}. Defaults to `true` * (every write requires approval). Pass `false` to disable, or an object * keyed by write-tool name for fine-grained control. */ requireApproval?: ApprovalConfig; /** * Per-tool overrides for `description` / `annotations` without touching * the underlying handler or input schema. */ overrides?: Partial>; /** * Name of the in-process MCP server that wraps these tools. Affects the * `mcp____` strings the agent uses to address * each tool. Defaults to `"files"`. */ serverName?: string; /** * MCP server `version` metadata. Defaults to `"1.0.0"`. */ serverVersion?: string; } export interface ClaudeFileTools { /** * Pass into `query({ options: { mcpServers: tools.mcpServers } })`. */ mcpServers: Record; /** * Pass into `query({ options: { allowedTools: tools.allowedTools } })`. * Each entry is of the form `mcp____`. */ allowedTools: string[]; /** * Ready-made `canUseTool` callback. Allows reads unconditionally, allows * writes whose `needsApproval` resolves to `false`, denies the rest with * a `"requires approval"` message. Pass directly into `query()`, or * compose your own using {@link ClaudeFileTools.needsApproval}. */ canUseTool: CanUseTool; /** * Whether the named tool is approval-gated under the configured * `requireApproval`. Accepts both bare names (`"uploadFile"`) and the * MCP-prefixed form (`"mcp__files__uploadFile"`). Read tools and unknown * names return `false`. */ needsApproval(toolName: string): boolean; /** * The raw SDK MCP server instance — same value as * `mcpServers[serverName]`. Exposed for callers that want to compose it * into a larger `mcpServers` map. */ server: McpSdkServerConfigWithInstance; /** * The MCP server name used in the `mcp____*` prefix. */ serverName: string; } /** * Create files-sdk tools shaped for the Claude Agent SDK * (`@anthropic-ai/claude-agent-sdk`). * * The Claude Agent SDK consumes tools by way of an in-process MCP server + * an `allowedTools` allow-list + a `canUseTool` approval callback. The * returned bundle gives you all three, plus the raw server instance and a * `needsApproval()` helper if you want to wire your own `canUseTool`. * * @example * ```ts * import { query } from "@anthropic-ai/claude-agent-sdk"; * import { Files } from "files-sdk"; * import { s3 } from "files-sdk/s3"; * import { createClaudeFileTools } from "files-sdk/claude"; * * const files = new Files({ adapter: s3({ bucket: "uploads" }) }); * const tools = createClaudeFileTools({ files }); * * for await (const message of query({ * prompt: "List my files.", * options: { * mcpServers: tools.mcpServers, * allowedTools: tools.allowedTools, * canUseTool: tools.canUseTool, * }, * })) { * // handle messages * } * ``` * * @example Read-only agent * ```ts * createClaudeFileTools({ files, readOnly: true }) * ``` * * @example Granular approval * ```ts * createClaudeFileTools({ * files, * requireApproval: { * deleteFile: true, * uploadFile: false, * copyFile: false, * signUploadUrl: true, * }, * }) * ``` */ export declare const createClaudeFileTools: ({ files, readOnly, requireApproval, overrides, serverName, serverVersion, }: ClaudeFileToolsOptions) => ClaudeFileTools; export { claudeCopyFile, claudeDeleteFile, claudeDownloadFile, claudeGetFileMetadata, claudeGetFileUrl, claudeListFiles, claudeSignUploadUrl, claudeUploadFile, } from "./tools.js"; export type { ClaudeWriteToolOptions } from "./tools.js"; export type { ClaudeToolOverrides, ToolAnnotations } from "./types.js"; //# sourceMappingURL=index.d.ts.map