get_model_version_by_hash
Retrieve detailed version information for a model on Civitai MCP Server by providing its file hash (AutoV1, AutoV2, SHA256, CRC32, or Blake3). Streamlines model identification and access.
Instructions
Get model version information by file hash
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| hash | Yes | The hash of the model file (AutoV1, AutoV2, SHA256, CRC32, or Blake3) |
Implementation Reference
- src/index.ts:477-497 (handler)Main handler function that executes the tool logic: extracts hash argument, fetches model version via client, formats response as MCP text content.private async getModelVersionByHash(args: any) { const { hash } = args; const version = await this.client.getModelVersionByHash(hash); return { content: [ { type: 'text', text: `# Model Found by Hash\\n\\n` + `**Model:** ${version.model.name}\\n` + `**Version:** ${version.name} (ID: ${version.id})\\n` + `**Type:** ${version.model.type}\\n` + `**Hash:** ${hash}\\n\\n` + `**Created:** ${new Date(version.createdAt).toLocaleDateString()}\\n` + `**Downloads:** ${version.stats.downloadCount?.toLocaleString() || 0}\\n` + `**Trained Words:** ${version.trainedWords.join(', ') || 'None'}\\n\\n` + `**Description:**\\n${version.description}`, }, ], }; }
- src/index.ts:153-163 (registration)Tool registration in getTools() array, including name, description, and input schema definition.{ name: 'get_model_version_by_hash', description: 'Get model version information by file hash', inputSchema: { type: 'object', properties: { hash: { type: 'string', description: 'The hash of the model file (AutoV1, AutoV2, SHA256, CRC32, or Blake3)' }, }, required: ['hash'], }, },
- src/types.ts:143-161 (schema)Zod schema for validating the Civitai API response of model version data, used in the client makeRequest.export const ModelVersionResponseSchema = z.object({ id: z.number(), name: z.string(), description: z.string(), model: z.object({ name: z.string(), type: ModelType, nsfw: z.boolean(), poi: z.boolean().optional(), mode: ModelMode, }), modelId: z.number(), createdAt: z.string(), downloadUrl: z.string(), trainedWords: z.array(z.string()), files: z.array(ModelFileSchema), stats: StatsSchema, images: z.array(ImageSchema), });
- src/civitai-client.ts:134-137 (helper)Supporting client method that builds the API endpoint URL and performs the HTTP request with response validation.async getModelVersionByHash(hash: string): Promise<ModelVersionResponse> { const url = this.buildUrl(`/model-versions/by-hash/${hash}`); return this.makeRequest<ModelVersionResponse>(url, ModelVersionResponseSchema); }
- src/index.ts:55-56 (handler)Switch case in CallToolRequestSchema handler that routes the tool call to the specific handler method.case 'get_model_version_by_hash': return await this.getModelVersionByHash(args);