Files
claude-code/src/services/mcp/adapter/storage.ts
2026-05-01 21:39:30 +08:00

28 lines
794 B
TypeScript

// Host content storage adapter — bridges persistBinaryContent to mcp-client's ContentStorage interface
import type { ContentStorage } from '@claude-code-best/mcp-client'
import { persistBinaryContent } from '../../../utils/mcpOutputStorage.js'
import {
persistToolResult,
isPersistError,
} from '../../../utils/toolResultStorage.js'
/**
* Creates a ContentStorage implementation using the host's binary persistence.
*/
export function createMcpStorage(): ContentStorage {
return {
async persistBinaryContent(data: Buffer, ext: string) {
const result = await persistBinaryContent(
data,
ext,
`mcp-adapter-${Date.now()}`,
)
if ('error' in result) {
throw new Error(result.error)
}
return result.filepath
},
}
}