Skip to content

copilot-plugin: let Copilot run TypeAgent actions directly over MCP - #2973

Open
George Ng (GeorgeNgMsft) wants to merge 1 commit into
mainfrom
georgengmsft-copilot-direct-actions
Open

copilot-plugin: let Copilot run TypeAgent actions directly over MCP#2973
George Ng (GeorgeNgMsft) wants to merge 1 commit into
mainfrom
georgengmsft-copilot-direct-actions

Conversation

@GeorgeNgMsft

Copy link
Copy Markdown
Contributor

What this does

Copilot CLI's TypeAgent plugin could only talk to TypeAgent in one way: send natural language to typeagent-processCommand and let TypeAgent figure out what to do. That costs an LLM translation call on every request — even when Copilot already knows exactly which action it wants to run.

This adds a direct path. Two new tools on the plugin's typeagent MCP server:

  • typeagent-discoverActions — asks what this session can actually run: the enabled agents, their actions with descriptions, and the TypeScript parameter contract for a specific action.
  • typeagent-executeAction — runs one action by schemaName / actionName / parameters. The dispatcher validates it against its schema and executes it. No translation, no reasoning.

typeagent-processCommand is unchanged and remains the path for conversational requests, multi-step work, and anything with a learn: / dev: / record: prefix. The guidance the plugin injects now tells the model to prefer the direct path only when it already knows the action, and not to re-discover on every turn.

Highlights

  • Shared protocol, no copy-paste. commandExecutor already had its own discovery/execution tools. Rather than duplicating them, the narrow common piece (command building, active-schema filtering, action lookup) moved into @typeagent/dispatcher-types/helpers/actionDispatch, which both MCP servers already depend on. commandExecutor now uses it too.
  • Two bugs fixed in commandExecutor as a result. Its enabled-schema filter worked per top-level agent instead of per sub-schema, and a naturalLanguage phrase containing an apostrophe was mangled by the command tokenizer.
  • Discovery now matches what will actually run. The dispatcher's status active flag is true when either an agent's actions or its commands are enabled, but @action only runs when the actions are. A new actionActive field reports the real thing, so discovery can't advertise an action that would then be refused. Older agent servers that don't report it fall back to the old flag.
  • Honest results. Cancellation is checked before output, so partial output from a cancelled request is labelled rather than returned as success. An already-aborted tool call never submits side-effecting work. And when an agent asks a follow-up question this MCP client can't answer, the tool says so instead of implying the action completed.
  • Injection-safe. Schema and action names are validated before they reach the command line.

Validation

  • pnpm run build dispatcher-types dispatcher copilot-plugin command-executor-mcp — succeeded
  • @typeagent/copilot-plugin: 12 suites, 85 tests passing
  • command-executor-mcp: 4 tests passing
  • Prettier applied; lint, complexity, circular-dependency, and tech-debt ratchets all pass with no regressions

New tests cover the MCP catalog exposing the tools from the real bundled server, discovery filtering by enabled schema, direct execution emitting the @action path rather than translation, injection rejection, cancellation, structured-content forwarding, and unchanged behavior in dev/bypass/processCommand modes.

The plugin's MCP mode could only send natural language to
typeagent-processCommand, so every request paid for TypeAgent
translation even when the caller already knew exactly which typed
action to run.

Add two tools to the agent MCP server: typeagent-discoverActions
reports the agents, actions and TypeScript contracts the session
currently has enabled, and typeagent-executeAction runs one of them
through the dispatcher's @action command, skipping translation and
reasoning. typeagent-processCommand is unchanged and remains the path
for conversational requests and for learn:/dev:/record: directives.

The discovery and command-building protocol both MCP servers need now
lives in @typeagent/dispatcher-types/helpers/actionDispatch, and
command-executor uses it too. That fixes two bugs there: active
filtering now works per sub-schema instead of per top-level agent, and
a naturalLanguage phrase containing an apostrophe is no longer mangled
by the command tokenizer.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
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.

1 participant