ollama_copy
Copy a model to create a duplicate with a new name, enabling model backup or version creation.
Instructions
Copy a model. Creates a duplicate of an existing model with a new name.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| source | Yes | Name of the source model | |
| destination | Yes | Name for the copied model | |
| format | No | json |
Implementation Reference
- src/tools/copy.ts:10-22 (handler)The core handler function for ollama_copy. Calls ollama.copy() with source and destination, then formats the response.
export async function copyModel( ollama: Ollama, source: string, destination: string, format: ResponseFormat ): Promise<string> { const response = await ollama.copy({ source, destination, }); return formatResponse(JSON.stringify(response), format); } - src/tools/copy.ts:24-51 (registration)The ToolDefinition export that registers 'ollama_copy' with its name, description, input schema, and a handler that validates args with CopyModelInputSchema before calling copyModel.
export const toolDefinition: ToolDefinition = { name: 'ollama_copy', description: 'Copy a model. Creates a duplicate of an existing model with a new name.', inputSchema: { type: 'object', properties: { source: { type: 'string', description: 'Name of the source model', }, destination: { type: 'string', description: 'Name for the copied model', }, format: { type: 'string', enum: ['json', 'markdown'], default: 'json', }, }, required: ['source', 'destination'], }, handler: async (ollama: Ollama, args: Record<string, unknown>, format: ResponseFormat) => { const validated = CopyModelInputSchema.parse(args); return copyModel(ollama, validated.source, validated.destination, format); }, }; - src/schemas.ts:184-191 (schema)Zod schema for ollama_copy input validation: requires source (string), destination (string), and optional format (default 'json').
/** * Schema for ollama_copy tool */ export const CopyModelInputSchema = z.object({ source: z.string().min(1), destination: z.string().min(1), format: ResponseFormatSchema.default('json'), }); - src/utils/response-formatter.ts:7-10 (helper)The formatResponse function used by copyModel to format the Ollama API response as JSON or markdown.
export function formatResponse( content: string, format: ResponseFormat ): string { - src/autoloader.ts:31-57 (helper)The discoverTools function that auto-discovers all tool definitions (including ollama_copy) from the tools directory by dynamic import.
export async function discoverTools(): Promise<ToolDefinition[]> { const toolsDir = join(__dirname, 'tools'); const files = await readdir(toolsDir); // Filter for .js files (production) or .ts files (development) // Exclude test files and declaration files const toolFiles = files.filter( (file) => (file.endsWith('.js') || file.endsWith('.ts')) && !file.includes('.test.') && !file.endsWith('.d.ts') ); const tools: ToolDefinition[] = []; for (const file of toolFiles) { const toolPath = join(toolsDir, file); const module = await import(toolPath); // Check if module exports tool metadata if (module.toolDefinition) { tools.push(module.toolDefinition); } } return tools; }