cp
Copy Ollama AI models locally to create duplicates or backups of existing models for different uses or testing.
Instructions
Copy a model
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| source | Yes | Source model name | |
| destination | Yes | Destination model name |
Implementation Reference
- src/index.ts:439-453 (handler)The handler function for the 'cp' tool. It executes the 'ollama cp' command with source and destination arguments, captures stdout/stderr, and returns it as text content. Errors are wrapped in McpError.private async handleCopy(args: any) { try { const { stdout, stderr } = await execAsync(`ollama cp ${args.source} ${args.destination}`); return { content: [ { type: 'text', text: stdout || stderr, }, ], }; } catch (error) { throw new McpError(ErrorCode.InternalError, `Failed to copy model: ${formatError(error)}`); } }
- src/index.ts:176-190 (schema)Input schema for the 'cp' tool defining required 'source' and 'destination' string properties.inputSchema: { type: 'object', properties: { source: { type: 'string', description: 'Source model name', }, destination: { type: 'string', description: 'Destination model name', }, }, required: ['source', 'destination'], additionalProperties: false, },
- src/index.ts:173-191 (registration)Tool registration object for 'cp' in the setTools call, including name, description, and inputSchema.{ name: 'cp', description: 'Copy a model', inputSchema: { type: 'object', properties: { source: { type: 'string', description: 'Source model name', }, destination: { type: 'string', description: 'Destination model name', }, }, required: ['source', 'destination'], additionalProperties: false, }, },
- src/index.ts:270-271 (registration)Dispatcher case in the request handler that routes 'cp' tool calls to handleCopy function.case 'cp': return await this.handleCopy(request.params.arguments);