Skip to content

feat: REST API parity with MCP tools — 30+ endpoints#46

Merged
howethomas merged 3 commits intomainfrom
feature/rest-api-parity
Apr 15, 2026
Merged

feat: REST API parity with MCP tools — 30+ endpoints#46
howethomas merged 3 commits intomainfrom
feature/rest-api-parity

Conversation

@howethomas
Copy link
Copy Markdown
Contributor

Summary

  • Expand REST API from 7 endpoints to 30+, achieving full parity with all MCP tools
  • Add supertest-based HTTP test coverage for every endpoint (62 new tests)
  • Fix stale documentation across 23 files (wrong versions, endpoint counts, missing REST references)

What changed

REST API (src/api/):

  • Refactored monolithic rest-router.ts into modular route files (routes/vcons.ts, tags.ts, search.ts, database.ts, analytics.ts, schema.ts)
  • New endpoints: PATCH vCons, sub-resource appending (dialog/analysis/attachments), tag CRUD, keyword/semantic/hybrid search, database ops, analytics, schema/examples
  • New shared utilities: context.ts, response.ts, validation.ts, middleware/pagination.ts

Business logic (src/services/):

  • Added VConService.update() with beforeUpdate/afterUpdate hook lifecycle (fixes existing MCP handler that bypassed VConService)

Shared utilities (src/utils/):

  • Extracted generateEmbedding() from MCP search handler to src/utils/embeddings.ts — used by both MCP and REST

Tests (tests/api/):

  • Test harness: helpers.ts with createTestApp(), mock factories for all 7 RestApiContext deps
  • 62 new supertest tests across 5 route test files
  • Total: 691 tests pass (42 files), up from 629 (37 files)

Docs (23 files):

  • Fixed vcon version 0.3.0→0.4.0 across 15 files
  • Fixed spec references draft-ietf-vcon-vcon-core-00→-02 across 12 files
  • Updated README endpoint table, CLAUDE.md file structure, architecture diagrams
  • Added missing REST env vars to .env.example
  • Fixed Python syntax error in rest-api.md example

Test plan

  • npm run build — clean TypeScript compilation
  • npm test — 691 tests pass (42 files)
  • All 62 new REST API tests pass via supertest with mocked dependencies
  • Existing 629 tests unchanged (no regressions)
  • Manual curl testing against live server with MCP_TRANSPORT=http

🤖 Generated with Claude Code

howethomas and others added 3 commits April 15, 2026 13:45
Expand the REST API from 7 basic CRUD endpoints to full parity with all
30 MCP tools. Developers can now choose between MCP (for AI assistants)
and REST (for scripts, web apps, integrations) with identical capabilities.

New endpoints:
- PATCH /vcons/:uuid — update metadata
- POST /vcons/:uuid/dialog, /analysis, /attachments — sub-resources
- GET/PUT/DELETE /vcons/:uuid/tags — per-vCon tag management
- GET /tags, /tags/search — tag discovery
- GET /vcons/search/content, /semantic, /hybrid — all search modes
- GET /database/shape, /stats, /size, /health — operational
- POST /database/analyze — query plan analysis
- GET /analytics, /growth, /content, /tags, /attachments — reporting
- GET /schema, /examples/:type — documentation

Architecture:
- Refactor monolithic rest-router.ts into modular route files
- Extract generateEmbedding() to shared src/utils/embeddings.ts
- Add VConService.update() with hook lifecycle (fixes MCP bypass)
- Extend RestApiContext with dbInspector, dbAnalytics, dbSizeAnalyzer
- Add response envelope helpers, validation utils, pagination middleware
- Add PATCH to CORS allowed methods, X-Total-Count header support

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add comprehensive HTTP-level test coverage for every REST route using
supertest with fully mocked dependencies (no database required).

Test files:
- tests/api/helpers.ts — test harness (createTestApp, mock factories, sample data)
- tests/api/routes/vcons.test.ts — CRUD + sub-resources (23 tests)
- tests/api/routes/tags.test.ts — tag management + discovery (11 tests)
- tests/api/routes/search.test.ts — content, semantic, hybrid search (9 tests)
- tests/api/routes/database.test.ts — DB ops + analytics (12 tests)
- tests/api/routes/schema.test.ts — health, version, schema, examples (7 tests)

Fixes:
- Fix Koa router prefix double-mounting for /database and /analytics routes
- Add supertest + @types/supertest to devDependencies

Total: 691 tests pass (42 files), up from 629 tests (37 files).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Documentation audit found 23 files with issues after REST API expansion.

Critical fixes:
- README.md: endpoint table updated from 6 to 30+ routes, tool count 27→30,
  curl examples fixed from vcon 0.3.0→0.4.0, REST description expanded
- CLAUDE.md: added src/api/ directory tree, Koa to tech list
- docs/api/index.md: REST component box updated, spec version -00→-02
- docs/development/architecture.md: added REST layer to diagram, fixed
  vcon version 0.3.0→0.4.0
- docs/development/testing.md: tool count 11→30, added REST test mention

Consistency fixes (23 files):
- All vcon version references: 0.3.0→0.4.0 across 15 doc files
- All spec references: draft-ietf-vcon-vcon-core-00→-02 across 12 files
- docs/api/rest-api.md: Python example fixed JS template literal syntax
- .env.example: added REST_API_BASE_PATH, REST_API_ENABLED, CORS_ORIGIN
- docs/reference/QUICK_REFERENCE.md: session_id type fixed to object,
  must_support renamed to critical
- docs/guide/getting-started.md: tool list expanded, REST API section added

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@howethomas howethomas merged commit 2d1e80a into main Apr 15, 2026
5 checks passed
@howethomas howethomas deleted the feature/rest-api-parity branch April 15, 2026 20:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant