Skip to main content
Glama

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

公開するツール

ツール

目的

psn_taste_profile

メインのツール:時間順のトップゲーム、お気に入りのフランチャイズ、プレイスタイルの習慣(平均セッション時間、深掘り率、プラチナ率)、100%に近いゲーム、1時間で放棄したゲーム、一度も起動していない購入品をまとめたダイジェスト。推薦に関する質問はここから始めてください。

psn_library

フィルタ可能なゲームリスト:タイトル検索、時間/最終プレイ日/トロフィー進捗で並べ替え、プラットフォーム、時間、日付、進捗でフィルタリング。

psn_game_trophies

1つのゲームのすべてのトロフィー:獲得済みかどうか、日付、レア度、所持プレイヤーの割合。

psn_owned_games

すでに購入済みまたはPS Plusで入手済みのゲーム(時間がわかっているものも含む)。すでに所有しているゲームが推薦されないようにします。

psn_recently_played

最近起動したゲーム。

psn_profile

オンラインID、PS Plus、トロフィーレベル、生涯トロフィー数。

psn_refresh

レスポンスキャッシュを削除します(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にサインイン

  1. ブラウザで https://www.playstation.com にサインインします。

  2. https://ca.account.sony.com/api/v1/ssocookie を開きます。{"npsso":"..."} が返されます。

  3. 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.main

Claude 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 を参照)から読み取られます。

変数

デフォルト

意味

PSN_NPSSO

—

NPSSOクッキー。psn-login の代替:設定すると、サーバーが自動的にサインインします。

PSN_TOKENS_PATH

~/.mcp-ps-store/tokens.json

トークンがキャッシュされる場所。

PSN_CACHE_TTL

600

PSNの応答が再利用される時間(秒)。

PSN_STORE_LOCALE

en-us

store.playstation.com のリンクで使用されるロケール。

PSN_REQUEST_TIMEOUT

30

PSNリクエストのHTTPタイムアウト(秒)。

PSN_MCP_TRANSPORT

stdio

stdio、streamable-http、または sse。

PSN_MCP_HOST

127.0.0.1

HTTPトランスポートのバインドアドレス。

PSN_MCP_PORT

8000

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 account

Available Tools

7 tools
psn_game_trophiesTrophy detail for one gameA
Read-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 libraryA
Read-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 libraryA
Read-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 profileB
Read-only

Online ID, PS Plus status, trophy level and lifetime trophy counts.

Inputs: no named parameters. Returns: object

psn_recently_playedRecently playedB
Read-only

The account's most recently launched games, newest first.

Inputs: limit. Returns: object

psn_refreshRefresh PSN cacheA
Idempotent

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 profileA
Read-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

    A3.7/5.0

    Scored across 7 tools

    Disambiguation3/5

    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.

    Naming Consistency4/5

    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.

    Tool Count5/5

    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.

    Completeness4/5

    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

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers