Skip to content

refactor: consolidate MCP tools from 40 to 25#98

Merged
jcanizalez merged 2 commits intomainfrom
refactor/mcp-consolidate-tools
Mar 26, 2026
Merged

refactor: consolidate MCP tools from 40 to 25#98
jcanizalez merged 2 commits intomainfrom
refactor/mcp-consolidate-tools

Conversation

@jcanizalez
Copy link
Copy Markdown
Owner

Summary

  • Remove 9 git tools — agents have native git access, these were just wrappers
  • Merge 3 session list tools into list_sessions with filter param (active/recent/archived)
  • Merge launch_agent + launch_headless into launch_session with headless param
  • Merge kill_session + kill_headless into kill_session with headless param
  • Merge 2 workflow run list tools into list_workflow_runs with optional task_id filter
  • Merge 2 scheduler tools into get_workflow_schedule with info param (log/next_run)
  • Fix write_to_terminal to auto-append \r so input is actually submitted

Bundle size: 82KB → 68KB

Closes #93

Test plan

  • Build succeeds
  • All 25 tools register and return valid JSON schemas
  • Lint + prettier pass

- Remove 9 git tools (agents have native git access)
- Merge list_sessions + list_recent_sessions + list_archived_sessions
  into list_sessions with filter param
- Merge launch_agent + launch_headless into launch_session with
  headless param
- Merge kill_session + kill_headless into kill_session with headless
  param
- Merge list_workflow_runs + list_workflow_runs_by_task into
  list_workflow_runs with optional task_id filter
- Merge get_scheduler_log + get_next_scheduled_run into
  get_workflow_schedule with info param
- Fix write_to_terminal to auto-append carriage return

Closes #93
Copilot AI review requested due to automatic review settings March 26, 2026 01:11
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Refactors the MCP tool surface area by removing redundant git-wrapper tools and consolidating several session/workflow tools into fewer, more flexible endpoints, reducing context/tool schema overhead for agents.

Changes:

  • Consolidates workflow run listing into list_workflow_runs with optional workflow_id/task_id filters.
  • Consolidates scheduler tools into get_workflow_schedule with an info selector (log/next_run).
  • Consolidates session listing/launch/kill tools and updates write_to_terminal to append \r.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
packages/mcp/src/tools/workflows.ts Merges workflow run listing + scheduler tools into consolidated APIs.
packages/mcp/src/tools/sessions.ts Merges session list/launch/kill tools and tweaks terminal input behavior.
packages/mcp/src/tools/git.ts Removes MCP git wrapper tools entirely.
packages/mcp/src/server.ts Stops registering git tools after their removal.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +263 to +270
if (args.task_id) {
const runs = listWorkflowRunsByTask(args.task_id, args.limit ?? 20)
return { content: [{ type: 'text', text: JSON.stringify(runs, null, 2) }] }
}
if (args.workflow_id) {
const runs = listWorkflowRuns(args.workflow_id, args.limit ?? 20)
return { content: [{ type: 'text', text: JSON.stringify(runs, null, 2) }] }
}
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

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

list_workflow_runs accepts both workflow_id and task_id, but the handler silently prioritizes task_id when both are provided. This makes the API ambiguous and can return unexpected results. Consider returning an error when both filters are set (or define a clear precedence and document/enforce it).

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Fixed — now returns an explicit error when both workflow_id and task_id are provided.

Comment on lines +170 to +172
// Append carriage return so the terminal submits the input
const data = args.data.endsWith('\r') ? args.data : args.data + '\r'
await rpcNotify('terminal:write', { id: args.id, data })
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

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

Appending \r only when the input doesn't end with \r can produce \n\r when callers already include a newline (common when sending command strings ending in \n), potentially causing an extra/blank submission. Consider treating both \r and \n as “already terminated” (or normalizing to a single line ending) before appending.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Fixed — now strips trailing \r and \n before appending a single \r, so 'text\n' becomes 'text\r' instead of 'text\n\r'.

- Reject when both workflow_id and task_id are provided in list_workflow_runs
- Normalize trailing \r\n before appending \r in write_to_terminal
@jcanizalez jcanizalez merged commit bc5e680 into main Mar 26, 2026
1 check passed
@jcanizalez jcanizalez deleted the refactor/mcp-consolidate-tools branch March 26, 2026 15:19
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.

RFC: Consolidate MCP tools into resource domains to prevent tool sprawl

2 participants