refactor(commands): centralize MCP execution and list rendering#27
Merged
Conversation
added 5 commits
June 13, 2026 13:51
Signed-off-by: A365 CLI Maintainer <maintainer@example.com>
Signed-off-by: A365 CLI Maintainer <maintainer@example.com>
Signed-off-by: A365 CLI Maintainer <maintainer@example.com>
Signed-off-by: A365 CLI Maintainer <maintainer@example.com>
Signed-off-by: A365 CLI Maintainer <maintainer@example.com>
There was a problem hiding this comment.
Pull request overview
This PR centralizes the MCP command execution path and list rendering logic. Previously, every command handler repeated boilerplate for client creation, initialization, tool invocation, and content extraction. The new Context.CallToolData method encapsulates this sequence, while PrintListFromData consolidates the common pattern of extracting lists from response data with fallback keys and max-limit truncation.
Changes:
- Introduces
Context.CallToolData()inroot.goas a single execution seam (initialize → call → extract) and migrates all command handlers to use it - Adds
PrintListFromData/RowsFromDatain the output package to centralize list extraction with key fallback and max-limit logic - Aligns Word/Excel command arguments with live MCP schemas (
desiredFileName→fileName,driveId+documentId→urlfor get commands,text→newComment/content) and updates docs/tests accordingly
Show a summary per file
| File | Description |
|---|---|
| internal/commands/root.go | Adds CallToolData method centralizing MCP execution |
| internal/commands/root_test.go | Tests for CallToolData success and error paths |
| internal/output/formatter.go | Adds PrintListFromData, RowsFromData, appendDefaultKey |
| internal/output/formatter_test.go | Tests for new list extraction/rendering functions |
| internal/commands/word/word.go | Migrates to CallToolData, updates arg names for MCP schema |
| internal/commands/word/word_test.go | Updates test schemas to match new arg names |
| internal/commands/excel/excel.go | Migrates to CallToolData, updates arg names for MCP schema |
| internal/commands/excel/excel_test.go | Updates test schemas to match new arg names |
| internal/commands/teams/*.go | Migrates all Teams handlers to CallToolData + PrintListFromData |
| internal/commands/calendar/calendar.go | Migrates all Calendar handlers to CallToolData + PrintListFromData |
| internal/commands/mail/mail.go | Migrates all Mail handlers to CallToolData + PrintListFromData |
| internal/commands/planner/planner.go | Migrates all Planner handlers to CallToolData + PrintListFromData |
| internal/commands/sharepoint/sharepoint.go | Migrates all SharePoint handlers to CallToolData |
| internal/commands/splists/splists.go | Migrates all SP Lists handlers to CallToolData |
| internal/commands/onedriveremote/onedriveremote.go | Migrates all OneDrive Remote handlers to CallToolData |
| internal/commands/copilot/copilot.go | Migrates callCopilot retry loop to use CallToolData |
| internal/commands/copilot/agents.go | Migrates fetchAvailableAgents to CallToolData |
| internal/commands/me/me.go | Migrates Me handlers to CallToolData + PrintListFromData |
| internal/commands/websearch/websearch.go | Migrates to CallToolData |
| internal/commands/nlweb/nlweb.go | Migrates to CallToolData |
| internal/commands/knowledge/knowledge.go | Migrates to CallToolData |
| internal/commands/triggers/triggers.go | Migrates to CallToolData |
| internal/commands/dasearch/dasearch.go | Migrates to CallToolData |
| internal/commands/admin/admin.go | Migrates to CallToolData |
| internal/commands/admin365/admin365.go | Migrates to CallToolData |
| internal/commands/api/api.go | Migrates to CallToolData |
| docs/word.md | Updates docs for new Word command args |
| docs/excel.md | Updates docs for new Excel command args |
| docs/architecture.md | Documents new output pipeline with CallToolData |
| CONTRIBUTING.md | Updates command implementation example |
| AGENTS.md | Updates command template and key conventions |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 34/34 changed files
- Comments generated: 0
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Context.CallToolDataNewMCPClient/Initialize/CallTool/ExtractContentboilerplatePrintListFromDataWhy
The previous command modules repeated the same shallow MCP execution sequence at each call site. This made transport/extraction changes broad and error-prone. The new command execution seam improves locality by keeping initialize, tool invocation, extraction, and action-scoped errors in one module while command handlers own only argument construction and rendering.
Validation
make buildgo test ./... -count=1go vet ./...golangci-lint run ./...api serversapi call websearch SearchWebcopilot agentsme search __a365_refactor_smoke_no_user__