Overview
index.ts is currently 12,800+ lines and serves as a monolith containing tool handlers, OAuth/session middleware, startup logic, config validation, download token handling, and MCP server setup. It's navigable only by grep and every PR risks merge conflicts on it.
This issue tracks breaking it into focused, maintainable modules. Feedback welcome on scope and priorities before work begins.
Proposed structure
server.ts - startup, transport initialization, runServer()
middleware/ - auth, rate limiting, session management
tools/ - one file per tool category (partially started with tools/registry.ts)
index.ts - thin entrypoint that wires everything together
oauth.ts already exists but much OAuth middleware is still in index.ts
Suggested approach
Carve out one slice at a time to avoid a giant high-conflict PR:
- Extract startup/transport code (most self-contained)
- Extract middleware
- Extract tool handlers by category
I can start working on this but I'm looking for more inputs. What other areas of the codebase should be targeted in this cleanup?
Overview
index.tsis currently 12,800+ lines and serves as a monolith containing tool handlers, OAuth/session middleware, startup logic, config validation, download token handling, and MCP server setup. It's navigable only by grep and every PR risks merge conflicts on it.This issue tracks breaking it into focused, maintainable modules. Feedback welcome on scope and priorities before work begins.
Proposed structure
server.ts- startup, transport initialization,runServer()middleware/- auth, rate limiting, session managementtools/- one file per tool category (partially started withtools/registry.ts)index.ts- thin entrypoint that wires everything togetheroauth.tsalready exists but much OAuth middleware is still inindex.tsSuggested approach
Carve out one slice at a time to avoid a giant high-conflict PR:
I can start working on this but I'm looking for more inputs. What other areas of the codebase should be targeted in this cleanup?