# TeamSnap MCP Server - Deployment Log
## Deployment Date: 2026-02-09
### Endpoint
`https://svu4xwvh74.execute-api.us-east-1.amazonaws.com`
---
## Deploy Cycle 1
**Timestamp:** 2026-02-09T17:45:00-08:00
### Build
- `npm install` in `aws/` — clean, 193 packages
- `npm run build` (esbuild) — success, 19.9kb CJS bundle
- No TypeScript or ESM/CJS errors in source code
### Deploy Script Failure
- **Error:** `APIGatewayV2Client is not a constructor`
- **Root Cause:** `aws/scripts/deploy.js` used default-import destructuring pattern (`import Pkg from "..."; const { X } = Pkg;`) which is incompatible with Node.js v25 ESM handling of CJS packages from AWS SDK v3
- **Fix 1:** Switched to named ESM imports — failed because `@aws-sdk/client-apigatewayv2` is a CJS module
- **Fix 2:** Used `createRequire()` to require all AWS SDK packages — still failed because the installed SDK version exports `ApiGatewayV2Client` (camelCase), not `APIGatewayV2Client` (ALLCAPS)
- **Fix 3:** Corrected class name from `APIGatewayV2Client` to `ApiGatewayV2Client`
### Deploy Success
- DynamoDB table: already exists (ACTIVE)
- IAM role: already exists, policy re-attached
- Lambda function: code + config updated, confirmed Active state
- API Gateway: already exists (`svu4xwvh74`), recreated 4 routes (GET /, GET /callback, POST /mcp, GET /health)
### Health Check
- `GET /health` → `{"status":"ok","service":"teamsnap-mcp"}`
- `GET /` → `{"status":"ok","service":"teamsnap-mcp"}`
### MCP Protocol Test
- `POST /mcp` initialize → returned protocolVersion `2024-11-05`, serverInfo `teamsnap-mcp v0.1.0`
- `POST /mcp` tools/list → returned all 9 tools with schemas
### Tool Call Failure
- **Error:** `{"message":"Internal Server Error"}` on `teamsnap_auth` tool call
- **CloudWatch:** `ValidationException: The provided key element does not match the schema`
- **Root Cause:** DynamoDB table was created in a previous deployment with partition key `userId`, but all code used `pk` as the key attribute name
- Triggered on `loadCredentials()` → `GetCommand({ Key: { pk: "user#default" } })`
---
## Deploy Cycle 2
**Timestamp:** 2026-02-09T17:47:00-08:00
### Fixes Applied
1. **`aws/src/dynamodb.ts`**: Changed all DynamoDB Key references from `pk` to `userId` (matching existing table schema)
2. **`aws/src/teamsnap.ts`**: Updated credential spreading to use `userId` instead of `pk`
3. **`aws/scripts/deploy.js`**: Updated CreateTableCommand schema to use `userId` for future deployments
### Deploy
- Rebuilt with esbuild — success
- Lambda code + config updated — Active
### Tool Call Test — Partial Success
- `teamsnap_auth` returned: `TEAMSNAP_CLIENT_ID and TEAMSNAP_CLIENT_SECRET must be set`
- **Root Cause:** Deploy script set env vars from `process.env.TEAMSNAP_CLIENT_ID || ""`, but shell `source .env` didn't `export` the vars, so Node.js didn't receive them
- **Fix:** Ran `aws lambda update-function-configuration` with explicit env var values
### Final Verification — All Tools Working
After env var fix, all 9 tools responded correctly:
| # | Tool | Response | Status |
|---|------|----------|--------|
| 1 | `teamsnap_auth` | Returns auth URL with state | OK |
| 2 | `teamsnap_auth_status` | `authenticated: false` | OK |
| 3 | `teamsnap_logout` | `status: logged_out` | OK |
| 4 | `teamsnap_list_teams` | "Not authenticated" (expected) | OK |
| 5 | `teamsnap_get_team` | "Not authenticated" (expected) | OK |
| 6 | `teamsnap_get_roster` | "Not authenticated" (expected) | OK |
| 7 | `teamsnap_get_events` | "Not authenticated" (expected) | OK |
| 8 | `teamsnap_get_event` | "Not authenticated" (expected) | OK |
| 9 | `teamsnap_get_availability` | "Not authenticated" (expected) | OK |
### OAuth Flow Verification
- Auth URL returns valid TeamSnap OAuth redirect (HTTP 302 → login page)
- Callback endpoint correctly processes requests:
- Missing code → returns HTML error with debug info
- Invalid code → properly attempts token exchange, returns `invalid_grant` error
- State parameter → correctly looked up in DynamoDB
- Redirect URI matches: `https://svu4xwvh74.execute-api.us-east-1.amazonaws.com/callback`
---
## Summary
| Metric | Value |
|--------|-------|
| Deploy cycles | 2 |
| Total issues fixed | 4 |
| Final status | All endpoints operational |
| Lambda runtime | Node.js 20.x |
| Bundle size | 19.9kb |
| Cold start | ~350ms |
| Warm request | ~1-3ms (health), ~450ms (DynamoDB) |
### Issues Fixed
1. Deploy script ESM/CJS import incompatibility with Node.js v25
2. AWS SDK `ApiGatewayV2Client` class name casing mismatch
3. DynamoDB key attribute mismatch (`pk` vs `userId`)
4. Lambda environment variables not propagated from shell
### Files Modified
- `aws/scripts/deploy.js` — Fixed imports, key schema
- `aws/src/dynamodb.ts` — Changed key attribute from `pk` to `userId`
- `aws/src/teamsnap.ts` — Updated credential key reference