Integrations
Unsplash API - FastAPI + FastMCP
@aliosmankaya によって unsplash-apiからフォークされました
目次
概要
このプロジェクトは、UnsplashサービスにアクセスするためのAPIを提供し、画像の検索、一覧表示、ランダムな画像取得を可能にします。さらに、モデルコンテキストプロトコル(MCP)を統合しているため、ClaudeのようなAIモデルがUnsplash APIと直接やり取りできるようになります。
前提条件
Unsplash API を使用する前に、次のことを行う必要があります。
- Unsplashで開発者として登録する
- アクセスキーを取得する
.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.txt
- Unsplash APIキーを使用して
.env
ファイルを作成します - 開発モードでサーバーを実行します:
python main.py
ライセンス
このプロジェクトは MIT ライセンスに基づいてライセンスされています - 詳細については LICENSE ファイルを参照してください。
This server cannot be installed
remote-capable server
The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.
Unsplash の画像検索、リスト、ランダム写真機能を MCP ツールとして公開する API により、Claude などの AI モデルが Unsplash のサービスと直接やり取りできるようになります。
Related MCP Servers
- AsecurityAlicenseAqualityEnables AI assistants to download images from URLs and perform basic image optimization tasks.Last updated -24JavaScriptApache 2.0
- AsecurityAlicenseAqualityEnables the generation of images using Together AI's models through an MCP server, supporting customizable parameters such as model selection, image dimensions, and output directory.Last updated -14JavaScriptMIT License
- -securityAlicense-qualityA FastMCP server implementation that provides a standardized interface for accessing AI models hosted on Replicate's API, currently supporting image generation with customizable parameters.Last updated -2PythonMIT License
- 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 -1112PythonMIT License