Skip to main content
Glama
Cicatriiz

Civitai MCP Server

search_models

Use this tool to find AI models on Civitai with filters like type, base model, and sorting options. Enable precise searches for Checkpoint, LORA, Controlnet, and more.

Instructions

Search for AI models on Civitai with various filters

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
baseModelsNoFilter by base model types (e.g., ["SD 1.5", "SDXL 1.0"])
limitNoNumber of results (1-100, default 20)
nsfwNoInclude NSFW content
pageNoPage number for pagination
periodNoTime period for sorting
queryNoSearch query to filter models by name
sortNoSort order for results
typesNoFilter by model types

Implementation Reference

  • The main handler function for the 'search_models' tool. It calls the CivitaiClient's getModels method with the provided arguments, formats the response, and returns a formatted text response for the MCP protocol.
    private async searchModels(args: any) {
      const response = await this.client.getModels(args);
      const formatted = this.formatModelsResponse(response);
      
      return {
        content: [
          {
            type: 'text',
            text: `Found ${formatted.pagination.totalItems} models:\\n\\n${formatted.models.map((model: any) => 
              `**${model.name}** (${model.type})\\n` +
              `Creator: ${model.creator}\\n` +
              `Downloads: ${model.stats.downloads.toLocaleString()} | Rating: ${model.stats.rating.toFixed(1)}\\n` +
              `Tags: ${model.tags.join(', ')}\\n` +
              `${model.description}\\n`
            ).join('\\n---\\n')}\\n\\nPage ${formatted.pagination.currentPage} of ${formatted.pagination.totalPages}`,
          },
        ],
      };
    }
  • Tool schema definition including input schema with properties for query, limit, page, types, sort, period, nsfw, and baseModels.
      name: 'search_models',
      description: 'Search for AI models on Civitai with various filters',
      inputSchema: {
        type: 'object',
        properties: {
          query: { type: 'string', description: 'Search query to filter models by name' },
          limit: { type: 'number', description: 'Number of results (1-100, default 20)', minimum: 1, maximum: 100 },
          page: { type: 'number', description: 'Page number for pagination', minimum: 1 },
          types: { 
            type: 'array', 
            items: { 
              type: 'string',
              enum: ['Checkpoint', 'TextualInversion', 'Hypernetwork', 'AestheticGradient', 'LORA', 'Controlnet', 'Poses']
            },
            description: 'Filter by model types'
          },
          sort: { 
            type: 'string', 
            enum: ['Highest Rated', 'Most Downloaded', 'Newest'],
            description: 'Sort order for results'
          },
          period: {
            type: 'string',
            enum: ['AllTime', 'Year', 'Month', 'Week', 'Day'],
            description: 'Time period for sorting'
          },
          nsfw: { type: 'boolean', description: 'Include NSFW content' },
          baseModels: {
            type: 'array',
            items: { type: 'string' },
            description: 'Filter by base model types (e.g., ["SD 1.5", "SDXL 1.0"])'
          }
        },
      },
    },
  • src/index.ts:49-50 (registration)
    Registration of the tool handler in the switch statement within the CallToolRequestSchema handler.
    case 'search_models':
      return await this.searchModels(args);
  • Helper function to format the raw models response from the API into a structured format used by the handler.
    private formatModelsResponse(response: any) {
      const models = response.items.map((model: any) => {
        const latestVersion = model.modelVersions[0];
        return {
          id: model.id,
          name: model.name,
          type: model.type,
          creator: model.creator.username,
          description: model.description.substring(0, 200) + (model.description.length > 200 ? '...' : ''),
          tags: model.tags.slice(0, 5), // Limit tags for readability
          nsfw: model.nsfw,
          stats: {
            downloads: model.stats?.downloadCount || 0,
            rating: model.stats?.rating || 0,
            favorites: model.stats?.favoriteCount || 0,
          },
          latestVersion: latestVersion ? {
            id: latestVersion.id,
            name: latestVersion.name,
            createdAt: latestVersion.createdAt,
            trainedWords: latestVersion.trainedWords,
          } : null,
        };
      });
    
      return {
        models,
        pagination: {
          currentPage: response.metadata.currentPage || 1,
          totalPages: response.metadata.totalPages || 1,
          totalItems: response.metadata.totalItems || models.length,
          hasNextPage: response.metadata.nextPage ? true : false,
        },
      };
    }
  • Core API client method called by the tool handler to fetch models from Civitai API endpoint '/models' with search parameters.
    async getModels(params: ModelsParams = {}): Promise<ModelsResponse> {
      const url = this.buildUrl('/models', params);
      return this.makeRequest<ModelsResponse>(url, ModelsResponseSchema);
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It only states the basic function without mentioning important behavioral aspects like whether this is a read-only operation, potential rate limits, authentication requirements, pagination behavior (implied by the 'page' parameter but not explained), or what the response format looks like.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that gets straight to the point with zero wasted words. It's appropriately sized for a search tool and front-loads the core functionality.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a search tool with 8 parameters, no annotations, and no output schema, the description is inadequate. It doesn't explain the relationship to sibling tools, doesn't describe the return format, and provides minimal behavioral context. The agent would struggle to use this effectively without trial and error.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema description coverage is 100%, so the schema already documents all 8 parameters thoroughly with descriptions, constraints, and enums. The description adds no additional parameter information beyond what's in the schema, meeting the baseline expectation when schema coverage is complete.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Search for AI models') and the resource ('on Civitai'), making the purpose understandable. However, it doesn't distinguish this tool from its many siblings (like get_latest_models, get_popular_models, search_models_by_creator, etc.), which all involve retrieving models with different approaches.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus the numerous sibling tools. It mentions 'various filters' but doesn't explain when filtered searching is preferable to the more specific sibling tools like get_latest_models or search_models_by_creator.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related 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/Cicatriiz/civitai-mcp-server'

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