From a1758b40b8f35a0ece4ba601ea2fae9e5cec26f5 Mon Sep 17 00:00:00 2001 From: Dasemu Date: Sun, 18 Oct 2026 15:09:56 +0200 Subject: [PATCH] chore: bootstrap Claude setup Add root CLAUDE.md, LESSONS.md, docs/ index, .claude hooks (syntax-check on edit/write and on stop, since no linter/test suite is configured yet), CI/version GitHub Actions workflows scoped to the existing master branch, and translate .env.example comments to English. Co-Authored-By: Claude Sonnet 5 --- .claude/bootstrap-version | 1 + .claude/settings.json | 25 +++++++++++++++++++++ .env.example | 26 +++++++++++----------- .github/workflows/ci.yml | 28 ++++++++++++++++++++++++ .github/workflows/version.yml | 34 +++++++++++++++++++++++++++++ CLAUDE.md | 41 +++++++++++++++++++++++++++++++++++ LESSONS.md | 6 +++++ docs/README.md | 6 +++++ 8 files changed, 154 insertions(+), 13 deletions(-) create mode 100644 .claude/bootstrap-version create mode 100644 .claude/settings.json create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/version.yml create mode 100644 CLAUDE.md create mode 100644 LESSONS.md create mode 100644 docs/README.md diff --git a/.claude/bootstrap-version b/.claude/bootstrap-version new file mode 100644 index 0000000..0cfbf08 --- /dev/null +++ b/.claude/bootstrap-version @@ -0,0 +1 @@ +2 diff --git a/.claude/settings.json b/.claude/settings.json new file mode 100644 index 0000000..21f1a3e --- /dev/null +++ b/.claude/settings.json @@ -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 *.js) node --check \"$file\" ;; esac" + } + ] + } + ], + "Stop": [ + { + "hooks": [ + { + "type": "command", + "command": "cd \"$CLAUDE_PROJECT_DIR\" && status=0; for f in $(find src -name '*.js'); do node --check \"$f\" || status=1; done; exit $status" + } + ] + } + ] + } +} diff --git a/.env.example b/.env.example index 8e56a53..d50d9a0 100644 --- a/.env.example +++ b/.env.example @@ -1,36 +1,36 @@ -# Copia este archivo a .env y rellena los valores +# Copy this file to .env and fill in the values -# Token de acceso (largo, 60 dias) del usuario admin de la pagina/cuenta IG +# Access token (long-lived, 60 days) of the admin user of the page/IG account META_ACCESS_TOKEN= -# App ID y App Secret de tu app en developers.facebook.com +# App ID and App Secret of your app on developers.facebook.com META_APP_ID= META_APP_SECRET= -# Se obtienen con: npm run get-ids +# Obtained with: npm run get-ids META_PAGE_ID= META_IG_BUSINESS_ID= -# Version de la Graph API a usar +# Graph API version to use META_GRAPH_VERSION=v21.0 -# Puerto e interfaz donde escucha el servidor HTTP del MCP +# Port and interface the MCP HTTP server listens on PORT=3300 HOST=127.0.0.1 -# Token opcional para proteger el endpoint /mcp (header: Authorization: Bearer ) -# Dejalo vacio para desactivar la comprobacion (solo recomendable en local/dev) +# Optional token to protect the /mcp endpoint (header: Authorization: Bearer ) +# Leave empty to disable the check (only recommended in local/dev) MCP_AUTH_TOKEN= -# URL publica (con path si aplica) desde la que se sirven los archivos subidos -# con upload_media, ej: https://mcp.zenvairo.es/zenvairosocial +# Public URL (with path if applicable) from which files uploaded with upload_media are served, +# e.g. https://mcp.zenvairo.es/zenvairosocial MEDIA_BASE_URL= -# Directorio donde se guardan los archivos subidos (por defecto ./media) +# Directory where uploaded files are stored (defaults to ./media) MEDIA_DIR= -# Tamano maximo (MB) de un archivo subido con upload_media +# Maximum size (MB) of a file uploaded with upload_media MAX_UPLOAD_MB=50 -# Dias que se conservan los archivos subidos antes de borrarse automaticamente +# Days uploaded files are kept before being automatically deleted MEDIA_RETENTION_DAYS=7 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..256626e --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,28 @@ +name: CI + +# This repo currently only has a `master` branch (no `development`/`main` split yet). +# Update these triggers if/when the standard `development`/`main` branches are introduced. +on: + pull_request: + branches: [master] + push: + branches: [master] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-node@v4 + with: + node-version: "20" + cache: "npm" + + - run: npm ci + + # No linter or test suite is configured in package.json yet; this is the quickest + # meaningful check available (catches syntax errors in every source file). + - name: Syntax check + run: | + for f in $(find src -name '*.js'); do node --check "$f"; done diff --git a/.github/workflows/version.yml b/.github/workflows/version.yml new file mode 100644 index 0000000..31ce182 --- /dev/null +++ b/.github/workflows/version.yml @@ -0,0 +1,34 @@ +name: Version + +# Simplified for now: this repo only has a `master` branch (no `development`/`main` split yet). +# Once that split exists, update this to the full development→main bump rules described in the +# global CLAUDE.md (PATCH bump on push to development, MINOR bump + PATCH reset on an approved +# development→main PR, PATCH bump on a direct hotfix push to main). +on: + push: + branches: [master] + +permissions: + contents: write + +jobs: + bump: + if: ${{ !contains(github.event.head_commit.message, '[skip ci]') && github.actor != 'github-actions[bot]' }} + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - uses: actions/setup-node@v4 + with: + node-version: "20" + + - name: Bump patch version + run: | + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + npm version patch --no-git-tag-version + VERSION=$(node -p "require('./package.json').version") + git commit -am "chore(release): v${VERSION} [skip ci]" + git push diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 0000000..a20f4af --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,41 @@ +# CLAUDE.md + +## Overview +SocialMCP: an MCP HTTP server that publishes to and manages a single Facebook Page and +linked Instagram professional account via Meta's Graph API (stateless streamable-HTTP MCP +transport). + +## Commands +- Dev/run: `npm start` (serves `http://HOST:PORT/mcp`, defaults `127.0.0.1:3300`) +- Helper scripts: `npm run get-ids` (fetch Page/IG IDs and Page Access Token), `npm run extend-token` + (exchange a short-lived user token for a 60-day one) +- Test: none configured yet +- Lint: none configured yet +- Build: none (plain Node.js, no bundling/transpilation) + +## Architecture +Entry point `src/index.js` wires an Express HTTP server to the MCP SDK (`@modelcontextprotocol/sdk`). +Tools are defined in `src/tools.js` and call the Graph API through `src/graph.js`. `src/media.js` +handles local file uploads served back as public URLs for `publish_post`. See `README.md` for the +full tool reference and `docs/` for anything longer-form. + +## Conventions +- ES modules (`"type": "module"` in package.json). +- No TypeScript, no bundler: code runs directly with `node`. +- Config is env-var only, read via `process.env` (see `.env.example` for the full list); never + hardcode credentials. + +## Workflow quirks +- `get-ids` and `extend-token` are one-off setup scripts, not part of the server runtime. +- The server is stateless: each JSON-RPC request is handled independently (no session state kept + in memory between requests), per the MCP SDK's recommendation for streamable HTTP. + +## Deployment +Use the `web-deploy` skill for anything related to hosting this as a live service (LXC/VPS, +systemd, update script, authenticated update endpoint). + +## Gotchas +- Instagram requires media (`imageUrl`/`videoUrl`/`media`) on every post; text-only posts are + Facebook-only. +- Graph API insight metric names change between API versions; see the README's Insights section + for the metrics confirmed working on the current `META_GRAPH_VERSION`. diff --git a/LESSONS.md b/LESSONS.md new file mode 100644 index 0000000..807032d --- /dev/null +++ b/LESSONS.md @@ -0,0 +1,6 @@ +# LESSONS.md + +Recurring mistakes and how to avoid them. Read before starting work; add an entry when a mistake +repeats. + +(No entries yet.) diff --git a/docs/README.md b/docs/README.md new file mode 100644 index 0000000..75cb675 --- /dev/null +++ b/docs/README.md @@ -0,0 +1,6 @@ +# Documentation index + +This directory is the standard location for longer-form docs. Right now the full setup guide and +tool reference live in the root `README.md` (kept there since it currently doubles as the +project's quick-start guide); move sections here as they grow instead of letting the root README +turn into a long reference manual.