Skip to main content
Glama
hyzhak

Ollama MCP Server

by hyzhak

Run model

run

Execute local AI models with text prompts, supporting vision models through image inputs and temperature control for response variation.

Instructions

Run a model with a prompt. Optionally accepts an image file path for vision/multimodal models and a temperature parameter.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYes
promptYes
imagesNo
temperatureNo
thinkNo

Implementation Reference

  • Handler function for the 'run' tool. Executes ollama.generate with model name, prompt, optional images, temperature, and think parameters. Formats response including thinking if present, handles errors.
    async ({ name, prompt, images, temperature, think }) => {
      try {
        const result = await ollama.generate({
          model: name,
          prompt,
          options: temperature !== undefined ? { temperature } : {},
          ...(images ? { images } : {}),
          ...(think !== undefined ? { think } : {}),
        });
    
        const content: Array<ContentBlock> = [];
        if (result?.thinking) {
          content.push({ type: "text", text: `<think>${result.thinking}</think>` });
        }
        content.push({ type: "text", text: result.response ?? "" });
        return { content };
      } catch (error) {
        return { content: [{ type: "text", text: `Error: ${formatError(error)}` }], isError: true };
      }
    }
  • Input schema definition for the 'run' tool using Zod, defining required name and prompt, optional images array, temperature (0-2), and think boolean.
    {
      title: "Run model",
      description: "Run a model with a prompt. Optionally accepts an image file path for vision/multimodal models and a temperature parameter.",
      inputSchema: { 
        name: z.string(), 
        prompt: z.string(),
        images: z.array(z.string()).optional(), // Array of image paths
        temperature: z.number().min(0).max(2).optional(),
        think: z.boolean().optional(),
      },
    },
  • src/index.ts:155-188 (registration)
    Registration of the 'run' tool using server.registerTool, including name, schema, and inline handler function.
    server.registerTool(
      "run",
      {
        title: "Run model",
        description: "Run a model with a prompt. Optionally accepts an image file path for vision/multimodal models and a temperature parameter.",
        inputSchema: { 
          name: z.string(), 
          prompt: z.string(),
          images: z.array(z.string()).optional(), // Array of image paths
          temperature: z.number().min(0).max(2).optional(),
          think: z.boolean().optional(),
        },
      },
      async ({ name, prompt, images, temperature, think }) => {
        try {
          const result = await ollama.generate({
            model: name,
            prompt,
            options: temperature !== undefined ? { temperature } : {},
            ...(images ? { images } : {}),
            ...(think !== undefined ? { think } : {}),
          });
    
          const content: Array<ContentBlock> = [];
          if (result?.thinking) {
            content.push({ type: "text", text: `<think>${result.thinking}</think>` });
          }
          content.push({ type: "text", text: result.response ?? "" });
          return { content };
        } catch (error) {
          return { content: [{ type: "text", text: `Error: ${formatError(error)}` }], isError: true };
        }
      }
    );
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions optional parameters but fails to describe critical behaviors such as rate limits, authentication needs, error handling, or what the tool returns. For a tool that likely involves AI model execution, this lack of detail is a significant gap.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized and front-loaded in a single sentence, efficiently stating the core purpose and optional parameters without unnecessary words. Every part earns its place by conveying essential information concisely.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of running AI models, no annotations, no output schema, and low parameter coverage, the description is incomplete. It lacks details on return values, error cases, model compatibility, or prerequisites, making it inadequate for safe and effective tool invocation by an agent.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description adds some meaning by specifying that 'images' are for vision/multimodal models and 'temperature' is a parameter, but with 0% schema description coverage and 5 parameters total, it doesn't fully compensate. Key parameters like 'name', 'prompt', and 'think' are undocumented in both schema and description, leaving semantics unclear.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('run') and resource ('model'), specifying it accepts a prompt and optionally image files and temperature. However, it doesn't distinguish this tool from sibling tools like 'chat_completion' or 'cp', which might have overlapping functionality with models.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'chat_completion' or 'create'. It mentions optional parameters but doesn't explain scenarios where this tool is preferred or excluded, leaving the agent without context for selection.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/hyzhak/ollama-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server