Unsplash API - FastAPI + FastMCP
@aliosmankaya によって unsplash-apiからフォークされました
目次
概要
このプロジェクトは、UnsplashサービスにアクセスするためのAPIを提供し、画像の検索、一覧表示、ランダムな画像取得を可能にします。さらに、モデルコンテキストプロトコル(MCP)を統合しているため、ClaudeのようなAIモデルがUnsplash APIと直接やり取りできるようになります。
前提条件
Unsplash API を使用する前に、次のことを行う必要があります。
アクセスキーを取得する
.envファイルでキーをUNSPLASH_CLIENT_IDとして設定します。
インストール
pipの使用
Dockerの使用
構成
プロジェクト ルートに次の内容の.envファイルを作成します。
ランニング
地元で
API はhttp://localhost:8000で利用できます。
Dockerを使用
API はhttp://localhost:8000で利用できます。
インタラクティブな API ドキュメントにhttp://localhost:8000/docsでアクセスします。
APIエンドポイント
検索
Unsplash で画像を検索するためのエンドポイント。
エンドポイント: /search
メソッド: GET
パラメータ:
query: 検索語(デフォルト: "nature")page: ページ番号(デフォルト: 1)per_page: 1ページあたりの写真数(デフォルト: 10)order_by: 写真の順序(デフォルト: "relevant"、オプション: "relevant"、"latest")
リクエスト例:
応答例:
写真
Unsplash ランディング ページから写真を一覧表示するエンドポイント。
エンドポイント: /photos
メソッド: GET
パラメータ:
page: ページ番号(デフォルト: 1)per_page: 1ページあたりの写真数(デフォルト: 10)order_by: 写真の順序 (デフォルト: "latest"、オプション: "latest"、"oldest"、"popular")
リクエスト例:
応答例:
ランダム
Unsplash からランダムな写真を取得するためのエンドポイント。
エンドポイント: /random
メソッド: GET
パラメータ:
query: ランダムに写真をフィルタリングするための検索語 (デフォルト: "nature")count: 返される写真の数(デフォルト: 1、最大: 30)
リクエスト例:
応答例:
Unsplash API の詳細については、公式ドキュメントを参照してください。
MCP統合
MCPの概要
モデルコンテキストプロトコル(MCP)は、AIモデルがAPIやサービスと直接やり取りできるようにするプロトコルです。この実装では、FastAPI-MCPを使用して、Unsplash APIエンドポイントをMCPツールとして公開します。
MCPエンドポイント
MCP サーバーは/mcpで利用でき、すべての API エンドポイントを MCP ツールとして公開します。
検索: Unsplashで画像を検索
写真: ランディングページから写真を一覧表示します
ランダム:ランダムな写真を取得する
AIモデルの使用
MCP をサポートする AI モデルは、以下を使用してこの API に接続できます。
Claude の場合、モデル設定または API 経由で接続を構成できます。
クライアントの例
シンプルな Python クライアントを使用して MCP サーバーをテストできます。
MCP の使用に関する詳細については、 MCP_USAGE.mdファイルを参照してください。
発達
開発に貢献するには:
リポジトリをクローンする
開発依存関係をインストールします:
pip install -r requirements.txtUnsplash APIキーを使用して
.envファイルを作成します開発モードでサーバーを実行します:
python main.py
ライセンス
このプロジェクトは MIT ライセンスに基づいてライセンスされています - 詳細については LICENSE ファイルを参照してください。
This server cannot be installed
Related Resources
Related MCP Servers
- AsecurityAlicenseAqualityA lightweight server that enables seamless integration with Unsplash's image library, allowing developers to search for high-quality photos with various filters directly from the Cursor editor.Last updated -1187MIT License
- -securityAlicense-qualityAn MCP server that allows Claude and other AI assistants to interact with the YouTube API, providing tools to search videos/channels and retrieve detailed information about them.Last updated -51MIT License
- -securityAlicense-qualityA search service based on multiple image APIs and icon generation capabilities, specifically designed for integration with Cursor MCP service. Supports image search, download, and AI-generated icons.Last updated -13MIT License
- -securityFlicense-qualityAn MCP server that crawls API documentation websites and exposes their content to AI models, enabling them to search, browse, and reference API specifications.Last updated -