Skip to content

refactor(commands): centralize MCP execution and list rendering#27

Merged
sozercan merged 5 commits into
mainfrom
refactor/command-output-seams
Jun 14, 2026
Merged

refactor(commands): centralize MCP execution and list rendering#27
sozercan merged 5 commits into
mainfrom
refactor/command-output-seams

Conversation

@sozercan

Copy link
Copy Markdown
Owner

Summary

  • centralize MCP command execution behind Context.CallToolData
  • migrate command handlers away from direct NewMCPClient / Initialize / CallTool / ExtractContent boilerplate
  • centralize standard list response extraction and fallback rendering with PrintListFromData
  • align Word and Excel command arguments with live MCP schemas and update docs/tests

Why

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 build
  • go test ./... -count=1
  • go vet ./...
  • golangci-lint run ./...
  • live/read-only or dry-run smoke checks after each significant step:
    • api servers
    • api call websearch SearchWeb
    • copilot agents
    • me search __a365_refactor_smoke_no_user__
    • Word/Excel create dry-runs with live schema validation
  • structured autoreview clean after each significant step

A365 CLI Maintainer 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>
Copilot AI review requested due to automatic review settings June 14, 2026 01:28

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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() in root.go as a single execution seam (initialize → call → extract) and migrates all command handlers to use it
  • Adds PrintListFromData / RowsFromData in the output package to centralize list extraction with key fallback and max-limit logic
  • Aligns Word/Excel command arguments with live MCP schemas (desiredFileNamefileName, driveId+documentIdurl for get commands, textnewComment/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

@sozercan sozercan merged commit 1bc9da2 into main Jun 14, 2026
9 checks passed
@sozercan sozercan deleted the refactor/command-output-seams branch June 14, 2026 02:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants