xbox-mcp 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,196 @@
1
+ Metadata-Version: 2.3
2
+ Name: xbox-mcp
3
+ Version: 0.1.0
4
+ Summary: Local MCP Server for official Microsoft Xbox Live APIs (playtime, Game Pass library, achievements, rarity, presence, friends)
5
+ Keywords: mcp,xbox,xbox-live,game-pass,gaming,model-context-protocol
6
+ Author: VinsentY
7
+ License: MIT
8
+ Requires-Dist: mcp[cli]>=2.3.0
9
+ Requires-Dist: xbox-webapi>=2.1.0
10
+ Requires-Python: >=3.12
11
+ Project-URL: Homepage, https://github.com/VinsentY/xbox-mcp
12
+ Project-URL: Repository, https://github.com/VinsentY/xbox-mcp
13
+ Project-URL: Issues, https://github.com/VinsentY/xbox-mcp/issues
14
+ Description-Content-Type: text/markdown
15
+
16
+ <!-- mcp-name: io.github.VinsentY/xbox-mcp -->
17
+
18
+ # xbox-mcp
19
+
20
+ [English](README.md) | [简体中文](README.zh-CN.md)
21
+
22
+ [![Python 3.12+](https://img.shields.io/badge/python-3.12+-blue.svg)](https://www.python.org/downloads/)
23
+ [![MCP](https://img.shields.io/badge/MCP-Model%20Context%20Protocol-green.svg)](https://modelcontextprotocol.io/)
24
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
25
+
26
+ A lightweight, local **Model Context Protocol (MCP)** server that connects directly to **official Microsoft Xbox Live APIs** — no third-party proxy API keys (like OpenXBL), no rate-limit paywalls, and all OAuth tokens stay strictly on your local machine.
27
+
28
+ Query your **Xbox console & PC Game Pass** game library, exact `MinutesPlayed` playtime, achievements & global rarity percentages, live online presence, friends list, and full playtime summaries right from your AI assistant.
29
+
30
+ ---
31
+
32
+ ## Highlights
33
+
34
+ - **Direct Official API Access**: Built on [`xbox-webapi`](https://github.com/OpenXbox/xbox-webapi-python) (`TitleHub`, `UserStats`, `Achievements`, `Profile`, `Presence`, `PeopleHub`).
35
+ - **Fast Batched Playtime Lookup**: Fetches `MinutesPlayed` in chunks of 50 titles per `userstats/batch` request so even large libraries resolve in ~1–2 seconds.
36
+ - **Xbox vs. Win32 Game Bar Separation**: Automatically distinguishes tracked Xbox / PC Game Pass games from third-party PC games (`Win32`) logged by Windows Xbox Game Bar.
37
+ - **Zero-Hassle Local Auth**: Supports both one-command CLI browser OAuth (`uv run xbox-auth`) and in-chat callback code exchange (`get_auth_status` + `complete_auth`), with automatic token refresh and `0600` file permissions.
38
+ - **Cross-Generation Achievements**: Supports Xbox One / Series X|S / PC achievements (with global unlock rarity percentages) and automatically falls back to Xbox 360 titles.
39
+
40
+ ---
41
+
42
+ ## Requirements
43
+
44
+ - **Python 3.12+**
45
+ - **[uv](https://docs.astral.sh/uv/)** (recommended)
46
+ - A Microsoft / Xbox account
47
+
48
+ ---
49
+
50
+ ## Quick Start
51
+
52
+ ### 1. Run via `uvx` (Recommended — No Clone Needed)
53
+
54
+ ```bash
55
+ # Authenticate once with Microsoft / Xbox Live
56
+ uvx --from xbox-mcp xbox-auth
57
+
58
+ # Run the MCP server
59
+ uvx xbox-mcp
60
+ ```
61
+
62
+ Or clone locally for development:
63
+
64
+ ```bash
65
+ git clone https://github.com/VinsentY/xbox-mcp.git
66
+ cd xbox-mcp
67
+ uv sync
68
+ uv run xbox-auth
69
+ ```
70
+
71
+ ### 2. Authenticate with Microsoft / Xbox Live (One-Time Setup)
72
+
73
+ Choose either method:
74
+
75
+ #### Option A: CLI Auto-Callback (Recommended)
76
+
77
+ ```bash
78
+ uv run xbox-auth
79
+ ```
80
+
81
+ This starts a temporary local listener on `http://localhost:8080/auth/callback`, opens Microsoft's official OAuth2 sign-in page in your browser, exchanges the authorization code for OAuth2 + XBL + XSTS tokens, and saves them locally with `0600` permissions.
82
+
83
+ #### Option B: In-Chat / Manual Callback URL
84
+
85
+ If you prefer not to run a local HTTP listener (or port `8080` is occupied):
86
+
87
+ 1. Ask your AI assistant to call `get_auth_status` — it returns the official Microsoft `login_url`.
88
+ 2. Sign in in your browser. After consent, the browser redirects to `http://localhost:8080/auth/callback?code=...` (an unreachable localhost page is expected).
89
+ 3. Copy the full URL from your browser's address bar and pass it to `complete_auth` (or run `uv run xbox-auth --code "<callback_url>"`).
90
+
91
+ > **Note on Token Storage & Auto-Refresh**
92
+ > Tokens are stored locally at `~/Library/Application Support/xbox/tokens.json` on macOS (or `~/.local/share/xbox/tokens.json` on Linux, overrideable via `XBOX_TOKENS_FILE`) with `0600` permissions. `xbox-mcp` automatically refreshes expired access/XSTS tokens and persists rotated refresh tokens back to disk.
93
+
94
+ ---
95
+
96
+ ## MCP Client Configuration
97
+
98
+ ### Antigravity (`~/.gemini/config/mcp_config.json`) / Claude Desktop / Cursor
99
+
100
+ Using `uvx` (recommended — zero local clone required):
101
+
102
+ ```json
103
+ {
104
+ "mcpServers": {
105
+ "xbox": {
106
+ "command": "uvx",
107
+ "args": ["xbox-mcp"],
108
+ "env": {
109
+ "XBOX_LANGUAGE": "en-US"
110
+ }
111
+ }
112
+ }
113
+ }
114
+ ```
115
+
116
+ Or using a local clone's virtual environment binary:
117
+
118
+ ```json
119
+ {
120
+ "mcpServers": {
121
+ "xbox": {
122
+ "command": "/absolute/path/to/xbox-mcp/.venv/bin/xbox-mcp",
123
+ "args": [],
124
+ "env": {
125
+ "XBOX_LANGUAGE": "en-US"
126
+ }
127
+ }
128
+ }
129
+ }
130
+ ```
131
+
132
+ ### Environment Variables (All Optional)
133
+
134
+ | Variable | Default | Description |
135
+ |---|---|---|
136
+ | `XBOX_TOKENS_FILE` | OS app data `xbox/tokens.json` | Custom path for local OAuth2 token persistence |
137
+ | `XBOX_LANGUAGE` | `en-US` | `Accept-Language` header for titles/achievements (e.g. `zh-CN`, `ja-JP`) |
138
+ | `XBOX_CLIENT_ID` | OpenXbox public client ID | Override with your own Azure App Registration Client ID |
139
+ | `XBOX_CLIENT_SECRET` | *(empty)* | Optional Azure App Client Secret if using a confidential app |
140
+ | `XBOX_REDIRECT_URI` | `http://localhost:8080/auth/callback` | Custom OAuth2 redirect URI matching your app registration |
141
+
142
+ ---
143
+
144
+ ## Available Tools (10)
145
+
146
+ | Tool | Description |
147
+ |---|---|
148
+ | `get_auth_status` | Verify local Xbox OAuth token validity; returns the Microsoft login URL if unauthenticated |
149
+ | `complete_auth` | Exchange an OAuth callback URL (`http://localhost:8080/auth/callback?code=...`) or raw code and save tokens locally |
150
+ | `get_profile` | Fetch Gamertag, Modern Gamertag, Gamerscore, Account Tier, Tenure, Bio, Location, and Avatar |
151
+ | `get_presence` | Check online status and currently playing title/device (Xbox console, PC, Cloud) |
152
+ | `get_game_library` | Fetch full Xbox / PC Game Pass history enriched with exact `MinutesPlayed`, sortable by `playtime`, `recent`, `achievements`, or `name`, with `platform`, `game_pass_only`, `tracked_only`, and `exclude_win32_footprints` filters |
153
+ | `get_recently_played` | Quick view of most recently played titles with playtime and achievement progress |
154
+ | `get_playtime_summary` | Aggregate report: total hours, Xbox console vs. PC breakdown, Game Pass share, playtime buckets, 100% completed games, Win32 footprint count, and Top 20 titles |
155
+ | `get_game_achievements` | Per-title achievement list with unlock timestamps, Gamerscore, and global rarity percentage (`sort_by`: `default`, `rarity`, `gamerscore`, `unlock_time`) |
156
+ | `get_game_stats` | Fetch `MinutesPlayed` and Hero stats for a specific `title_id` or `scid` |
157
+ | `get_friends_list` | List Xbox Live friends with Gamertags, Gamerscore, online status, and currently playing game |
158
+
159
+ ---
160
+
161
+ ## Example Prompts
162
+
163
+ - *"Summarize my Xbox and PC Game Pass playtime and build a gamer profile."*
164
+ - *"Show my top 20 most-played Xbox / Game Pass games, excluding Win32 Game Bar footprints."*
165
+ - *"What are my rarest unlocked achievements in Clair Obscur: Expedition 33?"*
166
+ - *"Compare my Steam library with my Xbox / Game Pass library and find games I've played on both."*
167
+ - *"Which of my Xbox friends are online right now and what are they playing?"*
168
+
169
+ ---
170
+
171
+ ## Troubleshooting
172
+
173
+ - **Passkey interstitial (`account.live.com/interrupt/passkey`) during login**: Click *Skip for now / Cancel* on the Microsoft Passkey prompt, then approve the Xbox Live consent screen until the browser redirects to `http://localhost:8080/auth/callback?code=...`.
174
+ - **`account.live.com` connection closed (`ERR_CONNECTION_CLOSED`)**: In regions with unstable routing to Microsoft Live endpoints, make sure `login.live.com`, `account.live.com`, and `*.xboxlive.com` route consistently through your network/proxy.
175
+ - **Win32 games showing `0m` / `null` playtime**: Windows Xbox Game Bar automatically records non-Xbox PC games (e.g., Steam, Riot, Battle.net titles) in TitleHub without `MinutesPlayed` telemetry. Pass `exclude_win32_footprints=true` or `tracked_only=true` to `get_game_library` to focus purely on Xbox / Game Pass titles.
176
+
177
+ ---
178
+
179
+ ## Development & Tests
180
+
181
+ ```bash
182
+ uv sync
183
+ uv run python -m unittest discover -s tests -v
184
+ ```
185
+
186
+ ---
187
+
188
+ ## Security & Privacy
189
+
190
+ - OAuth2 tokens are stored **only on your local machine** with `0600` file permissions and are never sent to any third-party service.
191
+ - `.gitignore` excludes `tokens.json`, `*tokens*.json`, and `.env*` by default.
192
+ - Never commit your local `tokens.json` file to version control.
193
+
194
+ ## License
195
+
196
+ [MIT](LICENSE)
@@ -0,0 +1,181 @@
1
+ <!-- mcp-name: io.github.VinsentY/xbox-mcp -->
2
+
3
+ # xbox-mcp
4
+
5
+ [English](README.md) | [简体中文](README.zh-CN.md)
6
+
7
+ [![Python 3.12+](https://img.shields.io/badge/python-3.12+-blue.svg)](https://www.python.org/downloads/)
8
+ [![MCP](https://img.shields.io/badge/MCP-Model%20Context%20Protocol-green.svg)](https://modelcontextprotocol.io/)
9
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
10
+
11
+ A lightweight, local **Model Context Protocol (MCP)** server that connects directly to **official Microsoft Xbox Live APIs** — no third-party proxy API keys (like OpenXBL), no rate-limit paywalls, and all OAuth tokens stay strictly on your local machine.
12
+
13
+ Query your **Xbox console & PC Game Pass** game library, exact `MinutesPlayed` playtime, achievements & global rarity percentages, live online presence, friends list, and full playtime summaries right from your AI assistant.
14
+
15
+ ---
16
+
17
+ ## Highlights
18
+
19
+ - **Direct Official API Access**: Built on [`xbox-webapi`](https://github.com/OpenXbox/xbox-webapi-python) (`TitleHub`, `UserStats`, `Achievements`, `Profile`, `Presence`, `PeopleHub`).
20
+ - **Fast Batched Playtime Lookup**: Fetches `MinutesPlayed` in chunks of 50 titles per `userstats/batch` request so even large libraries resolve in ~1–2 seconds.
21
+ - **Xbox vs. Win32 Game Bar Separation**: Automatically distinguishes tracked Xbox / PC Game Pass games from third-party PC games (`Win32`) logged by Windows Xbox Game Bar.
22
+ - **Zero-Hassle Local Auth**: Supports both one-command CLI browser OAuth (`uv run xbox-auth`) and in-chat callback code exchange (`get_auth_status` + `complete_auth`), with automatic token refresh and `0600` file permissions.
23
+ - **Cross-Generation Achievements**: Supports Xbox One / Series X|S / PC achievements (with global unlock rarity percentages) and automatically falls back to Xbox 360 titles.
24
+
25
+ ---
26
+
27
+ ## Requirements
28
+
29
+ - **Python 3.12+**
30
+ - **[uv](https://docs.astral.sh/uv/)** (recommended)
31
+ - A Microsoft / Xbox account
32
+
33
+ ---
34
+
35
+ ## Quick Start
36
+
37
+ ### 1. Run via `uvx` (Recommended — No Clone Needed)
38
+
39
+ ```bash
40
+ # Authenticate once with Microsoft / Xbox Live
41
+ uvx --from xbox-mcp xbox-auth
42
+
43
+ # Run the MCP server
44
+ uvx xbox-mcp
45
+ ```
46
+
47
+ Or clone locally for development:
48
+
49
+ ```bash
50
+ git clone https://github.com/VinsentY/xbox-mcp.git
51
+ cd xbox-mcp
52
+ uv sync
53
+ uv run xbox-auth
54
+ ```
55
+
56
+ ### 2. Authenticate with Microsoft / Xbox Live (One-Time Setup)
57
+
58
+ Choose either method:
59
+
60
+ #### Option A: CLI Auto-Callback (Recommended)
61
+
62
+ ```bash
63
+ uv run xbox-auth
64
+ ```
65
+
66
+ This starts a temporary local listener on `http://localhost:8080/auth/callback`, opens Microsoft's official OAuth2 sign-in page in your browser, exchanges the authorization code for OAuth2 + XBL + XSTS tokens, and saves them locally with `0600` permissions.
67
+
68
+ #### Option B: In-Chat / Manual Callback URL
69
+
70
+ If you prefer not to run a local HTTP listener (or port `8080` is occupied):
71
+
72
+ 1. Ask your AI assistant to call `get_auth_status` — it returns the official Microsoft `login_url`.
73
+ 2. Sign in in your browser. After consent, the browser redirects to `http://localhost:8080/auth/callback?code=...` (an unreachable localhost page is expected).
74
+ 3. Copy the full URL from your browser's address bar and pass it to `complete_auth` (or run `uv run xbox-auth --code "<callback_url>"`).
75
+
76
+ > **Note on Token Storage & Auto-Refresh**
77
+ > Tokens are stored locally at `~/Library/Application Support/xbox/tokens.json` on macOS (or `~/.local/share/xbox/tokens.json` on Linux, overrideable via `XBOX_TOKENS_FILE`) with `0600` permissions. `xbox-mcp` automatically refreshes expired access/XSTS tokens and persists rotated refresh tokens back to disk.
78
+
79
+ ---
80
+
81
+ ## MCP Client Configuration
82
+
83
+ ### Antigravity (`~/.gemini/config/mcp_config.json`) / Claude Desktop / Cursor
84
+
85
+ Using `uvx` (recommended — zero local clone required):
86
+
87
+ ```json
88
+ {
89
+ "mcpServers": {
90
+ "xbox": {
91
+ "command": "uvx",
92
+ "args": ["xbox-mcp"],
93
+ "env": {
94
+ "XBOX_LANGUAGE": "en-US"
95
+ }
96
+ }
97
+ }
98
+ }
99
+ ```
100
+
101
+ Or using a local clone's virtual environment binary:
102
+
103
+ ```json
104
+ {
105
+ "mcpServers": {
106
+ "xbox": {
107
+ "command": "/absolute/path/to/xbox-mcp/.venv/bin/xbox-mcp",
108
+ "args": [],
109
+ "env": {
110
+ "XBOX_LANGUAGE": "en-US"
111
+ }
112
+ }
113
+ }
114
+ }
115
+ ```
116
+
117
+ ### Environment Variables (All Optional)
118
+
119
+ | Variable | Default | Description |
120
+ |---|---|---|
121
+ | `XBOX_TOKENS_FILE` | OS app data `xbox/tokens.json` | Custom path for local OAuth2 token persistence |
122
+ | `XBOX_LANGUAGE` | `en-US` | `Accept-Language` header for titles/achievements (e.g. `zh-CN`, `ja-JP`) |
123
+ | `XBOX_CLIENT_ID` | OpenXbox public client ID | Override with your own Azure App Registration Client ID |
124
+ | `XBOX_CLIENT_SECRET` | *(empty)* | Optional Azure App Client Secret if using a confidential app |
125
+ | `XBOX_REDIRECT_URI` | `http://localhost:8080/auth/callback` | Custom OAuth2 redirect URI matching your app registration |
126
+
127
+ ---
128
+
129
+ ## Available Tools (10)
130
+
131
+ | Tool | Description |
132
+ |---|---|
133
+ | `get_auth_status` | Verify local Xbox OAuth token validity; returns the Microsoft login URL if unauthenticated |
134
+ | `complete_auth` | Exchange an OAuth callback URL (`http://localhost:8080/auth/callback?code=...`) or raw code and save tokens locally |
135
+ | `get_profile` | Fetch Gamertag, Modern Gamertag, Gamerscore, Account Tier, Tenure, Bio, Location, and Avatar |
136
+ | `get_presence` | Check online status and currently playing title/device (Xbox console, PC, Cloud) |
137
+ | `get_game_library` | Fetch full Xbox / PC Game Pass history enriched with exact `MinutesPlayed`, sortable by `playtime`, `recent`, `achievements`, or `name`, with `platform`, `game_pass_only`, `tracked_only`, and `exclude_win32_footprints` filters |
138
+ | `get_recently_played` | Quick view of most recently played titles with playtime and achievement progress |
139
+ | `get_playtime_summary` | Aggregate report: total hours, Xbox console vs. PC breakdown, Game Pass share, playtime buckets, 100% completed games, Win32 footprint count, and Top 20 titles |
140
+ | `get_game_achievements` | Per-title achievement list with unlock timestamps, Gamerscore, and global rarity percentage (`sort_by`: `default`, `rarity`, `gamerscore`, `unlock_time`) |
141
+ | `get_game_stats` | Fetch `MinutesPlayed` and Hero stats for a specific `title_id` or `scid` |
142
+ | `get_friends_list` | List Xbox Live friends with Gamertags, Gamerscore, online status, and currently playing game |
143
+
144
+ ---
145
+
146
+ ## Example Prompts
147
+
148
+ - *"Summarize my Xbox and PC Game Pass playtime and build a gamer profile."*
149
+ - *"Show my top 20 most-played Xbox / Game Pass games, excluding Win32 Game Bar footprints."*
150
+ - *"What are my rarest unlocked achievements in Clair Obscur: Expedition 33?"*
151
+ - *"Compare my Steam library with my Xbox / Game Pass library and find games I've played on both."*
152
+ - *"Which of my Xbox friends are online right now and what are they playing?"*
153
+
154
+ ---
155
+
156
+ ## Troubleshooting
157
+
158
+ - **Passkey interstitial (`account.live.com/interrupt/passkey`) during login**: Click *Skip for now / Cancel* on the Microsoft Passkey prompt, then approve the Xbox Live consent screen until the browser redirects to `http://localhost:8080/auth/callback?code=...`.
159
+ - **`account.live.com` connection closed (`ERR_CONNECTION_CLOSED`)**: In regions with unstable routing to Microsoft Live endpoints, make sure `login.live.com`, `account.live.com`, and `*.xboxlive.com` route consistently through your network/proxy.
160
+ - **Win32 games showing `0m` / `null` playtime**: Windows Xbox Game Bar automatically records non-Xbox PC games (e.g., Steam, Riot, Battle.net titles) in TitleHub without `MinutesPlayed` telemetry. Pass `exclude_win32_footprints=true` or `tracked_only=true` to `get_game_library` to focus purely on Xbox / Game Pass titles.
161
+
162
+ ---
163
+
164
+ ## Development & Tests
165
+
166
+ ```bash
167
+ uv sync
168
+ uv run python -m unittest discover -s tests -v
169
+ ```
170
+
171
+ ---
172
+
173
+ ## Security & Privacy
174
+
175
+ - OAuth2 tokens are stored **only on your local machine** with `0600` file permissions and are never sent to any third-party service.
176
+ - `.gitignore` excludes `tokens.json`, `*tokens*.json`, and `.env*` by default.
177
+ - Never commit your local `tokens.json` file to version control.
178
+
179
+ ## License
180
+
181
+ [MIT](LICENSE)
@@ -0,0 +1,37 @@
1
+ [project]
2
+ name = "xbox-mcp"
3
+ version = "0.1.0"
4
+ description = "Local MCP Server for official Microsoft Xbox Live APIs (playtime, Game Pass library, achievements, rarity, presence, friends)"
5
+ readme = "README.md"
6
+ keywords = [
7
+ "mcp",
8
+ "xbox",
9
+ "xbox-live",
10
+ "game-pass",
11
+ "gaming",
12
+ "model-context-protocol",
13
+ ]
14
+ requires-python = ">=3.12"
15
+ dependencies = [
16
+ "mcp[cli]>=2.3.0",
17
+ "xbox-webapi>=2.1.0",
18
+ ]
19
+
20
+ [project.license]
21
+ text = "MIT"
22
+
23
+ [[project.authors]]
24
+ name = "VinsentY"
25
+
26
+ [project.urls]
27
+ Homepage = "https://github.com/VinsentY/xbox-mcp"
28
+ Repository = "https://github.com/VinsentY/xbox-mcp"
29
+ Issues = "https://github.com/VinsentY/xbox-mcp/issues"
30
+
31
+ [project.scripts]
32
+ xbox-mcp = "xbox_mcp.server:main"
33
+ xbox-auth = "xbox_mcp.auth:cli_main"
34
+
35
+ [build-system]
36
+ requires = ["uv_build>=0.13.9,<0.14.0"]
37
+ build-backend = "uv_build"
@@ -0,0 +1,28 @@
1
+ [project]
2
+ name = "xbox-mcp"
3
+ version = "0.1.0"
4
+ description = "Local MCP Server for official Microsoft Xbox Live APIs (playtime, Game Pass library, achievements, rarity, presence, friends)"
5
+ readme = "README.md"
6
+ license = { text = "MIT" }
7
+ authors = [
8
+ { name = "VinsentY" }
9
+ ]
10
+ keywords = ["mcp", "xbox", "xbox-live", "game-pass", "gaming", "model-context-protocol"]
11
+ requires-python = ">=3.12"
12
+ dependencies = [
13
+ "mcp[cli]>=2.3.0",
14
+ "xbox-webapi>=2.1.0",
15
+ ]
16
+
17
+ [project.urls]
18
+ Homepage = "https://github.com/VinsentY/xbox-mcp"
19
+ Repository = "https://github.com/VinsentY/xbox-mcp"
20
+ Issues = "https://github.com/VinsentY/xbox-mcp/issues"
21
+
22
+ [project.scripts]
23
+ xbox-mcp = "xbox_mcp.server:main"
24
+ xbox-auth = "xbox_mcp.auth:cli_main"
25
+
26
+ [build-system]
27
+ requires = ["uv_build>=0.13.9,<0.14.0"]
28
+ build-backend = "uv_build"
@@ -0,0 +1,5 @@
1
+ """Local MCP Server for official Microsoft Xbox Live APIs."""
2
+
3
+ from .server import main
4
+
5
+ __all__ = ["main"]