feat: add ask_chatgpt tool handler
This commit is contained in:
+21
-2
@@ -7,13 +7,13 @@ ChatGPT MCP Server
|
||||
## Status
|
||||
|
||||
Planning complete.
|
||||
Phase 0 complete. Phase 1 complete. Phase 2 complete. Phase 3 complete.
|
||||
Phase 0 complete. Phase 1 complete. Phase 2 complete. Phase 3 complete. Task 4.1 complete.
|
||||
|
||||
## Current Phase
|
||||
|
||||
Phase 4 - Tool Handlers
|
||||
|
||||
## Completed Tasks (Phase 3 Complete)
|
||||
## Completed Tasks
|
||||
|
||||
- Task 0.1 — Create repository skeleton ✅
|
||||
- Task 0.2 — package.json with dependencies ✅
|
||||
@@ -31,6 +31,7 @@ Phase 4 - Tool Handlers
|
||||
- Task 3.5 — review_code prompt builder (`src/prompts/review-code.js`, `test/prompts/review-code.test.js`) ✅
|
||||
- Task 3.6 — debug_issue prompt builder (`src/prompts/debug-issue.js`, `test/prompts/debug-issue.test.js`) ✅
|
||||
- Task 3.7 — architecture_review prompt builder (`src/prompts/architecture-review.js`, `test/prompts/architecture-review.test.js`) ✅
|
||||
- Task 4.1 — ask_chatgpt MCP tool handler (`src/tools/ask-chatgpt.js`, `test/tools/ask-chatgpt.test.js`) ✅
|
||||
|
||||
## Phase 3 Completion Summary
|
||||
|
||||
@@ -53,3 +54,21 @@ Phase 3 — Tool Inputs and Prompts — is now complete.
|
||||
**Not done yet (belongs to Phase 4):**
|
||||
- No MCP tool registration.
|
||||
- No tool handlers.
|
||||
|
||||
## Completed Tasks (Phase 4)
|
||||
|
||||
### Task 4.1 — ask_chatgpt MCP Tool Handler ✅
|
||||
|
||||
Implemented `src/tools/ask-chatgpt.js` with dependency-injected handler and 27 orchestration-only tests in `test/tools/ask-chatgpt.test.js`.
|
||||
|
||||
**Key design decisions:**
|
||||
- Execution order: validate → loadConfig → checkContextBudget → buildAskChatGptPrompt → createOpenAIClient → sendOpenAIResponse
|
||||
- All external deps injected (loadConfig, createOpenAIClient, sendOpenAIResponse); internal utilities imported directly
|
||||
- OpenAI errors pass through `String(err)` unchanged — no wrapping or reformatting
|
||||
- Budget check short-circuits before prompt building or client creation
|
||||
- Every path returns structured `{ ok, answer|error, warnings }` — never throws to caller
|
||||
- 27 tests covering: success path, validation failure, config failure, budget failure, client creation failure, OpenAI failure, dependency call order, error handling for null/string throws, warning propagation, result shape, and short-circuit behavior
|
||||
|
||||
**Not done yet (Phase 4):**
|
||||
- No MCP tool registration
|
||||
- Other tool handlers (review_plan, review_code, debug_issue, architecture_review)
|
||||
|
||||
Reference in New Issue
Block a user