ollama_push
Upload a local model to the Ollama registry to make it accessible from remote locations.
Instructions
Push a model to the Ollama registry. Uploads a local model to make it available remotely.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| model | Yes | Name of the model to push | |
| insecure | No | Allow insecure connections | |
| format | No | json |
Implementation Reference
- src/tools/push.ts:10-23 (handler)The core handler function that executes the push operation. Calls ollama.push() with model, insecure flag, and stream:false, then formats the response as JSON.
export async function pushModel( ollama: Ollama, model: string, insecure: boolean, format: ResponseFormat ): Promise<string> { const response = await ollama.push({ model, insecure, stream: false, }); return formatResponse(JSON.stringify(response), format); } - src/schemas.ts:158-162 (schema)Zod schema for validating the ollama_push tool's input parameters: model (required string), insecure (optional boolean, default false), and format (optional enum, default 'json').
export const PushModelInputSchema = z.object({ model: z.string().min(1), insecure: z.boolean().default(false), format: ResponseFormatSchema.default('json'), }); - src/tools/push.ts:25-53 (registration)The tool definition registration object exported as 'toolDefinition'. Defines the tool name 'ollama_push', description, input schema properties with types/descriptions/defaults, and the handler function that validates args and calls pushModel.
export const toolDefinition: ToolDefinition = { name: 'ollama_push', description: 'Push a model to the Ollama registry. Uploads a local model to make it available remotely.', inputSchema: { type: 'object', properties: { model: { type: 'string', description: 'Name of the model to push', }, insecure: { type: 'boolean', description: 'Allow insecure connections', default: false, }, format: { type: 'string', enum: ['json', 'markdown'], default: 'json', }, }, required: ['model'], }, handler: async (ollama: Ollama, args: Record<string, unknown>, format: ResponseFormat) => { const validated = PushModelInputSchema.parse(args); return pushModel(ollama, validated.model, validated.insecure, format); }, }; - src/autoloader.ts:44-57 (registration)The autoloader discovers tool definitions (including ollama_push) by scanning the tools directory for modules exporting a 'toolDefinition' and collects them into an array.
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; } - src/utils/response-formatter.ts:7-34 (helper)Utility function that formats the push response output as either JSON or markdown based on the requested format.
export function formatResponse( content: string, format: ResponseFormat ): string { if (format === ResponseFormat.JSON) { // For JSON format, validate and potentially wrap errors try { // Try to parse to validate it's valid JSON JSON.parse(content); return content; } catch { // If not valid JSON, wrap in error object return JSON.stringify({ error: 'Invalid JSON content', raw_content: content, }); } } // Format as markdown try { const data = JSON.parse(content); return jsonToMarkdown(data); } catch { // If not valid JSON, return as-is return content; } }