Metadata-Version: 2.4
Name: marketing-data-platform
Version: 0.1.1
Summary: Login CLI and MCP server for the Data Platform API.
Requires-Python: >=3.11
Requires-Dist: httpx>=0.27.0
Requires-Dist: mcp>=1.2.0
Requires-Dist: pydantic-settings>=2.6.0
Description-Content-Type: text/markdown

# Marketing Data Platform

Python package for local agents and MCP clients that need to access the Data Platform API.

It provides two commands:

- `data-platform-login`: login with Google and save a local Data Platform API session.
- `data-platform-mcp`: start the MCP server that exposes mart access tools.

The MCP server does not connect to BigQuery directly. It calls the Data Platform API, and the API owns BigQuery credentials, authorization, and tenant access control.

## Install

For local development:

```bash
uv run --package marketing-data-platform data-platform-login --help
uv run --package marketing-data-platform data-platform-mcp
```

After publishing to PyPI:

```bash
uvx --from marketing-data-platform data-platform-login --help
uvx --from marketing-data-platform data-platform-mcp
```

## Login

The Data Platform API must be running and configured with Google OAuth.

```bash
uvx --from marketing-data-platform data-platform-login \
  --api-base-url https://data-platform-api.example.com
```

The CLI fetches the Google OAuth client ID from the Data Platform API. User machines do not need `DATA_PLATFORM_GOOGLE_OAUTH_CLIENT_ID` or `DATA_PLATFORM_GOOGLE_OAUTH_CLIENT_SECRET`.

By default, the command writes the MCP session file to:

```text
~/.config/data-platform/mcp.env
```

The session token is saved locally with file mode `600` and is not printed.

## MCP Config

For a published package:

```toml
[mcp_servers.data-platform-mart]
command = "uvx"
args = ["--from", "marketing-data-platform", "data-platform-mcp"]
startup_timeout_sec = 120
```

For this monorepo during development:

```toml
[mcp_servers.data-platform-mart]
command = "uv"
args = [
  "run",
  "--directory",
  "/path/to/data-platform",
  "--package",
  "marketing-data-platform",
  "data-platform-mcp",
]
startup_timeout_sec = 120
```

## MCP Tools

- `get_daily_ad_performance`

## Environment Variables

| Name | Required | Description |
| --- | --- | --- |
| `DATA_PLATFORM_API_BASE_URL` | optional | Data Platform API base URL. Default: `http://127.0.0.1:8002` |
| `DATA_PLATFORM_API_SESSION_TOKEN` | optional | Session JWT issued by login. Usually read from the session file. |
| `DATA_PLATFORM_MCP_SESSION_FILE` | optional | Session env file. Default: `~/.config/data-platform/mcp.env` |
| `DATA_PLATFORM_MCP_DEFAULT_LIMIT` | optional | Default row limit. Default: `100` |
| `DATA_PLATFORM_MCP_MAX_LIMIT` | optional | Max row limit. Default: `1000` |
