
Unsplash Smart
STDIOAI-powered Unsplash image search and download with attribution management for AI agents
AI-powered Unsplash image search and download with attribution management for AI agents
Empower your AI agents with stunning visuals, zero hassle.
A powerful FastMCP server that enables AI agents to seamlessly search, recommend, and deliver professional stock photos from Unsplash with intelligent context awareness and automated attribution management.
In the landscape of visual content integration, our Unsplash Smart MCP Server stands out as the definitive solution for AI-powered image acquisition:
stock_photo
tool that handles the entire image workflowgit clone https://github.com/drumnation/unsplash-smart-mcp-server.git cd unsplash-smart-mcp-server
npm install
Configure your Cursor MCP settings:
~/.cursor/mcp.json
%USERPROFILE%\.cursor\mcp.json
~/.cursor/mcp.json
Add the following configuration:
{ "servers": { "unsplash": { "command": "npx", "args": ["tsx", "src/server.ts"], "cwd": "/absolute/path/to/unsplash-smart-mcp-server", "env": { "UNSPLASH_ACCESS_KEY": "your_api_key_here" } } } }
Replace:
/absolute/path/to/unsplash-smart-mcp-server
with the actual path where you cloned the repoyour_api_key_here
with your Unsplash API keySave the file and restart Cursor.
Important: Unlike many MCP servers, this server requires direct process piping and cannot be accessed via TCP ports or through npm directly due to how it handles FastMCP's I/O interactions. The local installation method is the most reliable approach.
If you prefer using Cursor's CLI:
claude mcp add unsplash npx tsx /path/to/unsplash-smart-mcp-server/src/server.ts --cwd /path/to/unsplash-smart-mcp-server claude mcp config set unsplash UNSPLASH_ACCESS_KEY=your_api_key_here
Replace the paths and API key with your actual values.
git clone https://github.com/drumnation/unsplash-smart-mcp-server.git cd unsplash-smart-mcp-server
docker-compose.yml
file:services: unsplash-mcp: build: . image: unsplash-mcp-server restart: always stdin_open: true tty: true environment: - UNSPLASH_ACCESS_KEY=your_api_key_here
docker-compose up -d
Configure your Cursor MCP settings:
~/.cursor/mcp.json
%USERPROFILE%\.cursor\mcp.json
~/.cursor/mcp.json
Add the following configuration:
{ "servers": { "unsplash": { "command": "docker", "args": ["exec", "-i", "unsplash-mcp-unsplash-mcp-1", "tsx", "src/server.ts"], "env": {} } } }
This setup will:
If you prefer cloud deployment, you can use Smithery:
npx @smithery/cli install @drumnation/unsplash-smart-mcp-server --client cursor --key your_api_key_here
Note for Windows users: Smithery deployment includes special handling for Windows compatibility.
For detailed instructions and troubleshooting, see the Smithery Deployment Guide.
Our Unsplash Smart MCP Server is designed to make image acquisition through AI agents effortless and intuitive:
stock_photo
tool with optimized parametersThis process eliminates the traditional workflow of:
Ask Claude in Cursor for images using natural language prompts like these:
"Find a professional image for a tech startup landing page hero section"
If you're using Windows and experiencing the "Client closed" error when running the MCP server in Cursor, follow these special configuration steps:
Create a file named mcp.json
in your .cursor
directory (typically at %USERPROFILE%\.cursor\mcp.json
) with one of these configurations:
{ "mcpServers": { "stock_photo": { "command": "node", "args": ["./node_modules/.bin/tsx", "path/to/unsplash-mcp/src/server.ts"], "disabled": false, "env": { "UNSPLASH_ACCESS_KEY": "your_api_key_here" }, "shell": false } } }
{ "mcpServers": { "stock_photo": { "command": "powershell", "args": ["-Command", "npx tsx path/to/unsplash-mcp/src/server.ts"], "disabled": false, "env": { "UNSPLASH_ACCESS_KEY": "your_api_key_here" } } } }
For complete documentation on Windows compatibility, see Windows Compatibility Guide.
Our architecture uses a URL-first approach rather than direct image embedding for several critical reasons:
This strategy enables AI agents to intelligently suggest the optimal download location based on project context, without being constrained by their own environment limitations.
Unlike other solutions that require multiple tool calls for searching, filtering, downloading, and attributing images, our server:
stock_photo
toolThis design significantly reduces the number of API calls and tool invocations, leading to faster results and lower operational costs.
Using images from Unsplash requires adherence to their Terms of Service. Our server handles this automatically:
By using our Unsplash Smart MCP Server, you are automatically compliant with Unsplash's requirements without any additional effort.
The server includes a comprehensive attribution management system:
// Retrieve attribution data for your project const attributions = await fetch('http://localhost:3000/api/unsplash', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ method: 'get_attributions', params: { format: 'json', // Options: json, html, react projectPath: '/path/to/your/project' } }) }).then(res => res.json()); // attributions contains complete data about every image used
The API can generate three types of attribution files:
Our Unsplash Smart MCP Server seamlessly integrates into your development workflow:
Images are automatically organized based on your project type:
Framework | Default Image Path | Alternate Paths |
---|---|---|
Next.js | /public/images/ | /public/assets/images/ |
React | /src/assets/images/ | /assets/images/ |
Vue | /src/assets/images/ | /public/images/ |
Angular | /src/assets/images/ | /assets/images/ |
Generic | /assets/images/ | ~/Downloads/stock-photos/ |
Feature | Unsplash Smart MCP Server | Alternatives |
---|---|---|
AI Agent Integration | ✅ Purpose-built for AI agent workflow | ❌ Typically requires manual parameter setting |
Context Awareness | ✅ Interprets vague requests intelligently | ❌ Relies on exact keyword matching |
Tool Efficiency | ✅ Single tool handles entire workflow | ❌ Often requires multiple separate tools |
Attribution Management | ✅ Comprehensive system with multiple formats | ❌ Manual tracking or basic text output |
Project Organization | ✅ Framework-aware folder structures | ❌ Generic downloads to a single location |
Installation Complexity | ✅ Simple one-line command | ❌ Often requires multiple configuration steps |
Response Format | ✅ AI-optimized with relevant context | ❌ Generic JSON requiring further processing |
Download Flexibility | ✅ URL-first with intelligent suggestions | ❌ Either direct downloads or just URLs |
Variable | Description | Default |
---|---|---|
UNSPLASH_ACCESS_KEY | Your Unsplash API access key | - |
PORT | Port for the server to listen on | 3000 |
HOST | Host for the server | localhost |
ATTRIBUTION_DB_PATH | Path to store attribution database | ~/.unsplash-mcp |
Parameter | Type | Description | Default |
---|---|---|---|
query | string | What to search for (AI will choose if not specified) | - |
purpose | string | Where the image will be used (e.g., hero, background) | - |
count | number | Number of images to return | 1 |
orientation | string | Preferred orientation (any, landscape, portrait, square) | any |
width | number | Target width in pixels | - |
height | number | Target height in pixels | - |
minWidth | number | Minimum width for filtering results | - |
minHeight | number | Minimum height for filtering results | - |
outputDir | string | Directory to save photos | ~/Downloads/stock-photos |
projectType | string | Project type for folder structure (next, react, vue, angular) | - |
category | string | Category for organizing images (e.g., heroes, backgrounds) | - |
downloadMode | string | Whether to download images or return URLs | urls_only |
Parameter | Type | Description | Default |
---|---|---|---|
format | string | Output format (json, html, react) | json |
projectPath | string | Filter attributions to a specific project path | - |
outputPath | string | Where to save attribution files | - |
Issue | Solution |
---|---|
Connection Refused | Ensure the server is running on the configured port |
Authentication Error | Verify your Unsplash API key is correctly set |
No Images Found | Try broader search terms or check your search query |
Download Permission Issues | Use downloadMode: 'urls_only' and manual download commands |
Docker Container Exits Prematurely | Ensure you're using CMD ["npm", "start"] in your Dockerfile instead of directly running the TypeScript file with tsx. This ensures the server stays running in a Docker environment. |
Timeout Errors | The default MCP timeout is 60 seconds, which may be insufficient for downloading larger images or processing multiple images. For image-heavy operations: 1) Process fewer images per request, 2) Use smaller image dimensions, 3) Consider using urls_only mode instead of auto-download, 4) Check network connectivity |
Attribution Not Found | Verify the image was downloaded through the MCP server |
Unhandled MCP Errors | If you see "McpError: MCP error -32001: Request timed out" errors, your request is likely taking too long. Break it into smaller operations or use the URLs-only approach |
Contributions are welcome! Please feel free to submit a Pull Request.
npm install
.env
file with your Unsplash API keynpm run dev
npm test
Here's what we're planning for future releases:
MIT License
When using images from Unsplash, you must comply with the Unsplash License:
Our server's attribution system makes it easy to provide proper credit to photographers.
For issues or questions, please open an issue on GitHub.
# Clone the repository git clone https://github.com/drumnation/unsplash-smart-mcp-server.git cd unsplash-smart-mcp-server # Install dependencies npm install # Set up your environment variables cp .env.example .env # Edit .env to add your UNSPLASH_ACCESS_KEY # Start the development server npm run dev
The package includes a comprehensive test suite:
# Run core tests npm test # Run all tests and get a summary report npm run test:all
The test suite includes:
For detailed information about testing, see docs/testing.md.
Empower your AI agents with the perfect images, every time.
Built with ❤️ for developers and AI enthusiasts.