Skip to content

refactor: break up index.ts into focused modules #516

Description

@vrajpal-jhala

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:

  1. Extract startup/transport code (most self-contained)
  2. Extract middleware
  3. 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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions