mcp-ps-store
mcp-ps-store
PlayStation Networkアカウント自身のゲーム履歴(プレイ時間、トロフィー進捗、購入ライブラリ)を公開するMCPサーバー。AIアシスタントが推測ではなく実際のデータに基づいてゲームを推薦できるようにします。
Русская версия: README.ru.md。
概要
PSNには公開APIはありません。このサーバーはPlayStationモバイルアプリが使用しているのと同じ内部APIと通信し、ブラウザセッションから取得したNPSSOクッキーで認証します。すべてのリクエストは読み取り専用であり、アカウントに何かを書き込むことはありません。
レイアウトは階層型アーキテクチャに従っています:APIレイヤー(MCPツール)、コアレイヤー(サービス、リポジトリ、DTO)、DIコンテナ、インフラストラクチャレイヤー。
コア技術
言語: Python 3.11+
プロトコル: Model Context Protocol (
mcp)HTTPクライアント: httpx (非同期)
DIコンテナ:
dependency-injector設定:
pydantic-settings依存関係管理: Poetry
テスト: Pytest,
pytest-asyncio
Related MCP server: WG-Console-MCP-server
公開するツール
ツール | 目的 |
| メインのツール:時間順のトップゲーム、お気に入りのフランチャイズ、プレイスタイルの習慣(平均セッション時間、深掘り率、プラチナ率)、100%に近いゲーム、1時間で放棄したゲーム、一度も起動していない購入品をまとめたダイジェスト。推薦に関する質問はここから始めてください。 |
| フィルタ可能なゲームリスト:タイトル検索、時間/最終プレイ日/トロフィー進捗で並べ替え、プラットフォーム、時間、日付、進捗でフィルタリング。 |
| 1つのゲームのすべてのトロフィー:獲得済みかどうか、日付、レア度、所持プレイヤーの割合。 |
| すでに購入済みまたはPS Plusで入手済みのゲーム(時間がわかっているものも含む)。すでに所有しているゲームが推薦されないようにします。 |
| 最近起動したゲーム。 |
| オンラインID、PS Plus、トロフィーレベル、生涯トロフィー数。 |
| レスポンスキャッシュを削除します(PSNの応答は10分間キャッシュされます)。 |
さらに、recommend_games プロンプトも用意されています。「短めのゲーム」や「2人用協力プレイ」などのオプションの指示を受け付ける、「プロフィールを作成してゲームを推薦する」シナリオがすぐに使えます。
クイックスタート
Python 3.11+ が必要です。
1. インストール
Poetryを使用する場合:
poetry installまたは、通常のvirtualenvを使用する場合:
python3.11 -m venv .venv && .venv/bin/pip install -e .2. PSNにサインイン
ブラウザで https://www.playstation.com にサインインします。
https://ca.account.sony.com/api/v1/ssocookie を開きます。
{"npsso":"..."}が返されます。64文字の
npsso値をコピーして、以下を実行します:
poetry run psn-login PASTE_NPSSO_HEREトークンは ~/.mcp-ps-store/tokens.json に 0600 パーミッションで保存されます。
セッションの有効期間について。 アクセストークンは1時間、リフレッシュトークンは10日間しか有効ではありませんが、NPSSO自体は約2ヶ月有効です。そのため、NPSSOはトークンと一緒に保存され、リフレッシュトークンが期限切れになるとサーバーが自動的に再認証します。実際には、1回の psn-login で約60日間有効です。
3. 動作確認
poetry run psn-doctorアカウント名、表示可能なゲーム数、プレイ時間トップ5が表示されます。
クライアントの接続
Claude Code
claude mcp add ps-store -- /path/to/mcp-ps-store/.venv/bin/python -m app.mainClaude Desktop
claude_desktop_config.json に以下を追加:
{
"mcpServers": {
"ps-store": {
"command": "/path/to/mcp-ps-store/.venv/bin/python",
"args": ["-m", "app.main"],
"cwd": "/path/to/mcp-ps-store"
}
}
}Codex CLI
CodexはローカルのMCPサーバーとstdioで通信するため、同じように動作します。codex mcp add を実行するか、~/.codex/config.toml に以下を追加します:
[mcp_servers.ps-store]
command = "/path/to/mcp-ps-store/.venv/bin/python"
args = ["-m", "app.main"]
cwd = "/path/to/mcp-ps-store"Codexセッション内で /mcp で確認できます。
ChatGPT
ChatGPTはローカルプロセスを起動できません。カスタムコネクタはデベロッパーモード(設定 → アプリ → 詳細設定)で追加し、SSEまたはStreamable HTTPを話す公開HTTPSエンドポイントである必要があります。そのため、サーバーをHTTPトランスポートに切り替えて公開する必要があります:
PSN_MCP_TRANSPORT=streamable-http PSN_MCP_PORT=8000 poetry run mcp-ps-store次に、http://127.0.0.1:8000/mcp をHTTPS経由で公開します(OpenAIのSecure MCP Tunnel、または cloudflared / ngrok などのトンネルを使用)。そして、結果のURLをカスタムコネクタとして追加します。
これにより、URLを知っている誰にでもPSN履歴が公開されます。 サーバー自体には認証機能がないため、トンネルを認証の背後に置き、必要な間だけ実行し、ローカルクライアントで十分な場合はCodex CLIを優先してください。
設定
すべての設定は環境変数または .env ファイル(.env.example を参照)から読み取られます。
変数 | デフォルト | 意味 |
| — | NPSSOクッキー。 |
|
| トークンがキャッシュされる場所。 |
|
| PSNの応答が再利用される時間(秒)。 |
|
| store.playstation.com のリンクで使用されるロケール。 |
|
| PSNリクエストのHTTPタイムアウト(秒)。 |
|
|
|
|
| HTTPトランスポートのバインドアドレス。 |
|
| HTTPトランスポートのポート。 |
制限事項
プレイ時間はPS4 / PS5 / PC版のみ存在します。 PSNはPS3とVitaのゲームをトロフィーのみで報告するため、これらのゲームは
hours: nullとして表示されます。ここにはPS Storeのカタログはありません。 ストアは完全にクライアントサイドであり、そのGraphQL APIは、Sonyがデプロイのたびにハッシュを変更する永続クエリのみを受け付けます。これを維持することは現実的ではありません。推薦候補はモデル自身のゲーム知識から得られ、
psn_owned_gamesはすでに購入済みのゲームを提案しないようにします。購入ライブラリはPSNのプライベートGraphQL APIを経由します。Sonyがクエリを変更した場合、そのツールだけが動作しなくなります。他のすべては動作し続け、ダイジェストには
backlog_unavailableという注記が追加されます。プレイ時間とトロフィーはタイトルで結合されるため、トロフィーセットを共有するリマスター版はオリジナルと統合される可能性があります。エディション、プラットフォームの接尾辞、ローマ数字は意図的に正規化されます。
Alan Wake IIとAlan Wake 2は同じゲームとして扱われます。このAPIは非公式です。Sonyはいつでも変更する可能性があります。
プロジェクト構造
.
├── app/
│ ├── api/ # MCP layer: tools, prompts, serialisers, tool errors
│ │ ├── games/
│ │ ├── profile/
│ │ └── taste/
│ ├── core/ # Business logic: services, repositories, DTOs
│ │ ├── auth/ # NPSSO -> tokens, refresh, re-login
│ │ ├── games/ # Library, playtime/trophy merge, name normalisation
│ │ ├── profile/ # Account profile and trophy summary
│ │ └── taste/ # Taste digest aggregation
│ ├── di/ # DI containers and providers
│ ├── infra/adapters/ # HTTP client, token storage, TTL cache
│ ├── cli.py # psn-login, psn-doctor
│ └── main.py # MCP server entry point
├── settings/ # pydantic-settings configuration
├── tests/
│ ├── core/ # Merge and aggregation tests
│ └── factories/ # Builders for test data
└── pyproject.toml開発
poetry run pytest # unit tests; no network and no account needed
poetry run psn-doctor # live check against the signed-in accountAvailable Tools
7 toolspsn_game_trophiesTrophy detail for one gameARead-only
Full trophy list for a single game with earned status, earn dates and rarity. Pass a title (fuzzy match against the account's games) or an exact np_communication_id. Useful for 'what's left to platinum' and for judging how deeply the user engaged with a game.
Inputs: game, limit, status, include_hidden, +2 more. Returns: object
psn_libraryPSN game libraryARead-only
Filtered, sorted list of games on the account, joining playtime with trophy progress. Use it to answer questions like 'what did I play most in 2024', 'what have I nearly finished', 'what did I drop quickly'. Store page: https://store.playstation.com//concept/<concept_id>.
Inputs: sort, limit, offset, search, +9 more. Returns: object
psn_owned_gamesPurchased PSN libraryARead-only
Games the account has bought or claimed (including PS Plus monthly claims), with hours played where known. Check this before recommending anything so you do not suggest a game the user already owns, and to surface unplayed purchases.
Inputs: limit, offset, search, platform, +1 more. Returns: object
psn_profilePSN account profileBRead-only
Online ID, PS Plus status, trophy level and lifetime trophy counts.
Inputs: no named parameters. Returns: object
psn_recently_playedRecently playedBRead-only
The account's most recently launched games, newest first.
Inputs: limit. Returns: object
psn_refreshRefresh PSN cacheAIdempotent
Drops the cached PSN responses so the next call re-reads live data. Use after the user has just played something.
Inputs: no named parameters. Returns: object
psn_taste_profilePSN taste profileARead-only
One-shot digest of the account's gaming taste: totals, playtime habits, top games by hours, favourite franchises, platinums, games close to completion, games bounced off after a short try, and unplayed purchases. Start here for any recommendation request.
Inputs: top, include_backlog. Returns: object
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 7 tools
Most tools are distinct, but psn_taste_profile, psn_library, and psn_owned_games overlap in what they surface: playtime habits, nearly-finished games, dropped games, and unplayed purchases are all claimed by more than one tool. The descriptions somewhat clarify their intents (digest vs. queryable list vs. ownership check), but an agent could easily pick the wrong one for a given user question.
All tools share a consistent psn_ prefix and snake_case convention, which makes them recognizable as a family. The primary deviation is that psn_refresh is verb-first while the rest are noun phrases (psn_library, psn_profile, psn_owned_games), but the overall pattern is still predictable.
Seven tools is a well-scoped set for a PSN account insights server. Each tool covers a meaningful slice of the domain—profile, library, owned games, recent activity, trophies, taste digest, and cache refresh—without feeling padded or redundant at the count level.
The core domain of account-level PSN data is well covered: profile, catalog, ownership, recency, trophies, and an aggregate taste digest are all present. Minor gaps exist, such as no direct store/game-details lookup or cross-game trophy comparison, but the set supports the stated recommendation and account-insight workflows without major dead ends.
Maintenance
Related MCP Connectors
Give any AI assistant real-time access to your phone's GPS and location history.
Personal context and preferences for AI via OAuth-approved profile sections and taste data.
Persistent memory and shared context across compatible AI assistants, with account-scoped OAuth.
Savecraft serves real save game data and expert game knowledge to AI assistants.
Related MCP Servers
- AlicenseCqualityDmaintenanceEnables AI assistants to access and interact with personal data from platforms like Steam, YouTube, Bilibili, Spotify, and Reddit for personalized, context-aware interactions.8864MIT
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to access live Wargaming API data for World of Tanks Console, allowing queries about players, clans, vehicles, and tank comparisons.10 npmISC
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to access Garmin Connect fitness and health data, including activities, heart rate, sleep, and device information.MIT
- FlicenseNot gradedqualityDmaintenanceEnables AI assistants to access Sapphire Wellness user data, including health alerts, personalized recommendations, and partner service subscriptions.-