A Model Context Protocol (MCP) server for searching images using the Unsplash API.
- .NET 8.0 SDK or later
- An Unsplash API access key (Get one here)
This project requires an Unsplash API client ID to function. The API key should never be committed to source control. You can configure it using one of the following methods:
This is the most secure method for local development:
dotnet user-secrets set "ImageApi:ClientId" "your-unsplash-api-key"Set the environment variable using the double-underscore notation:
Windows (PowerShell):
$env:ImageApi__ClientId="your-unsplash-api-key"Windows (Command Prompt):
set ImageApi__ClientId=your-unsplash-api-keyLinux/macOS:
export ImageApi__ClientId="your-unsplash-api-key"Create a file named appsettings.Development.json (this file is already in .gitignore):
{
"ImageApi": {
"ClientId": "your-unsplash-api-key"
}
}Edit Properties/launchSettings.json (this file is already in .gitignore) and replace the placeholder:
{
"profiles": {
"image-mcp": {
"commandName": "Project",
"environmentVariables": {
"ImageApi__ClientId": "your-unsplash-api-key"
}
}
}
}The application expects the following configuration:
{
"ImageApi": {
"BaseUrl": "https://api.unsplash.com/",
"ClientId": "your-api-key"
}
}- BaseUrl: The Unsplash API base URL (already configured in
appsettings.json) - ClientId: Your Unsplash API access key (must be configured using one of the methods above)
- Clone the repository
- Configure your Unsplash API key using one of the methods above
- Build the project:
dotnet build
- Run the server:
dotnet run
The application validates that all required configuration values are present at startup. If the ClientId is missing or invalid, the application will fail to start with a clear error message.
The following files contain sensitive information and are excluded from version control via .gitignore:
appsettings.Development.jsonappsettings.*.json(exceptappsettings.example.json)Properties/launchSettings.json
- Go to https://unsplash.com/developers
- Create a new application
- Copy your "Access Key" and use it as your
ClientIdin the configuration
- GetImage: Search for images based on a query string and returns image URLs with photographer attribution.