|
| 1 | +# Contributing |
| 2 | + |
| 3 | +Thanks for your interest in contributing to the Iterable MCP Server! We welcome bug reports, feature requests, and pull requests. If you find a bug or have an idea, please [open an issue](https://github.com/Iterable/mcp-server/issues). |
| 4 | + |
| 5 | +## Prerequisites |
| 6 | + |
| 7 | +- Node.js >= 20 (v22 LTS recommended) |
| 8 | +- [pnpm](https://pnpm.io/) (see `packageManager` in `package.json` for the exact version) |
| 9 | + |
| 10 | +## Install from source |
| 11 | + |
| 12 | +To test changes locally, clone the repo and use one of the `install-dev` scripts. This builds the project and links it as a local MCP server in your AI client, so you can test your changes without publishing to npm. |
| 13 | + |
| 14 | +```bash |
| 15 | +git clone https://github.com/iterable/mcp-server.git |
| 16 | +cd mcp-server |
| 17 | +pnpm install-dev:cursor # or install-dev:claude-desktop, install-dev:claude-code, install-dev:gemini-cli, install-dev:windsurf, install-dev:antigravity |
| 18 | +``` |
| 19 | + |
| 20 | +To enable debug logging during local development, use the `:debug` variants: |
| 21 | + |
| 22 | +```bash |
| 23 | +pnpm install-dev:cursor:debug |
| 24 | +``` |
| 25 | + |
| 26 | +## Project structure |
| 27 | + |
| 28 | +MCP tools live in `src/tools/`, one file per domain (campaigns, templates, catalogs, etc.). Each file exports a creator function that returns an array of MCP `Tool` definitions. These are registered in `src/tools/index.ts` via the `TOOL_CREATORS_BY_CATEGORY` array — adding a tool to the appropriate domain file is all that's needed for it to be picked up. |
| 29 | + |
| 30 | +Tool visibility is controlled by `src/tool-filter.ts`, which uses safe-lists to gate tools based on the `ITERABLE_USER_PII`, `ITERABLE_ENABLE_WRITES`, and `ITERABLE_ENABLE_SENDS` permission flags. |
| 31 | + |
| 32 | +### API client |
| 33 | + |
| 34 | +The MCP server uses [`@iterable/api`](https://github.com/Iterable/api-client) as its underlying API client. Tool definitions in this repo map user requests to API client methods. If you need to add support for a new Iterable API endpoint, you'll need to add it to the [api-client](https://github.com/Iterable/api-client) first, then expose it as an MCP tool here. |
| 35 | + |
| 36 | +## Development workflow |
| 37 | + |
| 38 | +```bash |
| 39 | +# Install dependencies |
| 40 | +pnpm install |
| 41 | + |
| 42 | +# Build the project (runs lint:fix, compiles TypeScript, updates TOOLS.md) |
| 43 | +pnpm build |
| 44 | + |
| 45 | +# Build and watch for changes (TypeScript only, does not update TOOLS.md) |
| 46 | +pnpm build:watch |
| 47 | + |
| 48 | +# Run in development mode (auto-reloads on file changes) |
| 49 | +pnpm dev |
| 50 | + |
| 51 | +# Build and link locally for testing |
| 52 | +pnpm run install-dev |
| 53 | +``` |
| 54 | + |
| 55 | +## Code quality |
| 56 | + |
| 57 | +The build automatically runs `lint:fix`, but you can also run these independently: |
| 58 | + |
| 59 | +```bash |
| 60 | +# Run all checks (format, typecheck, lint) |
| 61 | +pnpm check |
| 62 | + |
| 63 | +# Auto-format with Prettier |
| 64 | +pnpm format |
| 65 | + |
| 66 | +# Auto-fix lint issues with ESLint |
| 67 | +pnpm lint:fix |
| 68 | +``` |
| 69 | + |
| 70 | +## Running tests |
| 71 | + |
| 72 | +The project includes both unit and integration tests: |
| 73 | + |
| 74 | +```bash |
| 75 | +# Run all tests |
| 76 | +pnpm test |
| 77 | + |
| 78 | +# Run only unit tests (no API key required) |
| 79 | +pnpm test:unit |
| 80 | + |
| 81 | +# Run only integration tests (requires valid API key) |
| 82 | +pnpm test:integration |
| 83 | + |
| 84 | +# Watch mode |
| 85 | +pnpm test:watch |
| 86 | +``` |
| 87 | + |
| 88 | +### Integration tests |
| 89 | + |
| 90 | +Integration tests make real API calls to Iterable and require a valid API key. |
| 91 | + |
| 92 | +**Setup:** |
| 93 | + |
| 94 | +1. Set your API key as an environment variable: |
| 95 | + ```bash |
| 96 | + export ITERABLE_API_KEY=your_actual_api_key |
| 97 | + ``` |
| 98 | + |
| 99 | +2. Or add a key to key manager (interactive): |
| 100 | + ```bash |
| 101 | + iterable-mcp keys add |
| 102 | + ``` |
| 103 | + |
| 104 | + **Note:** The key name can be anything (e.g., "dev", "test", "staging"). The system automatically uses whichever key is marked as **active**. Your first key is automatically set as active. If you have multiple keys, use `iterable-mcp keys activate <name>` to switch between them. |
| 105 | + |
| 106 | +3. Run the integration tests: |
| 107 | + ```bash |
| 108 | + pnpm test:integration |
| 109 | + ``` |
| 110 | + |
| 111 | +**Note:** Integration tests require a valid API key (env var or active key manager key). The suite fails fast if none is found. |
| 112 | + |
| 113 | +## How TOOLS.md stays in sync |
| 114 | + |
| 115 | +`TOOLS.md` is auto-generated. The `scripts/update-tools.js` script reads the tool registry (`TOOL_CREATORS_BY_CATEGORY`) and the permission safe-lists (`tool-filter.ts`) to produce the full tool listing with permission badges. It runs automatically as part of `pnpm build`. |
| 116 | + |
| 117 | +To regenerate it manually: |
| 118 | + |
| 119 | +```bash |
| 120 | +pnpm update-tools |
| 121 | +``` |
0 commit comments