list_models
Retrieve all available models for a specified LLM provider (e.g., OpenAI, Anthropic, Google Gemini) through the Just Prompt MCP server, enabling efficient model selection.
Instructions
List all available models for a specific LLM provider
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| provider | Yes | Provider to list models for (e.g., 'openai' or 'o') |
Implementation Reference
- src/just_prompt/server.py:209-215 (handler)Handler logic in the call_tool function that invokes list_models_func with the provider argument and formats the list of models as TextContent for the MCP response.elif name == JustPromptTools.LIST_MODELS: models = list_models_func(arguments["provider"]) return [TextContent( type="text", text=f"Models for provider '{arguments['provider']}':\n" + "\n".join([f"- {model}" for model in models]) )]
- src/just_prompt/server.py:73-75 (schema)Pydantic schema defining the input for the list_models tool, requiring a 'provider' string field.class ListModelsSchema(BaseModel): provider: str = Field(..., description="Provider to list models for (e.g., 'openai' or 'o')")
- src/just_prompt/server.py:147-151 (registration)Registration of the 'list_models' tool in the server's list_tools() method, including name, description, and input schema.Tool( name=JustPromptTools.LIST_MODELS, description="List all available models for a specific LLM provider", inputSchema=ListModelsSchema.schema(), ),
- Core list_models function imported and used by the handler; validates the provider and routes to ModelRouter for model listing.def list_models(provider: str) -> List[str]: """ List available models for a provider. Args: provider: Provider name (full or short) Returns: List of model names """ # Validate provider validate_provider(provider) # Get models from provider return ModelRouter.route_list_models(provider)
- ModelRouter.route_list_models dynamically imports the provider-specific module and calls its list_models() method to retrieve available models.def route_list_models(provider_name: str) -> List[str]: """ Route a list_models request to the appropriate provider. Args: provider_name: Provider name (full or short) Returns: List of model names """ provider = ModelProviders.from_name(provider_name) if not provider: raise ValueError(f"Unknown provider: {provider_name}") # Import the appropriate provider module try: module_name = f"just_prompt.atoms.llm_providers.{provider.full_name}" provider_module = importlib.import_module(module_name) # Call the list_models function return provider_module.list_models() except ImportError as e: logger.error(f"Failed to import provider module: {e}") raise ValueError(f"Provider not available: {provider.full_name}") except Exception as e: logger.error(f"Error listing models for {provider.full_name}: {e}") raise