Skip to main content
Glama

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: PersonalizationMCP

公开的工具

工具

用途

psn_taste_profile

主要工具:一份摘要——按小时数排列的热门游戏、最爱的系列、游戏风格习惯(平均游戏时长、深度游戏占比、白金率)、接近 100% 完成的游戏、玩了一小时就放弃的游戏、以及从未启动过的购买内容。推荐相关问题可由此入手。

psn_library

可筛选的游戏列表:按标题搜索、按游戏时长/上次游玩/奖杯进度排序、按平台、游戏时长、日期和进度筛选。

psn_game_trophies

一款游戏的所有奖杯:是否获得、获得日期、稀有度、拥有该奖杯的玩家比例。

psn_owned_games

已购买或通过 PS Plus 领取的游戏,含已知的游戏时长——避免推荐已拥有的游戏。

psn_recently_played

最近游玩过的游戏。

psn_profile

在线 ID、PS Plus 状态、奖杯等级、生涯总奖杯数。

psn_refresh

清除响应缓存(PSN 响应会被缓存 10 分钟)。

另外还有一个 recommend_games 提示词——一个现成的"构建我的个人资料并推荐游戏"场景,可接受"短时游戏"或"双人合作"等可选引导。

快速开始

需要 Python 3.11+。

1. 安装

使用 Poetry:

poetry install

或使用普通虚拟环境:

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

令牌会以 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.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 通过 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)。

变量

默认值

含义

PSN_NPSSO

NPSSO cookie。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

stdiostreamable-httpsse

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 仅接受每次部署时索尼都会更换哈希值的持久化查询——保持其正常工作不切实际。推荐候选游戏来自模型自身的游戏知识,而 psn_owned_games 可防止推荐已购买的内容。

  • 已购买的库 通过 PSN 的私有 GraphQL API 获取。如果索尼更改查询方式,该工具将停止工作;其他所有功能仍正常运行,摘要中会添加 backlog_unavailable 注释。

  • 游戏时长和奖杯通过标题关联,因此当重制版与原版共享奖杯集时,两者可能合并。版本、平台后缀和罗马数字会被有意标准化——Alan Wake IIAlan 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 account
F
license - not found
-
quality - not tested
C
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

View all related MCP servers

Related MCP Connectors

  • Connect AI assistants to your GitHub-hosted Obsidian vault to seamlessly access, search, and analy…

  • Connect your Player's Bank account to AI via Brazil's Open Finance: balances, statements, cards, inv

  • Connect AI assistants to GitHub - manage repos, issues, PRs, and workflows through natural language.

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/murzin-ml/mcp-ps-store'

If you have feedback or need assistance with the MCP directory API, please join our Discord server