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
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/mcp_ollama/server.py:20-38 (handler)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)}"