Civitai MCP Server (Python FastMCP)
A Python FastMCP implementation of an MCP server for interacting with the Civitai API. Browse AI models, images, creators, and more.
Features
- Model Search: Search AI models with various filters
- Model Details: Get detailed information about specific models
- Image Browsing: Browse AI-generated images
- Creator Search: Search for model creators
- Tag Search: Search models by tags
- Popular/Latest/Top Rated: Get ranking information
Installation
- Install dependencies:
pip install -r requirements.txt
- Set up environment variables (optional):
cp .env.example .env
# Edit .env file to set your Civitai API key
Usage
Standalone Execution
python civitai_mcp_server.py
Deploy your MCP server to Amazon Bedrock AgentCore
Deploy using Amazon Bedrock AgentCore starter toolkit
agentcore configure -e civitai_mcp_server.py --protocol MCP
agentcore launch
MCP Configuration
Add the following to your Kiro configuration file (.kiro/settings/mcp.json):
{
"mcpServers": {
"civitai": {
"command": "python",
"args": ["path/to/civitai_mcp_server.py"],
"env": {
"CIVITAI_API_KEY": "your_api_key_here"
},
"disabled": false,
"autoApprove": []
}
}
}
Available Tools
Model-related
search_models: Search models with query, type, sort filtersget_model: Get detailed model information by IDget_model_version: Get model version detailsget_model_version_by_hash: Get model version by file hashget_popular_models: Get popular modelsget_latest_models: Get newest modelsget_top_rated_models: Get highest rated modelssearch_models_by_tag: Search models by tagsearch_models_by_creator: Search models by creatorget_models_by_type: Filter models by typeget_download_url: Get download URL
Other
browse_images: Browse imagesget_creators: Search creatorsget_tags: Search tags
API Key
A Civitai API key is not required but recommended for:
- Access to private models
- Higher rate limits
- Some advanced features
You can get an API key from your Civitai account settings.
Examples
# Search models
search_models(query="anime", limit=10, sort="Most Downloaded")
# Get specific model details
get_model(model_id=12345)
# Get popular LORA models
get_models_by_type(type="LORA", sort="Most Downloaded", limit=5)
# Browse images
browse_images(limit=20, nsfw="None", sort="Newest")
Notes
- API responses can be large
- Use NSFW filtering options appropriately
- Store API keys securely using environment variables