Skip to main content
Glama
Cicatriiz

Civitai MCP Server

get_latest_models

Retrieve recently uploaded AI models from Civitai's collection, with options to specify the number of models to fetch, for enhanced discovery and selection.

Instructions

Get the newest models uploaded to Civitai

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNoNumber of models to return (default: 20)

Implementation Reference

  • MCP tool handler for 'get_latest_models'. Calls CivitaiClient.getLatestModels, formats response using formatModelsResponse, and returns formatted text content.
    private async getLatestModels(args: any) { const response = await this.client.getLatestModels(args.limit); const formatted = this.formatModelsResponse(response); return { content: [ { type: 'text', text: `# Latest Models\\n\\n${formatted.models.map((model: any) => `**${model.name}** (${model.type})\\n` + `Creator: ${model.creator}\\n` + `Created: ${model.latestVersion ? new Date(model.latestVersion.createdAt).toLocaleDateString() : 'Unknown'}\\n` + `${model.description}\\n\\n` ).join('---\\n')}`, }, ], }; }
  • src/index.ts:234-242 (registration)
    Tool registration in getTools(), including name, description, and input schema definition.
    name: 'get_latest_models', description: 'Get the newest models uploaded to Civitai', inputSchema: { type: 'object', properties: { limit: { type: 'number', description: 'Number of models to return (default: 20)', minimum: 1, maximum: 100 }, }, }, },
  • Input schema for the get_latest_models tool.
    inputSchema: { type: 'object', properties: { limit: { type: 'number', description: 'Number of models to return (default: 20)', minimum: 1, maximum: 100 }, }, },
  • Helper method in CivitaiClient that calls getModels API with sort='Newest' to fetch latest models.
    async getLatestModels(limit: number = 20): Promise<ModelsResponse> { return this.getModels({ sort: 'Newest', limit, nsfw: false }); }
  • Helper function to format the raw API response into a structured model list used by getLatestModels.
    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, }, }; }

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