spond-no-match-mcp
by Starefossen
README.md
# spond-no-match-mcp
An [MCP](https://modelcontextprotocol.io/) server for managing kids' sports activities on [Spond](https://spond.com/). Built for parents who want to give AI assistants access to upcoming matches, training schedules, and attendance — so you can ask "what's on this week?" or "sign Oliver up for Saturday's match" from any MCP-capable client.
## Features
- **Six tools** — list groups, upcoming events, event details, attendance status, RSVP, and search
- **Family member mapping** — configure which kids belong to which groups
- **Norwegian output** — responses formatted in Norwegian (dates, weekdays, status labels)
- **TTL caching** — groups cached 1h, events 5min to minimize API calls
- **Bearer token auth** — optional authentication for protecting sensitive family data
- **Scale-to-zero ready** — lightweight Python server, works great on Knative
## Tools
| Tool | Description |
| --------------------- | --------------------------------------------------------------- |
| `list_groups` | List all Spond groups with member counts |
| `get_upcoming_events` | Get upcoming events, filterable by kid or group |
| `get_event_details` | Full details for a specific event (location, description, RSVP) |
| `get_attendance` | Show which events are missing responses for your kids |
| `respond_to_event` | Accept or decline an event for a family member |
| `search_events` | Search upcoming events by text in title or description |
| `get_updates` | What's new (the app's notification feed): posts, comments, mentions, event changes; filter by group and `since_hours` |
| `get_posts` | Group wall posts with comment counts |
| `get_post_comments` | One post with all comments and replies |
| `get_chats` | Recent chats (DM, group, club) with last message and unread flag |
| `get_chat_messages` | Message history for one chat (newest 10, oldest first) |
| `get_attachment` | Attachment (📎) by id: PDF as text via docling (`DOCLING_URL`), otherwise name and link |
All tools except `respond_to_event` are read-only. Chat history, `get_updates` and post comments use
Spond endpoints the `spond` library does not wrap (`GET {chat_url}/chats/{id}/messages`, `GET /core/v1/activities`);
these are plain GETs and do not mark anything as read.
## Quick Start
### Prerequisites
- Python 3.11+
- A [Spond](https://spond.com/) account with active group memberships
### Run locally
```bash
# Install dependencies
pip install -r requirements.txt
# Start the server
SPOND_USERNAME=you@example.com \
SPOND_PASSWORD=your-password \
KIDS_CONFIG='[{"name":"Oliver","groups":["Team 2013"]},{"name":"Emma","groups":["Team 2017"]}]' \
python main.py
```
The server starts on port 8080:
- Health check: `http://localhost:8080/health`
- MCP SSE endpoint: `http://localhost:8080/sse`
### Docker
```bash
docker build -t spond-mcp .
docker run -p 8080:8080 \
-e SPOND_USERNAME=you@example.com \
-e SPOND_PASSWORD=your-password \
-e 'KIDS_CONFIG=[{"name":"Oliver","groups":["Team 2013"]}]' \
spond-mcp
```
### Environment Variables
| Variable | Required | Default | Description |
| ---------------- | -------- | ----------------------- | ------------------------------------------------- |
| `SPOND_USERNAME` | Yes | | Spond account email |
| `SPOND_PASSWORD` | Yes | | Spond account password |
| `KIDS_CONFIG` | No | `[]` | JSON array mapping kid names to Spond group names |
| `MCP_CALLERS_DIR` | Yes | | Directory of per-caller tokens (see below) |
| `PORT` | No | `8080` | Server port |
| `BASE_URL` | No | `http://localhost:8080` | Public URL for SSE endpoint construction |
### `KIDS_CONFIG` Format
Maps your children's first names to their Spond group names. Group matching is fuzzy — partial matches work (e.g. `"Team 2013"` matches `"Fjordvik Team 2013"`).
```json
[
{"name": "Oliver", "groups": ["Team 2013", "School 2014"]},
{"name": "Emma", "groups": ["Team 2017"]}
]
```
Without `KIDS_CONFIG`, the server still works but can't filter by kid or show per-kid attendance.
## Authentication
Per-caller bearer auth via `mcpauth.py` (mirror of github.com/starefossen/mcpauth). Tokens are files in `$MCP_CALLERS_DIR/read/<caller>`; the server refuses to start without them. Only the `Authorization: Bearer` header is accepted; `/health` is open. Each accepted request logs `caller=<name>`.
```bash
mkdir -p /tmp/callers/read && openssl rand -hex 24 > /tmp/callers/read/me
MCP_CALLERS_DIR=/tmp/callers SPOND_USERNAME=you@example.com SPOND_PASSWORD=pw python main.py
curl -H "Authorization: Bearer $(cat /tmp/callers/read/me)" http://localhost:8080/sse
```
In Kubernetes the callers are projected from Secret `mcp-auth-token` (see `config/knative-service.yaml`).
`GET /api/minside/today?kid=<name>` (RFC-011): one kid's Spond events for the next 24 hours as JSON for Min side: `heading`, `start`, `end`, `location`, `cancelled`, `answer`. Only events the kid is invited to, from the kid's groups in `KIDS_CONFIG`; 404 for an unknown kid. Group `minside` only (key `minside`, optional mount); the `read` group cannot call it and `minside` cannot call the MCP tools. Min side decides which kid a login may see; spond trusts the caller.
`GET /api/exercise/days?kid=<name>[&days=N]` (RFC-026 §12): minutes per Oslo day of ended, not cancelled events in the kid's `exercise_groups` (family.yaml `spond_exercise_groups`) that the kid said yes to, except headings with a `NOT_EXERCISE` word (møte, dugnad, …), N days back (1–14, default 2): `{"days":[{"day","minutes"}]}`. No names or places. Spond does not report attendance, so fleet stores these as unverified exercise. Group `exercise` only (key `fleet-spond`, optional mount).
`read/jwks.json` (ConfigMap `spond-jwks`, `config/spond-jwks.yaml`) also enables Kanidm JWTs, same rules as mcpauth v0.3.0: ES256 `at+jwt` only, `iss`/`aud`/`exp`/`nbf` with 60 s skew, required scope, and `callers` as a `sub` allowlist (unknown `sub` gets 401). The JWKS loads in the background over HTTPS without redirects, refreshes hourly and on an unknown `kid` at most once a minute. Static tokens are tried first and keep working while Kanidm is down.
## Login failures, password change and 2FA
The server logs in once per pod and logs in again when Spond answers 401. If
Spond rejects the login, the server stops trying for 15 minutes so it does not
lock the account. During that time every tool returns
"Innlogging mot Spond feilet (prøver igjen om N min)" without calling Spond, and
one alert goes to the ntfy drift topic (`NTFY_TOPIC`, from Secret
`mcp/ntfy-token` key `drift_topic`; create it once with
`cd apps/vigilo && mise run ntfy-secret`).
After changing the Spond password, or if login fails:
1. Log in at spond.com in a browser with the same account. If Spond asks for a
2FA code or a new password, finish that there. The server cannot answer 2FA
prompts; use an account without 2FA.
2. Update the Secret:
`kubectl -n mcp create secret generic spond-credentials --from-literal=username=... --from-literal=password=... --dry-run=client -o yaml | kubectl apply -f -`
3. Restart so the backoff is cleared: `mise run deploy` (new revision).
The server refuses to start without `SPOND_USERNAME` and `SPOND_PASSWORD`.
## Usage with mcporter
[mcporter](https://github.com/steipete/mcporter) can connect to this server as a remote MCP tool:
```bash
# List all groups
mcporter call spond.list_groups
# Get this week's events for a specific kid
mcporter call spond.get_upcoming_events kid_name=Oliver days=7
# Check what needs a response
mcporter call spond.get_attendance kid_name=Oliver
# Accept a match
mcporter call spond.respond_to_event event_id=ABC123 kid_name=Oliver accept=true
# Search for upcoming matches
mcporter call spond.search_events query=kamp days=30
```
For authenticated servers, configure mcporter with the Authorization header in `~/.mcporter/mcporter.json`:
```json
{
"mcpServers": {
"spond": {
"url": "https://your-spond-mcp.example.com/sse",
"transport": "sse",
"headers": {
"Authorization": "Bearer your-token-here"
}
}
}
}
```
## Architecture
```text
MCP Client (mcporter, Claude, etc.)
│ HTTP/SSE (JSON-RPC)
▼
spond-mcp (:8080)
│
└── api.spond.com (Spond API)
```
- Implements the [Model Context Protocol](https://modelcontextprotocol.io/) over HTTP+SSE
- Uses [mcp](https://pypi.org/project/mcp/) SDK with Starlette SSE transport
- Uses [spond](https://github.com/Olen/Spond) library for API access
- Stateless — all caching is in-memory with configurable TTLs
## Development
```bash
# Install dev dependencies
pip install -r requirements.txt -r requirements-dev.txt
# Run tests (164 tests, including auth middleware and JWT tests)
pytest -v
# Lint
ruff check .
```
## Homelab Deployment
This server is designed to run on Knative with scale-to-zero. See [knative-service.yaml](config/knative-service.yaml) and [.mise.toml](.mise.toml) for deployment tasks.
Callers are projected from Secret `mcp-auth-token` in the `mcp` namespace.
```bash
# Build and deploy (requires mise + Docker + kubectl)
mise run full-deploy
# Integration test against deployed service (auto-fetches auth token from K8s)
mise run test:mcp
```
## Data Source
- **Spond API** via [Olen/Spond](https://github.com/Olen/Spond) — unofficial Python wrapper for the Spond mobile app API
## License
MIT
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessOutdated data