You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Refactor: extract typed internal API clients for MCP tools #494
Refactor: extract typed internal API clients for MCP tools
Why
Many MCP tools are thin HTTP clients + formatting with hardcoded paths. This duplicates URL construction, error mapping, and response validation across tools.
Why needed: Ensure clean separation before adding new abstraction layer
Assessment: The dependency chain needs to be resolved first. This refactor would be significantly easier after those structural improvements are in place.
All MCP tools use async with get_client() as client:
Clean dependency injection via factory pattern
This provides a solid foundation for the proposed API client abstraction
Alignment:
The project follows a "repository pattern for data access" (CLAUDE.md line 58), and the proposed API clients would extend this pattern to the MCP tool layer.
Activity
claude commentedon Dec 31, 2025
Claude finished @phernandez's task in 2m 1s —— View job
Issue Triage Complete
Triage Analysis
Issue Classification:
Current State Assessment
I've examined the MCP tools codebase and identified the following patterns:
Duplication Found:
/v2/projects/{project_id}/resource/{entity_id}manuallyresolve_entity_id()function inutils.pyis shared, but project/entity lookup patterns are duplicatedExample from
read_note.py(lines 103-117):Example from
recent_activity.py(lines 254-258):Proposed Architecture
The issue proposes introducing typed internal API clients:
This would centralize:
Dependency Status
This refactor depends on:
Issue Refactor: explicit config injection (only roots read ConfigManager) #496 - Explicit config injection (only roots read ConfigManager)
Issue Refactor: introduce ProjectResolver and unify project selection across MCP/API/CLI #493 - Introduce ProjectResolver and unify project selection
Issue Refactor: reduce coupling + centralize cloud_mode/config wiring #490 - Reduce coupling + centralize cloud_mode/config wiring
Assessment: The dependency chain needs to be resolved first. This refactor would be significantly easier after those structural improvements are in place.
Related Work
Already Complete:
async with get_client() as client:Alignment:
The project follows a "repository pattern for data access" (CLAUDE.md line 58), and the proposed API clients would extend this pattern to the MCP tool layer.
Recommendations
1. Implementation Sequence:
2. Design Considerations:
call_get/call_postpattern fromtools/utils.py3. Coverage Strategy:
4. Migration Risk:
Labels Applied
enhancement- Technical improvement to existing functionalityNote: Attempted to add component-specific labels, but they don't exist in this repository yet.
Next Steps
For project maintainers:
mcp,technical-debt,complex)For implementation:
refactor: introduce typed internal API clients for MCP tools (#494)