Skip to main content
Glama
Studio Finch

Studio Finch

by RevanNasser
README.md
# Studio Finch

<p align="center">
  <img src="assets/studio-finch-readme-banner.png" width="960" alt="Finch says: Ask better questions about your channel. Studio Finch supports YouTube, AdSense, and read-only access." />
</p>

Studio Finch is an open-source, self-hosted MCP server that lets an AI assistant answer questions about a creator's YouTube channel and Google AdSense account. It is intentionally **read-only**: it helps people understand their numbers without taking actions on their behalf.

> **Status:** early release. The core Google connection and read-only MCP tools work; the contributor experience is actively being improved.

## What it can do

- Summarize the authenticated YouTube channel and lifetime statistics.
- Compare views, watch time, average view duration, and subscribers across any date range.
- Check which AdSense accounts the connected Google account can access.
- Work from Hermes, Codex, or another MCP-compatible client.

## What it will never do

Studio Finch does **not** upload or delete videos, publish posts, reply to comments, change monetization, alter AdSense settings, or initiate payments. The OAuth scopes and MCP tools are read-only by design.

## Example questions

```text
Give me a channel health report for the last 28 days.
Compare this month with last month and explain the biggest changes.
Which metrics should I improve before I publish my next video?
Check whether my Google account has an accessible AdSense account.
```

## Example result

<p align="center">
  <img src="assets/example-weekly-report.svg" width="900" alt="Fictional Studio Finch weekly creator report" />
</p>

*This is a fictional demo report. Studio Finch only shows data from the Google account that its owner explicitly connects.*

## Included MCP tools

| Tool | Description |
| --- | --- |
| `get_channel_summary` | Channel name and lifetime statistics. |
| `get_channel_analytics(start_date, end_date)` | Views, watch time, average view duration, and subscribers gained. |
| `get_adsense_accounts` | Accessible Google AdSense accounts. |

## Architecture

```text
MCP client (Hermes, Codex, etc.)
              |
              v
       Studio Finch MCP server
              |
              v
 Google OAuth + encrypted local token store
              |
              v
YouTube Data API / YouTube Analytics API / AdSense Management API
```

Tokens are encrypted at rest using `TOKEN_ENCRYPTION_KEY`. Keep the service private, use a dedicated MCP token, and never put a token in a public URL, screenshot, issue, or README.

## Quick start

### 1. Create a Google OAuth client

Create a free Google Cloud project and enable these APIs:

- YouTube Data API v3
- YouTube Analytics API
- AdSense Management API

Create an OAuth client for a web application. Add this exact redirect URL:

```text
https://YOUR_DOMAIN/oauth/google/callback
```

While your OAuth consent screen is in testing, add the Google account that owns the channel as a test user. A billing account is not required for the normal read-only API use covered by this project.

### 2. Configure the service

```bash
cp .env.example .env
```

Fill in the values in `.env`. Generate secrets locally:

```bash
python -c "from cryptography.fernet import Fernet; print(Fernet.generate_key().decode())"
python -c "import secrets; print(secrets.token_urlsafe(32))"
```

Use a different generated value for `APP_ADMIN_TOKEN` and `MCP_TOKEN`.

### 3. Run with Docker

```bash
docker build -t studio-finch .
docker run --env-file .env -p 8000:8000 -v studio-finch-data:/data studio-finch
```

Open `https://YOUR_DOMAIN/auth/google` and complete Google authorization. The health check is available at `/healthz`.

For a secret-free first-run checklist, open `https://YOUR_DOMAIN/setup`. It shows whether Google OAuth, the channel connection, and the dedicated MCP token are ready, without ever showing their values.

### 4. Connect an MCP client

Add a remote HTTP MCP server pointing at:

```text
https://YOUR_DOMAIN/mcp
```

Authenticate it with `MCP_TOKEN`, a dedicated bearer token that cannot access the administrative REST endpoints. `MCP_QUERY_TOKEN` is retained only as a temporary compatibility path for existing Hermes installations; never put either token in a public URL or repository.

For Codex, remote MCP servers can be added through the Codex CLI or its shared configuration. See the [Codex MCP documentation](https://developers.openai.com/learn/docs-mcp) for the current configuration flow.

## Environment variables

| Variable | Required | Purpose |
| --- | --- | --- |
| `GOOGLE_CLIENT_ID` | Yes | OAuth client ID. |
| `GOOGLE_CLIENT_SECRET` | Yes | OAuth client secret. |
| `PUBLIC_BASE_URL` | Yes | Public HTTPS URL of this service. |
| `TOKEN_ENCRYPTION_KEY` | Yes | Fernet key used to encrypt Google tokens at rest. |
| `APP_ADMIN_TOKEN` | Yes | Private bearer token for administrative REST endpoints only. |
| `MCP_TOKEN` | Yes | Dedicated, read-only bearer token for MCP clients. |
| `MCP_QUERY_TOKEN` | No | Legacy compatibility token for existing Hermes installations; new installs should use `MCP_TOKEN`. |
| `TOKEN_DB_PATH` | No | SQLite path; defaults to `/data/tokens.db`. |
| `PORT` | No | Server port; defaults to `8000`. |

## Deploying on Coolify

1. Create an application from this repository.
2. Give it a persistent volume mounted at `/data`.
3. Add the required environment variables as secrets.
4. Set `PUBLIC_BASE_URL` to the deployed HTTPS domain.
5. Add `https://YOUR_DOMAIN/oauth/google/callback` to your Google OAuth client's authorized redirect URIs.
6. Deploy, then visit `/auth/google` once to connect the Google account.
7. Open `/setup` to confirm the installation is ready without exposing any secrets.

## Running the tests

The authentication, OAuth-state, and setup-screen checks use Python's built-in test runner:

```bash
python -m unittest discover -s tests -v
```

## Privacy and security

- Google permissions are limited to `youtube.readonly`, `yt-analytics.readonly`, and `adsense.readonly`.
- OAuth tokens are encrypted before being written to the local SQLite database.
- Keep `.env`, database files, deployment secrets, and MCP tokens out of Git.
- Treat MCP output as sensitive creator data. Only connect clients and models you trust.
- Rotate any token immediately if it is exposed.

## Roadmap

See [ROADMAP.md](ROADMAP.md) for the public plan, including better setup ergonomics, scheduled reporting, video-level insights, and multi-channel support.

## Contributing

Contributions are welcome. Please open an issue before proposing a large feature and keep every new capability read-only unless the project maintainers explicitly agree otherwise.

## License

Studio Finch is released under the [MIT License](LICENSE).