Skip to main content
Glama

list_templates

Browse available templates for creating MCP servers, optionally filtered by programming language, to accelerate development with pre-configured starting points.

Instructions

list available templates for MCP server creation.

Args:
    language: Filter by language (optional)

Returns:
    Formatted list of available templates

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
languageNo

Implementation Reference

  • main.py:133-162 (handler)
    The main MCP tool handler for 'list_templates', including registration via @mcp.tool() decorator. This function fetches templates from the template_manager and formats them for output.
    @mcp.tool()
    async def list_templates(ctx: Context, language: str | None = None) -> str:
        """
        list available templates for MCP server creation.
    
        Args:
            language: Filter by language (optional)
    
        Returns:
            Formatted list of available templates
        """
        try:
            template_manager = ctx.request_context.lifespan_context["template_manager"]
            templates = await template_manager.list_templates(language=language)
    
            if not templates:
                return "No templates available"
    
            result = "📋 Available Templates:\n\n"
            for lang, template_list in templates.items():
                result += f"**{lang.upper()}:**\n"
                for template in template_list:
                    result += f"  • {template['name']}: {template['description']}\n"
                result += "\n"
    
            return result
    
        except Exception as e:
            logger.error(f"Failed to list templates: {e}")
            return f"❌ Error listing templates: {str(e)}"
  • Core helper method in TemplateManager that performs the actual template listing and filtering by language, returning a structured dictionary of templates.
    async def list_templates(self, language: str | None = None) -> dict[str, list[dict]]:
        """list templates with optional language filtering."""
        result = {}
    
        for template in self.templates.values():
            if language and template.language != language:
                continue
    
            lang = template.language
            if lang not in result:
                result[lang] = []
    
            result[lang].append({
                "name": template.name,
                "description": template.description,
                "features": template.features,
            })
    
        return result

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/angrysky56/mcp-creator-mcp'

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