Skip to main content
Glama

list_models

Read-only

List locally installed Ollama models to view names, sizes, families, parameter sizes, and quantization levels.

Instructions

List locally-installed models: name, size in bytes, digest, modified timestamp, family (e.g. llama), parameter size (e.g. 8.0B), and quantization level (e.g. Q4_K_M).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The `listModels` function that executes the tool logic — calls Ollama's GET /api/tags to list locally-installed models and formats the response with name, size, digest, etc.
    async function listModels() {
      const r = await httpRequest('GET', '/api/tags');
      if (r.error) return errorResult(r.error);
      const models = (r.data?.models || []).map((m) => ({
        name: m.name,
        size_bytes: m.size,
        digest: m.digest,
        modified_at: m.modified_at,
        family: m.details?.family || null,
        parameter_size: m.details?.parameter_size || null,
        quantization_level: m.details?.quantization_level || null,
      }));
      return textResult({ count: models.length, models });
    }
  • Tool definition with name 'list_models', description, annotations, and inputSchema (empty object — no parameters needed).
    {
      name: 'list_models',
      description: 'List locally-installed models: name, size in bytes, digest, modified timestamp, family (e.g. llama), parameter size (e.g. 8.0B), and quantization level (e.g. Q4_K_M).',
      annotations: { title: 'List installed models', readOnlyHint: true, destructiveHint: false, openWorldHint: false },
      inputSchema: { type: 'object', properties: {}, additionalProperties: false },
    },
  • server.js:385-394 (registration)
    The HANDLERS mapping that registers 'list_models' to the listModels function for JSON-RPC dispatch.
    const HANDLERS = {
      ollama_status: ollamaStatus,
      list_models: listModels,
      list_running: listRunning,
      show_model: showModel,
      generate: generate,
      chat: chat,
      pull_model: pullModel,
      delete_model: deleteModel,
    };
  • The httpRequest helper used by listModels to call Ollama's GET /api/tags endpoint.
    // ─── HTTP helper ──────────────────────────────────────────────────────────
    function httpRequest(method, path, body) {
      return new Promise((resolve) => {
        let url;
        try {
          url = new URL(path, OLLAMA_URL);
        } catch (e) {
          resolve({ error: `invalid URL: ${e.message}` });
          return;
        }
        const lib = url.protocol === 'https:' ? https : http;
        const opts = {
          method,
          hostname: url.hostname,
          port: url.port || (url.protocol === 'https:' ? 443 : 80),
          path: url.pathname + url.search,
          headers: { 'accept': 'application/json' },
        };
        let bodyBuf = null;
        if (body !== undefined) {
          bodyBuf = Buffer.from(JSON.stringify(body), 'utf8');
          opts.headers['content-type'] = 'application/json';
          opts.headers['content-length'] = bodyBuf.length;
        }
        const req = lib.request(opts, (res) => {
          let chunks = Buffer.alloc(0);
          res.on('data', (d) => { chunks = Buffer.concat([chunks, d]); });
          res.on('end', () => {
            const text = chunks.toString('utf8');
            if (res.statusCode >= 400) {
              resolve({ status: res.statusCode, error: `HTTP ${res.statusCode}: ${text.slice(0, 500)}` });
              return;
            }
            // Some endpoints return text/plain (e.g. GET /); try JSON first, fall back to text.
            try { resolve({ status: res.statusCode, data: JSON.parse(text) }); }
            catch (_) { resolve({ status: res.statusCode, data: null, text }); }
          });
        });
        req.setTimeout(REQUEST_TIMEOUT_MS, () => {
          req.destroy(new Error(`request timed out after ${REQUEST_TIMEOUT_MS}ms`));
        });
        req.on('error', (e) => {
          // Give a friendly connection-refused message.
          const msg = /ECONNREFUSED|ENOTFOUND/.test(e.code || e.message)
            ? `cannot reach Ollama at ${OLLAMA_URL} — is the server running? Start it with \`ollama serve\` or open the Ollama app.`
            : e.message;
          resolve({ error: msg });
        });
        if (bodyBuf) req.write(bodyBuf);
        req.end();
      });
    }
  • The requireString helper used to validate required string arguments (though list_models has no inputs, this is a shared utility).
    function requireString(args, field) {
      if (typeof args[field] !== 'string' || !args[field].trim()) {
        return `${field} is required (non-empty string)`;
      }
      return null;
    }
Behavior3/5

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

Annotations already indicate readOnlyHint=true and destructiveHint=false. Description adds no additional behavioral traits such as authentication needs or data size limits. Does not contradict annotations.

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?

Single concise sentence that front-loads the action and lists key fields. No wasted words.

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

Completeness5/5

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

For a simple list with no input parameters and read-only annotations, the description fully explains what is returned. No need for pagination or filtering details given the schema.

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

Parameters4/5

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

Input schema has zero parameters (100% coverage by default). According to rubric, 0 params baseline is 4. Description adds meaning by listing output fields, which is helpful since no output schema exists.

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

Purpose5/5

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

Description clearly states 'List locally-installed models' with specific fields enumerated. Distinguishes from siblings like chat, delete_model, generate which have different purposes.

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?

Description implies a listing operation but provides no explicit guidance on when to use this tool vs alternatives like list_running or show_model. Usage context is implied but not explicit.

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/LukeLamb/claude-ollama-mcp'

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