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
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Number of models to return (default: 20) |
Implementation Reference
- src/index.ts:574-591 (handler)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 }, }, }, },
- src/index.ts:236-241 (schema)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 }, }, },
- src/civitai-client.ts:186-192 (helper)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 }); }
- src/index.ts:327-361 (helper)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, }, }; }