Skip to content

refactor(mcp): plugin registry + AgentMarkPlugin contract - #22

Merged
rrader26 merged 1 commit into
mainfrom
refactor/mcp-plugin-registry
May 12, 2026
Merged

refactor(mcp): plugin registry + AgentMarkPlugin contract#22
rrader26 merged 1 commit into
mainfrom
refactor/mcp-plugin-registry

Conversation

@rrader26

Copy link
Copy Markdown
Contributor

Summary

  • Introduce AgentMarkPlugin contract and Dispatcher registry class.
  • Carve web / pdf / desktop / meta capabilities into plugin factories.
  • dispatcher.ts / tool-defs.ts / server.ts become thin shims over the registry; legacy functional API (dispatch, createDispatcherState, disposeAll, ALL_TOOLS) is preserved unchanged.
  • createMcpServer({ plugins?: AgentMarkPlugin[] }) now accepts a custom plugin set.

Why

Foundation for the Microsoft Workflows Pack (and Insurance, etc.) — external packs need a first-class registration API, not a special-cased extra case in the dispatcher switch. Going with the registry refactor rather than a bolt-on so future packs are first-class.

What stayed identical

  • Every existing test passes unchanged (317 prior + 9 new plugin-contract tests = 326 passing).
  • All public exports (functional API + types) keep their names and call signatures.
  • Tool names and behavior are byte-identical — the wire format is unchanged.

Test plan

  • pnpm build clean
  • pnpm test — 326 pass, 10 skip (same skip set as main)
  • Manual: spawn agentmark-mcp from a fresh Claude Code session on Windows VM, run agentmark_desktop_list_targets, confirm same window enumeration as before refactor
  • Manual: same on macOS against TextEdit

New public API

From @thinkfleet/agentmark (or the /mcp subpath):

  • AgentMarkPlugin, ToolHandler, DispatchResult — author surface
  • Dispatcher — registry/router class
  • createWebPlugin, createPdfPlugin, createDesktopPlugin, createMetaPlugin — first-party factories

Example pack:
```ts
import { type AgentMarkPlugin } from '@thinkfleet/agentmark'

export function createMicrosoftPlugin(opts): AgentMarkPlugin {
return {
name: 'microsoft',
tools: [/* MS-specific tool defs /],
handlers: { /
keyed by tool name / },
dispose: async () => { /
cleanup */ },
}
}
```

🤖 Generated with Claude Code

Replace the monolithic switch-based dispatcher with a plugin registry so
external packs (Microsoft Workflows, Insurance, etc.) can register MCP
tools using the same API as built-in capabilities. First-party features
(web, pdf, desktop, meta) are extracted into plugin factories that the
default dispatcher composes automatically.

The public functional API (`dispatch`, `createDispatcherState`,
`disposeAll`, `DispatcherState`, `ALL_TOOLS`, `createMcpServer`) is
preserved as a thin shim over the new `Dispatcher` class. No test
changes were required; all 317 prior tests + 9 new plugin-contract
tests pass.

New public exports (from '@thinkfleet/agentmark' or its '/mcp' subpath):
- `AgentMarkPlugin`, `ToolHandler`, `DispatchResult` — plugin types
- `Dispatcher` — the registry/router class
- `createWebPlugin`, `createPdfPlugin`, `createDesktopPlugin`,
  `createMetaPlugin` — factories so packs can compose their own server

Server now accepts `plugins?: AgentMarkPlugin[]` to override the default
set; tools are sourced from the registry rather than a static array.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@rrader26
rrader26 merged commit 922fc01 into main May 12, 2026
4 checks passed
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