chore: bootstrap Claude setup

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
dasemuandClaude Sonnet 5 committed 2026-10-18 15:09:39 +02:00
1 parent c4ade94324
commit 533d4a0744
9 files changed
+185

No files matched your search

+1
View File
@@ -0,0 +1 @@
2
+25
View File
@@ -0,0 +1,25 @@
{
"hooks": {
"PostToolUse": [
{
"matcher": "Edit|Write",
"hooks": [
{
"type": "command",
"command": "file=$(cat | python3 -c 'import json,sys; print(json.load(sys.stdin).get(\"tool_input\",{}).get(\"file_path\",\"\"))'); case \"$file\" in *.py) python3 -m py_compile \"$file\" ;; esac"
}
]
}
],
"Stop": [
{
"hooks": [
{
"type": "command",
"command": "cd \"$CLAUDE_PROJECT_DIR\" && python3 -m py_compile server.py"
}
]
}
]
}
}
+15
View File
@@ -0,0 +1,15 @@
# Meta Graph API access token (required; server will not start without it)
META_ACCESS_TOKEN=
# Graph API version (optional, defaults to v21.0)
META_API_VERSION=
# Default ad account ID used when a tool call omits ad_account_id (optional)
META_DEFAULT_AD_ACCOUNT_ID=
# Host/port the MCP server binds to (optional, defaults to 127.0.0.1:8086)
BIND_HOST=
BIND_PORT=
# NOTE: in production these are supplied via `metaads-mcp.env`, per
# nixpacks.toml / .gitignore, not a generic `.env` file.
+27
View File
@@ -0,0 +1,27 @@
name: CI
on:
pull_request:
branches: [master]
push:
branches: [master]
jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: "pip"
- name: Install dependencies
run: pip install -r requirements.txt
# No linter or test suite is configured yet for this project.
# This is a syntax-check placeholder; replace with real lint/test
# commands once they exist.
- name: Syntax check
run: python -m py_compile server.py
+37
View File
@@ -0,0 +1,37 @@
name: Version bump
# This repo currently only has a single long-lived branch (master), not the
# development/main split described in the global workflow convention. Until
# a development branch exists, every push to master bumps PATCH.
on:
push:
branches: [master]
permissions:
contents: write
jobs:
bump:
if: >-
github.actor != 'github-actions[bot]' &&
!contains(github.event.head_commit.message, '[skip ci]')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Bump patch version
run: |
set -e
version=$(cat VERSION)
IFS='.' read -r major minor patch <<< "$version"
patch=$((patch + 1))
new_version="$major.$minor.$patch"
echo "$new_version" > VERSION
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add VERSION
git commit -m "chore(release): v$new_version [skip ci]"
git push
+50
View File
@@ -0,0 +1,50 @@
# CLAUDE.md
## Overview
MCP server exposing the Meta (Facebook/Instagram) Marketing Graph API as tools —
campaigns, ad sets, ads, creatives, custom/lookalike audiences, insights,
custom conversions, lead forms, and raw Graph API passthrough. Single-file
Python server (`server.py`) built on the `mcp` SDK, served over
streamable-http.
## Commands
- Run: `python server.py` (reads `META_ACCESS_TOKEN` etc. from the environment)
- Install deps: `pip install -r requirements.txt` (or `venv/bin/pip install -r requirements.txt`)
- Lint/test: none configured yet. CI only does a Python syntax check
(`python -m py_compile server.py`) until a linter/test suite is added.
## Architecture
- `server.py`: all tools, grouped by Graph API resource (campaigns, ad sets,
ads, creatives, audiences, insights, labels, lead forms) plus shared
helpers (`_request`, `_paged`, `_form`, `_query_value`, `_merge`) and the
custom-audience PII hashing helpers (`_PII_NORMALIZERS`).
- No persistence layer: every tool call hits the Graph API directly with
`META_ACCESS_TOKEN`.
- See `docs/deployment.md` for how this process is run in production.
## Conventions
- Keep all 55 tools in `server.py` grouped by resource with `# ---` section
banners, matching the existing style — do not split into multiple modules
without a stated reason.
- Tool docstrings are the only user-facing documentation (shown to the MCP
client); keep them accurate and concise when a tool's behavior changes.
- Graph API POST/DELETE bodies go through `_form()`; GET query params go
through `_query_value()` — don't hand-roll JSON-encoding for nested params.
## Workflow quirks
- No `development` branch exists; the default branch is `master`. Branch
per task from `master`.
- `venv/` is checked into the working tree but is local tooling, not part of
the shipped app (see `.gitignore`: only `metaads-mcp.env` is excluded).
## Deployment
- Deployed via Nixpacks (`nixpacks.toml`: `python server.py`), not Docker and
not the standard systemd/LXC setup described in the global CLAUDE.md.
- Runtime secrets live in `metaads-mcp.env` (not `.env`); see
`.env.example` for the variable names.
## Gotchas
- `META_ACCESS_TOKEN` is required (`os.environ[...]`, no default) — the
process will not start without it.
- `META_DEFAULT_AD_ACCOUNT_ID` is optional; tools that need an ad account ID
fall back to it via `_act()` and raise if neither is set.
+4
View File
@@ -0,0 +1,4 @@
# LESSONS.md
Recurring mistakes and how to avoid them. Read before starting work; add an
entry whenever the same mistake happens twice.
+1
View File
@@ -0,0 +1 @@
0.1.0
+25
View File
@@ -0,0 +1,25 @@
# Deployment
The server is built and started via [Nixpacks](https://nixpacks.com)
(`nixpacks.toml`):
```
[start]
cmd = "python server.py"
```
It listens on `BIND_HOST:BIND_PORT` (defaults `127.0.0.1:8086`) using the
streamable-http MCP transport.
## Environment
Runtime configuration is read from environment variables — see
`.env.example` for the full list. In production these are supplied via a
`metaads-mcp.env` file (excluded from git by `.gitignore`), not a generic
`.env`.
## Required permissions
Some tools require specific Meta Graph API permissions on the access token
(e.g. `list_leads` requires `leads_retrieval`). Check the relevant tool's
docstring in `server.py` before relying on it.