Skip to main content
Glama
emgeee

MCP Ollama Server

list_models

Retrieve all downloaded Ollama models available for use through the MCP Ollama Server integration.

Instructions

List all downloaded Ollama models

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function for the 'list_models' tool. Decorated with @mcp.tool() for registration. Uses the ollama Client to list models, formats name, size, and modified time for each, returns formatted string or error.
    @mcp.tool()
    async def list_models() -> str:
        """List all downloaded Ollama models"""
        try:
            models = ollama.list()
            if not models.get('models'):
                return "No models found"
    
            formatted_models = []
            for model in models['models']:
                formatted_models.append(
                    f"Name: {model.get('model', 'Unknown')}\n"
                    f"Size: {model.get('size', 'Unknown')}\n"
                    f"Modified: {model.get('modified_at', 'Unknown')}\n"
                    "---"
                )
            return "\n".join(formatted_models)
        except Exception as e:
            return f"Error listing models: {str(e)}"
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/emgeee/mcp-ollama'

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