Skip to main content
Glama

recommend_models

Get ranked AI model recommendations with cost estimates by describing your use case in plain English. Covers 62 models across 29 providers.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
use_caseYesNatural language description of what you want to build or do with an AI model

Implementation Reference

  • Tool registration and handler definition for 'recommend_models'. Validates input, fetches model data, and calls the core recommendation function.
    server.tool(
      "recommend_models",
      {
        use_case: z
          .string()
          .describe(
            "Natural language description of what you want to build or do with an AI model",
          ),
      },
      async ({ use_case }) => {
        const apiKey = process.env.ANTHROPIC_API_KEY;
        if (!apiKey) {
          return {
            content: [
              {
                type: "text" as const,
                text: "Error: ANTHROPIC_API_KEY environment variable is required.",
              },
            ],
          };
        }
    
        try {
          const validation = await validateQuery(use_case, apiKey);
          if (!validation.valid) {
            return {
              content: [
                {
                  type: "text" as const,
                  text:
                    validation.message ??
                    "Please describe an AI use case you want to build.",
                },
              ],
            };
          }
    
          const { models, ageHours } = await getModels();
          const recs = await recommend(use_case, models, apiKey);
    
          const result = recs.map((r) => ({
            model_id: r.model_id,
            rank: r.rank,
            rank_label: r.rank_label,
            reasoning: r.reasoning,
            cost_estimate: r.estimated_cost_example,
            tradeoffs: r.tradeoffs,
            dataset_age_hours: ageHours,
          }));
    
          return {
            content: [
              { type: "text" as const, text: JSON.stringify(result, null, 2) },
            ],
          };
        } catch (err) {
          const msg = err instanceof Error ? err.message : "Unknown error";
          return {
            content: [{ type: "text" as const, text: `Error: ${msg}` }],
          };
        }
      },
    );
  • The core recommendation logic that orchestrates calling Claude and parsing the response.
    export async function recommend(
      userQuery: string,
      models: Model[],
      apiKey?: string,
    ): Promise<Recommendation[]> {
      if (!userQuery.trim()) throw new Error("Query cannot be empty");
      if (!models.length) throw new Error("Models array cannot be empty");
    
      const raw = await callClaude(userQuery, models, apiKey);
      return parseRecommendations(raw);
    }
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/kalraakshit042/ai-compass'

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