mirror of
https://github.com/kuhyx/todo-app.git
synced 2026-11-10 18:07:03 +01:00
New standalone Python package under mcp/ that exposes the todo app's exported BACKLOG.md (NotesMarkdown format) as read-only MCP tools, so Claude Code and its subagents can query the backlog. The app is Dart/Flutter with no Python and no CLI; this server reads BACKLOG.md and never touches the sqlite_crdt DB (CRDT writes would corrupt cross-device merge). - todo_mcp/_backlog.py: pure parse_backlog(text) -> list[Note]. - todo_mcp/_mcp.py: FastMCP stdio server. Read-only tools list_backlog, get_note, backlog_stats; every result carries the file mtime so a stale export is visible; missing file returns a graceful "export it" message. Logs to stderr; no writes; no secrets (backlog is note text). - .mcp.json registers it via a dedicated ~/.venvs/todo-mcp interpreter. - 100% coverage; verified end-to-end over stdio; parses the real BACKLOG.md. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LQGQj8Ne6TriBExv91nG8v
42 lines
1.4 KiB
Bash
Executable File
42 lines
1.4 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# ============================================================================
|
|
# Set up the dedicated virtualenv that hosts the todo backlog MCP server.
|
|
# Claude Code spawns this interpreter (see the repo-root .mcp.json) to run
|
|
# `python -m todo_mcp._mcp` over stdio.
|
|
#
|
|
# The MCP SDK (`mcp`) and the `todo_mcp` package live ONLY in this venv — the
|
|
# todo app itself is Dart/Flutter and has no Python, so this is fully separate.
|
|
# Both `mcp` and `todo_mcp` must be importable by this one interpreter or the
|
|
# MCP server fails to start silently.
|
|
#
|
|
# Idempotent: safe to re-run to pick up dependency changes.
|
|
# ============================================================================
|
|
|
|
set -euo pipefail
|
|
|
|
readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
readonly PKG_DIR="$(cd "${SCRIPT_DIR}/.." && pwd)"
|
|
readonly VENV_DIR="${HOME}/.venvs/todo-mcp"
|
|
|
|
main() {
|
|
echo "== Setting up MCP venv at ${VENV_DIR} =="
|
|
|
|
if [[ ! -d "${VENV_DIR}" ]]; then
|
|
python3 -m venv "${VENV_DIR}"
|
|
fi
|
|
|
|
"${VENV_DIR}/bin/pip" install --quiet --upgrade pip
|
|
"${VENV_DIR}/bin/pip" install --quiet -e "${PKG_DIR}"
|
|
|
|
echo "== Verifying imports =="
|
|
"${VENV_DIR}/bin/python" -c \
|
|
"import mcp, todo_mcp; print('mcp + todo_mcp import OK')"
|
|
|
|
echo
|
|
echo "Done. The server is registered via $(cd "${PKG_DIR}/.." && pwd)/.mcp.json"
|
|
echo "Restart Claude Code in this repo and approve the project MCP server prompt."
|
|
}
|
|
|
|
main "$@"
|