Stu Mason
Stu Mason

Activity

Issue Opened

Issue #81 opened: refactor: eliminate `as any` type assertions in MCP tool handlers

Problem

The MCP tool handlers in mcp-server.ts use as any type assertions when passing arguments to client methods. This bypasses TypeScript's type checking and was the root cause of Issue #76 (action field leaking to API).

Current State

Multiple places in mcp-server.ts use patterns like:

return wrap(() => this.client.createApplicationPublic(apiData as any));

Proposed Solution

  1. Use proper type guards - Validate fields are present before calling client methods
  2. Use discriminated unions - The action parameter already discriminates, leverage this
  3. Method overloads or generics - Make client methods accept properly typed inputs

Benefits

  • Compile-time safety prevents field leakage bugs like #76
  • Better IDE autocomplete and error messages
  • Self-documenting code

Affected Areas

  • application tool handler (create_public, create_github, create_key, create_dockerimage)
  • service tool handler (create)
  • github_apps tool handler (create) - already partially fixed with explicit field passing

Priority

Low - the immediate bug (#76) is fixed by stripping MCP-internal fields. This is a refactor for long-term code quality.


Filed for future improvement when tokens are plentiful ๐Ÿช™