MCP server that gives Claude access to Costco warehouse receipts and online orders — multi-account, direct GraphQL via Azure AD B2C refresh tokens
Project description
Costco MCP Server
An MCP (Model Context Protocol) server that gives Claude access to Costco warehouse receipts and online orders. Talks directly to Costco's internal GraphQL API using OAuth2 refresh tokens extracted from a browser session — no scraping, no runtime headless browser. Multi-account (e.g. personal, spouse) with per-account token storage.
Available on the MCP Registry as io.github.thehesiod/costco.
Disclaimer
This project is not affiliated with, endorsed by, or sponsored by Costco Wholesale Corporation. "Costco" and all related names, logos, and trademarks are the property of their respective owners.
This server communicates with Costco's undocumented internal APIs — endpoints that are not published, not guaranteed to be stable, and may change or be blocked at any time without notice. Use of those APIs may violate Costco's Terms of Service; you are responsible for reviewing the ToS and deciding whether your use is acceptable.
Use at your own risk. The authors and contributors accept no responsibility for any consequences of using this software, including but not limited to: account suspension or termination, data loss or corruption, incorrect receipt/order information, failed purchases, financial discrepancies, API rate-limit strikes, IP blocks, or any other direct or indirect damages. No warranty is provided — see LICENSE for the full MIT no-warranty clause.
If Costco publishes an official API, this project should be considered deprecated in favor of that.
Features
Warehouse
list_warehouse_receipts— In-store receipts for a date range (barcode, warehouse, total)get_receipt_detail— Full itemized receipt by barcode (products, quantities, prices, coupons, department codes)get_all_receipt_details— Bulk fetch every receipt's full detail for a date range
Online Orders
list_online_orders— Costco.com orders for a date range (order number, status, items, totals)
Products
lookup_products— Resolve item numbers to full product names + departments. Uses a local SQLite cache (~/.costco-mcp/products.db) so repeated lookups are free.
Authentication
check_auth_status— Report token freshness and list configured accountssave_refresh_token— Register or update an account's refresh token
Setup
Install in Claude Code
claude mcp add --transport stdio costco -- \
uvx --from "costco-mcp-server @ git+https://github.com/thehesiod/costco-mcp" costco-mcp-server
Once published to PyPI, the above simplifies to:
claude mcp add --transport stdio costco -- uvx costco-mcp-server
Authentication
Costco doesn't expose a public OAuth app, so refresh tokens are extracted from your browser's Azure AD B2C session storage. Refresh tokens are valid for ~90 days; bearer tokens are minted transparently on each API call.
Semi-automated flow (recommended). Uses a dedicated Chrome profile + chrome-devtools-mcp so Claude extracts and registers the token for you. After first setup, each re-auth is "launch the browser, ask Claude to refresh."
-
Launch the auth browser (cross-platform console script):
uvx --from "costco-mcp-server @ git+https://github.com/thehesiod/costco-mcp" costco-auth-browser
Chrome starts on port 9223 with a persistent profile at
~/.costco-mcp/chrome-profile/. -
Register a chrome-devtools-mcp instance pointed at that port (one time):
claude mcp add costco-browser -- npx -y chrome-devtools-mcp --browserUrl http://127.0.0.1:9223
-
Log into costco.com in the launched browser window (first time only — the profile persists).
-
Ask Claude to refresh:
Extract my Costco refresh token and save it for account "personal".
Claude reads the
msal.*.refreshtokenentry from localStorage viachrome-devtools-mcpand callssave_refresh_token.
Manual fallback. If you'd rather not wire up a second MCP: log into costco.com, open DevTools → Application → Local Storage → https://www.costco.com, find the key containing refreshtoken, copy the secret field from its JSON value, then:
uvx --from "costco-mcp-server @ git+https://github.com/thehesiod/costco-mcp" \
costco-mcp-server --save-token personal <REFRESH_TOKEN>
Multi-Account
Every tool takes an optional account argument (e.g. "personal", "spouse"). Omitting it uses the default account (first registered, or most recently set). Account data is isolated per name under ~/.costco-mcp/accounts/<name>/.
How It Works
The server uses httpx[http2] to hit Costco's internal GraphQL endpoints directly:
ecom-api.costco.com/ebusiness/order/v1/orders/graphql— warehouse receipts + online ordersecom-api.costco.com/ebusiness/product/v1/products/graphql— product lookups
Authentication uses Azure AD B2C (signin.costco.com). The public client IDs baked into auth.py (tenant, policy, MSAL/WCS client IDs) ship in Costco's own browser bundle — they are not secrets. No credentials (username/password) are handled by this server.
See CLAUDE.md for architecture details and development notes.
Platform Notes
Fully cross-platform (macOS, Linux, Windows). No shell scripts — all entry points are Python console scripts.
The semi-automated auth flow requires Chrome or Chromium installed at a standard location. costco-auth-browser searches:
- macOS:
/Applications/Google Chrome.app/... - Windows:
%ProgramFiles%,%ProgramFiles(x86)%,%LocalAppData%underGoogle\Chrome\Application\chrome.exe - Linux / fallback:
google-chrome,google-chrome-stable,chromium,chromium-browseronPATH
Override the debugger port with COSTCO_AUTH_PORT.
Security Notes
- Refresh tokens are stored plaintext in
~/.costco-mcp/. Rely on OS-level home directory permissions. - No credentials handled by this server. Authentication happens entirely in your browser's Costco login flow.
- The Azure AD B2C client IDs in
auth.pyare public SPA identifiers that ship in Costco's browser bundle — not secrets.
License
MIT — see LICENSE.
mcp-name: io.github.thehesiod/costco
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file costco_mcp_server-0.1.1.tar.gz.
File metadata
- Download URL: costco_mcp_server-0.1.1.tar.gz
- Upload date:
- Size: 51.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4fd53b4dc8800297c8e0ea57832315aeb0f5adec3016e8e472e7b2590ff72c31
|
|
| MD5 |
86d8e6367e5b45967d0734240b9ca7fc
|
|
| BLAKE2b-256 |
5af27d8922adf4789a8d89cd999fd7d4058f25b877fc95d57727323865741bd4
|
Provenance
The following attestation bundles were made for costco_mcp_server-0.1.1.tar.gz:
Publisher:
publish.yml on thehesiod/costco-mcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
costco_mcp_server-0.1.1.tar.gz -
Subject digest:
4fd53b4dc8800297c8e0ea57832315aeb0f5adec3016e8e472e7b2590ff72c31 - Sigstore transparency entry: 1340753088
- Sigstore integration time:
-
Permalink:
thehesiod/costco-mcp@1b6b93c98e563aac3264189d76b9a07379d077e3 -
Branch / Tag:
refs/tags/0.1.1 - Owner: https://github.com/thehesiod
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@1b6b93c98e563aac3264189d76b9a07379d077e3 -
Trigger Event:
push
-
Statement type:
File details
Details for the file costco_mcp_server-0.1.1-py3-none-any.whl.
File metadata
- Download URL: costco_mcp_server-0.1.1-py3-none-any.whl
- Upload date:
- Size: 16.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
30c2584a44b74513b4758f253149e0bfd743e18e704748a4d6823911d147e564
|
|
| MD5 |
8cf04a1fdd39b21c46e7e7db3903fa66
|
|
| BLAKE2b-256 |
8bc461685c7e96d3194a196d4b1267583eb94cca1d750f7af01222f0a36d42b2
|
Provenance
The following attestation bundles were made for costco_mcp_server-0.1.1-py3-none-any.whl:
Publisher:
publish.yml on thehesiod/costco-mcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
costco_mcp_server-0.1.1-py3-none-any.whl -
Subject digest:
30c2584a44b74513b4758f253149e0bfd743e18e704748a4d6823911d147e564 - Sigstore transparency entry: 1340753090
- Sigstore integration time:
-
Permalink:
thehesiod/costco-mcp@1b6b93c98e563aac3264189d76b9a07379d077e3 -
Branch / Tag:
refs/tags/0.1.1 - Owner: https://github.com/thehesiod
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@1b6b93c98e563aac3264189d76b9a07379d077e3 -
Trigger Event:
push
-
Statement type: