mcp-ps-store
mcp-ps-store
MCP 服务器,用于暴露 PlayStation Network 账户自身的游戏历史——游戏时长、奖杯进度、购买的库——以便 AI 助手能够基于真实数据而非猜测推荐游戏。
俄语版本:README.ru.md。
关于
PSN 没有公开的 API。该服务器与 PlayStation 手机应用使用的内部 API 通信,使用从浏览器会话获取的 NPSSO cookie 进行身份验证。每次请求都是只读操作;不会向账户写入任何内容。
结构采用分层架构:API 层(MCP 工具)、核心层(服务、存储库、DTO)、依赖注入容器和基础设施层。
核心技术
语言: 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% 完成的游戏、玩了一小时就放弃的游戏、以及从未启动过的购买内容。推荐相关问题可由此入手。 |
| 可筛选的游戏列表:按标题搜索、按游戏时长/上次游玩/奖杯进度排序、按平台、游戏时长、日期和进度筛选。 |
| 一款游戏的所有奖杯:是否获得、获得日期、稀有度、拥有该奖杯的玩家比例。 |
| 已购买或通过 PS Plus 领取的游戏,含已知的游戏时长——避免推荐已拥有的游戏。 |
| 最近游玩过的游戏。 |
| 在线 ID、PS Plus 状态、奖杯等级、生涯总奖杯数。 |
| 清除响应缓存(PSN 响应会被缓存 10 分钟)。 |
另外还有一个 recommend_games 提示词——一个现成的"构建我的个人资料并推荐游戏"场景,可接受"短时游戏"或"双人合作"等可选引导。
快速开始
需要 Python 3.11+。
1. 安装
使用 Poetry:
poetry install或使用普通虚拟环境:
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令牌会以 0600 权限保存到 ~/.mcp-ps-store/tokens.json。
关于会话有效期。 访问令牌有效期为 1 小时,刷新令牌仅 10 天,但 NPSSO 本身有效期约 2 个月。因此 NPSSO 会与令牌一同存储,当刷新令牌过期时服务器会自动重新验证。实际上一次 psn-login 大约可使用 60 天。
3. 验证是否正常
poetry run psn-doctor它会输出账户名称、可见游戏数量以及按游戏时长排序的前五款游戏。
连接客户端
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 通过 stdio 与本地 MCP 服务器通信,因此使用方法相同。可以运行 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然后通过 HTTPS 暴露 http://127.0.0.1:8000/mcp —— 使用 OpenAI 的 Secure MCP Tunnel,或 cloudflared / ngrok 等隧道工具 —— 并将生成的 URL 添加为自定义连接器。
这会将你的 PSN 历史暴露给所有找到该 URL 的人。 服务器本身没有身份验证,因此请为隧道设置认证,仅在需要时保持运行,如果本地客户端可用,请优先使用 Codex CLI。
配置
所有设置均从环境变量或 .env 文件中读取(参见 .env.example)。
变量 | 默认值 | 含义 |
| — | NPSSO cookie。 |
|
| 令牌缓存路径。 |
|
| PSN 响应复用时长,单位秒。 |
|
| store.playstation.com 链接中使用的区域设置。 |
|
| PSN 请求的 HTTP 超时时间,单位秒。 |
|
|
|
|
| HTTP 传输的绑定地址。 |
|
| HTTP 传输的端口。 |
局限性
游戏时长仅存在于 PS4 / PS5 / PC 版本。 PSN 对 PS3 和 Vita 游戏仅报告奖杯信息,因此这些游戏会显示
hours: null。此处不包含 PS Store 目录。 商店完全在客户端侧,其 GraphQL API 仅接受每次部署时索尼都会更换哈希值的持久化查询——保持其正常工作不切实际。推荐候选游戏来自模型自身的游戏知识,而
psn_owned_games可防止推荐已购买的内容。已购买的库 通过 PSN 的私有 GraphQL API 获取。如果索尼更改查询方式,该工具将停止工作;其他所有功能仍正常运行,摘要中会添加
backlog_unavailable注释。游戏时长和奖杯通过标题关联,因此当重制版与原版共享奖杯集时,两者可能合并。版本、平台后缀和罗马数字会被有意标准化——
Alan Wake II和Alan Wake 2被视为同一款游戏。该 API 是非官方的:索尼随时可能更改。
项目结构
.
├── 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.-