Skip to content

Hypothesis MCP — Specification

Author: Claude Code for jmpicnic Date: 2026-03-23 Status: Draft

Build a minimal stdio MCP server in TypeScript that lets Claude Code agents read and write Hypothesis web annotations. Then integrate it into the Arda workspace (settings, documentation, authoring guides) so future sessions can use it out of the box.

  • Goal file: Simple Hypothesis MCP
  • Hypothesis is already used for documentation review — see the How to Comment on Documentation page.
  • The MCP server will live in workspace/tools/mcp/hypothesis/.
  • The 1Password item op://Private/Hypothesis-API/credential already exists for the project owner.
  1. MCP server implementation — TypeScript stdio server with 6 tools (adjusted for actual API).
  2. MCP registration — Add the server to workspace/instructions/claude/settings.json.
  3. Workspace docs — Add a Hypothesis section to workspace/mcp-setup.md.
  4. Authoring docs — Update or extend the documentation site’s About/Authoring section with AI-assisted annotation workflows.
  5. CI validation — All checks pass in both documentation/ and workspace/ before push.
  • Hypothesis browser extension setup (already covered in commenting.md).
  • GitHub Actions CI for the MCP server itself (no CI pipeline exists for workspace/tools/).
  • Real-time annotation streaming or WebSocket support.
  • Target selectors for create_annotation (per goal file).

The goal file specifies POST /api/bulk/annotation for get_group_annotations. This endpoint does not exist in the Hypothesis API. The corrected tool set:

ToolMethodActual EndpointNotes
get_groupsGET/api/groupsReturns user’s group memberships
search_annotationsGET/api/searchParams: group, uri, text, user, tag, limit, offset
get_annotationGET/api/annotations/{id}Full annotation detail
get_group_annotationsGET/api/search?group={pubid}Paginated search filtered by group (replaces non-existent bulk endpoint)
create_annotationPOST/api/annotationsMinimal payload — uri, text, group (default: arda-products), tags
update_annotationPATCH/api/annotations/{id}Partial update — text, tags

The get_group_annotations tool will paginate internally using search_after or offset to fetch up to the requested limit (default 200).

#TaskPhaseDepends OnAcceptance Criteria
T-1Scaffold project: package.json, tsconfig.json, ESLint flat config, Prettier, Vitest config1: MCP Servernpm install succeeds
T-2Implement src/types.ts — shared types (Annotation, API response shapes)1: MCP ServerT-1npm run typecheck passes
T-3Implement src/client.ts — Hypothesis API client (typed fetch wrapper)1: MCP ServerT-2Unit tests pass, correct URL construction
T-4Implement src/index.ts — MCP server setup and tool registration1: MCP ServerT-3npm run build produces working dist/index.js
T-5Write tests/client.test.ts — API client unit tests1: MCP ServerT-3All assertions pass with mocked fetch
T-6Write tests/tools.test.ts — Tool input validation and response mapping tests1: MCP ServerT-4All assertions pass
T-7Write README.md — Install, build, test, token setup, Claude Code config snippet1: MCP ServerT-4Contains all sections from goal file
T-8Set up simple-git-hooks + lint-staged1: MCP ServerT-1Pre-commit hook runs Prettier + ESLint on staged .ts files
T-9Run full validation: npm run build, npm run lint, npm test1: MCP ServerT-5, T-6, T-8Zero errors
T-10Add Hypothesis MCP to settings.json (mcpServers section)2: IntegrationT-9Valid JSON, uses op read for token
T-11Add Hypothesis section to workspace/mcp-setup.md2: IntegrationT-9Follows existing section format
T-12Create/update authoring doc: AI-assisted annotation workflows3: DocumentationT-9New page or updated commenting.md covering agent read/write of annotations
T-13Register new page in sidebar.json (if new file created)3: DocumentationT-12Page appears in sidebar under About
T-14Run documentation/ CI checks: make test3: DocumentationT-12, T-13Build + link checks + smoke tests pass
T-15Commit, push, create PRs for both repos4: ShipT-9, T-14PRs created against main

Two separate repositories are modified. Each gets its own worktree branched from main.

Worktree layout (at workspace root):

Worktree directoryBranchRepositoryTasks
hypothesis-mcp-worktrees/workspacejmpicnic/hypothesis-mcpworkspaceT-1 through T-11
hypothesis-mcp-worktrees/documentationjmpicnic/hypothesis-mcpdocumentationT-12 through T-14

Merge workflow: Each worktree pushes its branch directly. One PR per repository, both targeting main.

Agent absolute-path rule: All tool calls use absolute paths to the worktree directories.

Worktree: hypothesis-mcp-worktrees/workspace

Build the complete MCP server under tools/mcp/hypothesis/. Follow all constraints from the goal file:

  • No classes — plain functions only
  • src/ under 300 lines total
  • ESM ("type": "module")
  • node: protocol prefix on built-in imports
  • No any types
  • exactOptionalPropertyTypes: true

All code must compile, lint, and test before proceeding.

Phase 2: Workspace Integration (T-10 through T-11)

Section titled “Phase 2: Workspace Integration (T-10 through T-11)”

Same worktree as Phase 1.

  • Add the MCP server config to settings.json using the 1Password pattern.
  • Add a documentation section to mcp-setup.md following the established format (Purpose, Prerequisites, Configuration, Verification).
  • Include a note about first-session permission prompts and what each tool does.
  • Include instructions for creating the 1Password item for other users.

Phase 3: Documentation Site (T-12 through T-14)

Section titled “Phase 3: Documentation Site (T-12 through T-14)”

Worktree: hypothesis-mcp-worktrees/documentation

Create a new page about/authoring/using-hypothesis-with-agents.md covering:

  1. Commenting on published docs with AI — How an agent can use the MCP to search and read annotations on documentation pages, then create annotations with feedback or suggestions.
  2. Reading and responding to comments during authoring — How an agent working in the documentation/ repo can fetch annotations for the page being edited, address feedback in the source, and reply to or resolve annotation threads.
  3. Practical examples — Sample prompts a user might give Claude Code to trigger these workflows.
  4. Tool reference — Brief description of each MCP tool and what it returns.
  5. Setup prerequisites — Link to commenting.md for Hypothesis account setup, link to mcp-setup.md for MCP server setup, note about 1Password item creation.

Also update commenting.md to cross-link to the new agent page.

Register the new page in sidebar.json under about > Authoring.

Run make test in the documentation worktree.

  • Commit all changes in each worktree.
  • Push both branches.
  • Create PRs targeting main in each repo.
RiskLikelihoodImpactMitigation
Hypothesis API rate limiting during developmentLowLowAll tests mock fetch; no real API calls in CI
search_after pagination not availableMediumLowFall back to offset pagination
Documentation build breaks from new pageLowMediumRun make test before commit
#QuestionOptionsRecommendationDecision
1New page vs. extend commenting.md for agent workflows?A) New dedicated page; B) Add section to commenting.mdA) New page — keeps human and agent workflows separate, avoids bloating commenting.mdNew page using-hypothesis-with-agents.md
2Replace get_group_annotations tool entirely or keep as a convenience wrapper?A) Drop it, users just call search_annotations with group param; B) Keep as convenience wrapper with internal paginationB) Keep it — the paginated fetch-all pattern is useful and matches the original intentKeep as paginated wrapper
3How to handle pagination in get_group_annotations?A) offset param; B) search_after cursorA) offset — simpler, sufficient for expected dataset sizes (< 1000 annotations per group)Use offset pagination