Skip to main content
Glama
TrueOleg

MCP Mac Apps Server

by TrueOleg

ollama_generate

Generate AI text responses using local Ollama models for tasks requiring natural language processing on macOS.

Instructions

Генерирует ответ используя локальную модель Ollama. Используйте для задач, требующих AI обработки текста

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
modelNoНазвание модели Ollama (например, 'llama3.2', 'deepseek-r1:8b'). По умолчанию 'llama3.2'llama3.2
promptYesЗапрос для модели

Implementation Reference

  • Python handler function for ollama_generate tool that sends a POST request to Ollama API to generate text.
    def ollama_generate(prompt: str, model: str = "llama3.2") -> str:
        """Generates response via Ollama API"""
        try:
            response = requests.post(
                f"{OLLAMA_API_URL}/api/generate",
                json={"model": model, "prompt": prompt, "stream": False},
                timeout=30,
            )
            response.raise_for_status()
            data = response.json()
            return data.get("response", "No response from model")
        except requests.exceptions.ConnectionError:
            raise Exception(
                f"Failed to connect to Ollama server ({OLLAMA_API_URL}). "
                "Make sure Ollama is running: ollama serve"
            )
        except Exception as e:
            raise Exception(f"Ollama error: {str(e)}")
  • TypeScript handler method for ollama_generate tool that uses fetch to call Ollama API.
    private async ollamaGenerate(prompt: string, model: string = "llama3.2") {
      try {
        const response = await fetch(`${OLLAMA_API_URL}/api/generate`, {
          method: "POST",
          headers: {
            "Content-Type": "application/json",
          },
          body: JSON.stringify({
            model,
            prompt,
            stream: false,
          }),
        });
    
        if (!response.ok) {
          const errorText = await response.text();
          throw new Error(
            `Ollama API error: ${response.status} ${errorText}`
          );
        }
    
        const data = (await response.json()) as { response?: string };
        return {
          content: [
            {
              type: "text",
              text: data.response || "Нет ответа от модели",
            },
          ],
        };
      } catch (error) {
        // Проверяем, доступен ли Ollama сервер
        if (error instanceof TypeError && error.message.includes("fetch")) {
          throw new Error(
            `Не удалось подключиться к Ollama серверу (${OLLAMA_API_URL}). Убедитесь, что Ollama запущен: ollama serve`
          );
        }
        throw new Error(
          `Ошибка Ollama: ${error instanceof Error ? error.message : String(error)}`
        );
      }
  • Input schema for ollama_generate tool in the Python MCP server.
    {
        "name": "ollama_generate",
        "description": "Generates response using local Ollama model. Use for tasks requiring AI text processing",
        "inputSchema": {
            "type": "object",
            "properties": {
                "model": {
                    "type": "string",
                    "description": "Ollama model name (e.g., 'llama3.2', 'deepseek-r1:8b'). Default 'llama3.2'",
                    "default": "llama3.2",
                },
                "prompt": {
                    "type": "string",
                    "description": "Prompt for the model",
                },
            },
            "required": ["prompt"],
        },
    },
  • Input schema for ollama_generate tool in the TypeScript MCP server.
    {
      name: "ollama_generate",
      description: "Генерирует ответ используя локальную модель Ollama. Используйте для задач, требующих AI обработки текста",
      inputSchema: {
        type: "object",
        properties: {
          model: {
            type: "string",
            description: "Название модели Ollama (например, 'llama3.2', 'deepseek-r1:8b'). По умолчанию 'llama3.2'",
            default: "llama3.2",
          },
          prompt: {
            type: "string",
            description: "Запрос для модели",
          },
        },
        required: ["prompt"],
      },
  • src/server.py:611-614 (registration)
    Dispatch/registration point in Python handle_request where ollama_generate is called.
    elif tool_name == "ollama_generate":
        result_text = ollama_generate(
            arguments.get("prompt"), arguments.get("model", "llama3.2")
        )
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions the tool generates responses using a local model, which implies it's a read-only operation that doesn't modify data, but it doesn't cover other behavioral aspects like potential rate limits, error handling, or performance characteristics. For a tool with no annotations, this leaves significant gaps in understanding how it behaves beyond the basic function.

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

Conciseness4/5

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

The description is concise and front-loaded, consisting of two sentences that directly state the purpose and usage. There's no unnecessary information, and each sentence serves a clear function: the first defines the tool, and the second provides guidance. It could be slightly improved by integrating the two ideas more seamlessly, but it's efficient overall.

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

Completeness3/5

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

Given the tool has 2 parameters, no annotations, and no output schema, the description provides a basic but incomplete context. It covers the purpose and general usage but lacks details on behavioral traits, output format, or error handling. For a text generation tool with local model interaction, more information on limitations or expected responses would enhance completeness, making it adequate but with clear gaps.

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 schema description coverage is 100%, with both parameters ('model' and 'prompt') fully described in the schema. The description doesn't add any additional meaning beyond what the schema provides (e.g., it doesn't explain parameter interactions or provide examples). According to the rules, with high schema coverage (>80%), the baseline score is 3, as the schema already documents the parameters adequately.

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 tool's purpose: 'Генерирует ответ используя локальную модель Ollama' (Generates a response using the local Ollama model). It specifies the verb ('генерирует' - generates) and resource ('локальную модель Ollama' - local Ollama model), making the function unambiguous. However, it doesn't explicitly differentiate from sibling tools like 'ollama_list_models', though the distinction is implied by the different actions.

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

Usage Guidelines3/5

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

The description provides some usage guidance: 'Используйте для задач, требующих AI обработки текста' (Use for tasks requiring AI text processing). This implies the context (text processing tasks) but doesn't specify when to use this tool versus alternatives (e.g., other AI tools not listed as siblings) or any exclusions. It's helpful but lacks explicit alternatives or detailed when-not-to-use scenarios.

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/TrueOleg/MCP-expirements'

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