mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-18 14:25:51 +00:00
28 lines
794 B
TypeScript
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
|
|
},
|
|
}
|
|
}
|