How rushikeshmore/shopify-partner-agent works
1. Project shape
- This is a small Python 3.11+ package that ships as an MCP server called shopify-partner-agent.
- It is not a hosted service: the server runs locally inside the user’s MCP client environment and talks directly to Shopify’s Partner API.
2. Primary runtime boundary
- The main architectural boundary is:
LLM/MCP client → local MCP server → Shopify Partner API
- There is no database, queue, web frontend, or intermediate backend operated by this repo.
- Credentials and configuration stay on the user’s machine via environment variables.
3. Server layer
- src/shopify_partner_agent/server.py is the entry point for the MCP server.
- It is responsible for exposing the 25 tools described in the README and wiring tool names to handler functions.
- This is the outward-facing interface that Claude Desktop, Claude Code, Cursor, or Windsurf connect to.
4. API access layer
- src/shopify_partner_agent/client.py is the Shopify API boundary.
- It centralizes authenticated requests using SHOPIFY_ORG_ID, SHOPIFY_ACCESS_TOKEN, and SHOPIFY_APP_IDS.
- This layer likely handles GraphQL transport, pagination, and error handling so the analytics layer doesn’t need to know HTTP details.
5. Query definition layer
- src/shopify_partner_agent/queries.py holds the raw Partner API query documents.
- This isolates Shopify-specific field selection and makes the rest of the code work with structured responses rather than hardcoded GraphQL strings scattered across the app.
6. Analytics and metric computation
- src/shopify_partner_agent/analytics.py is the core business-logic engine.
- It turns raw Partner API data into computed SaaS metrics like MRR, churn, cohorts, health scores, churn risk, forecasts, and merchant digests.
- The README’s formulas imply this module is where the repo’s main intellectual value lives: it converts event/transaction history into derived metrics the API does not provide directly.
7. Data model and flow
- The main data flow is:
1. MCP tool call arrives from the client.
2. Server selects the appropriate analytics function.
3. Analytics function asks the client layer for Shopify data.
4. Query layer supplies the GraphQL shape.
5. Results are transformed into business metrics and returned to the MCP client.
- Many tools appear to share the same underlying event, transaction, and merchant records, then diverge into different summaries.
8. Tool grouping suggests shared internal pipelines
- The README’s 25 tools cluster into five reusable domains:
- core data retrieval,
- revenue analytics,
- customer analytics,
- growth/forecasting,
- merchant intelligence,
- multi-app comparison.
- That implies the repo is built around a few canonical datasets: apps, merchants, events, transactions, and churn/retention derived from them.
9. Multi-app support
- The presence of app comparison and revenue anomalies indicates the code can aggregate across multiple apps from SHOPIFY_APP_IDS.
- The architecture therefore supports both per-app and portfolio-level analysis, with app ID as a key partitioning dimension.
10. Operational model
- The package is intended to be launched via uvx shopify-partner-agent or installed with pip.
- The MCP client owns process startup, so this repo must expose a clean command-line/server entrypoint and read configuration from the environment at launch time.
11. Testing boundary
- tests/test_analytics.py suggests the main automated coverage is on metric computations rather than network integration.
- That means the highest-value test boundary is the analytics layer, where correctness of formulas and edge cases matter most.
12. CI/CD and release flow
- .github/workflows/ci.yml and publish.yml indicate standard GitHub Actions automation for validation and PyPI publishing.
- The repo is distributed as a package, so the build/release boundary is “source code → packaged Python artifact → PyPI → uvx/pip consumers.”
13. Privacy and deployment implications
- The README explicitly states there is no telemetry and no cloud relay.
- Architecturally, that means all sensitive business data only transits between the local machine and Shopify, then from the MCP server to the user’s chosen LLM provider through the MCP client.
14. Diagram takeaway
- If drawing this system, model it as a local analytics adapter:
the MCP client invokes tools, the server orchestrates calls, the client/query modules fetch Partner API data, and the analytics module computes higher-level SaaS metrics before returning structured responses.
Main entry points: client.py API client · analytics.py Analytics · server.py Server · .env.example Env vars
Components 16
Local runtime
MCP client, server, and Shopify API boundary
- MCP client · Claude Desktop, Claude Code, Cursor, or Windsurf that starts and calls the server
- Partner API · Shopify Partner API data source
- Env vars · SHOPIFY_ORG_ID, SHOPIFY_ACCESS_TOKEN, and SHOPIFY_APP_IDS
.env.example
Python package
Source modules that implement tool orchestration and analytics
- Server · Exposes tools and routes MCP requests to handlers
src/shopify_partner_agent/server.py - Tool map · Maps tool names to the underlying analytics functions
src/shopify_partner_agent/server.py - Analytics · Computes revenue, retention, cohort, forecast, and merchant intelligence metrics
src/shopify_partner_agent/analytics.py - API client · Handles authenticated Partner API requests, pagination, and errors
src/shopify_partner_agent/client.py - Queries · Reusable Partner API query documents and field selections
src/shopify_partner_agent/queries.py - Metric results · Computed SaaS metrics returned to the MCP client
- App scope · Per-app and portfolio-level aggregation keyed by app IDs
- Merchant data · Apps, merchants, events, and transactions pulled from Shopify
- Revenue models · MRR, churn, revenue anomalies, and forecast inputs
src/shopify_partner_agent/analytics.py - Customer models · Cohorts, health scores, churn risk, and retention views
src/shopify_partner_agent/analytics.py
Automation
Tests and release workflows
- Analytics tests · Validates metric formulas and edge cases
tests/test_analytics.py - CI workflow · Runs validation for the package
.github/workflows/ci.yml - Publish workflow · Builds and releases the package to PyPI
.github/workflows/publish.yml
Connections 18
- MCP client → Server: tool calls · Client invokes MCP tools on the local server
- Server → Tool map: dispatches · Server resolves each tool name to a handler
- Tool map → Analytics: invokes · Handlers call the analytics layer for computation
- Analytics → API client: fetches data · Analytics requests Shopify data through the API boundary
- API client → Queries: uses queries · Client applies query documents when calling Partner API
- API client → Partner API: requests · Authenticated GraphQL requests to Shopify
- Env vars → API client: auth/config · Environment variables configure access and app scope
- Env vars → Server: launch config · Server reads local configuration at startup
- API client → Merchant data: retrieves · Pulls apps, merchants, events, and transactions
- Merchant data → App scope: partitions by app · Shared datasets are grouped by app ID
- App scope → Revenue models: feeds · Partitioned data drives revenue calculations
- App scope → Customer models: feeds · Partitioned data drives customer analytics
- Revenue models → Metric results: returns · Revenue-derived results are formatted for MCP clients
- Customer models → Metric results: returns · Customer-derived results are formatted for MCP clients
- Analytics → Metric results: emits · Analytics functions produce structured responses
- Analytics tests → Analytics: verifies · Test coverage focuses on metric computation correctness
- CI workflow → Analytics tests: runs · CI executes the test suite
- Publish workflow → Server: packages · Release workflow publishes the installable server package