cp
Transfer AI models between locations within the Ollama MCP Server to manage and organize local LLM resources efficiently using source and destination paths.
Instructions
Copy a model
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| destination | Yes | ||
| source | Yes |
Implementation Reference
- src/index.ts:126-133 (handler)The handler function for the 'cp' tool. It takes source and destination model names, calls ollama.copy, and returns the result as JSON or an error message.async ({ source, destination }) => { try { const result = await ollama.copy({ source, destination }); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] }; } catch (error) { return { content: [{ type: "text", text: `Error: ${formatError(error)}` }], isError: true }; } }
- src/index.ts:122-125 (schema)The tool specification including title, description, and inputSchema for 'cp' tool, defining source and destination as strings using Zod.title: "Copy model", description: "Copy a model", inputSchema: { source: z.string(), destination: z.string() }, },
- src/index.ts:119-134 (registration)The registration of the 'cp' tool using server.registerTool, including schema and handler.server.registerTool( "cp", { title: "Copy model", description: "Copy a model", inputSchema: { source: z.string(), destination: z.string() }, }, async ({ source, destination }) => { try { const result = await ollama.copy({ source, destination }); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] }; } catch (error) { return { content: [{ type: "text", text: `Error: ${formatError(error)}` }], isError: true }; } } );
- src/index.ts:18-19 (helper)Helper function formatError used in the 'cp' handler and other tools to format errors.const formatError = (error: unknown): string => error instanceof Error ? error.message : String(error);