Skip to content

feat: move from mcp to cli#20

Merged
cryptotavares merged 36 commits intomainfrom
cryptotavares/AIENG-59-move-to-cli
Apr 21, 2026
Merged

feat: move from mcp to cli#20
cryptotavares merged 36 commits intomainfrom
cryptotavares/AIENG-59-move-to-cli

Conversation

@cryptotavares
Copy link
Copy Markdown
Collaborator

@cryptotavares cryptotavares commented Apr 16, 2026

What

Decomposes the monolithic src/mcp-server/ module into a focused, layered architecture, introduces a standalone CLI entry point (mm), and adds several new tool capabilities including observation compaction, text extraction, and launch-time context selection.

Why

The original mcp-server/ directory mixed HTTP server concerns, tool implementations, validation logic, utilities, and knowledge-store code in a single flat namespace. This made it difficult to reason about boundaries, test in isolation, or reuse components independently (e.g., running tools outside the MCP server context). The new structure enforces clear dependency directions and enables the CLI to consume tools directly without going through the HTTP layer.

How

Architectural restructure — modules extracted from src/mcp-server/ into:

Module Responsibility
src/server/ HTTP server, daemon state, port allocation, request queue, session management, observation compaction
src/tools/ All tool implementations, type definitions, registry, utilities
src/knowledge-store/ Knowledge store and tokenization
src/validation/ Schema validation
src/utils/ Shared logger, errors, time utilities
src/cli/ New mm CLI entry point

New features:

  • Category-based observation filtering — Tools are classified as mutating, readonly, discovery, or batch. Mutating tools always include post-execution observations; readonly/discovery omit them; run_steps respects a new includeObservations parameter (all | none | failures)
  • Observation compaction — Post-mutation observations are compacted before being returned: <select> options are collapsed, and a diff-based mode compares the current page state against a baseline to emit only the changed elements when the diff is smaller than the full snapshot. A size guard prevents emitting diffs larger than the full observation.
  • get_text tool — New tool for reading the text content of a DOM element by ref
  • --context launch flag — Launch accepts a --context parameter for pre-session environment selection, allowing consumers to select which context/environment to initialize before the session starts
  • Active tab trackingdescribe_screen now includes active tab information in its output; ExtensionState gains an activeTab field
  • Post-mutation state recheck — After mutations that land on an unknown screen, the server rechecks the page state to provide an accurate observation
  • within scopingclick, type, and wait_for tools accept a within parameter to scope element resolution to a subtree
  • Discovery enrichment — Structural roles, a11y attribute enrichment, and node collapsing in the discovery layer
  • Batch improvementsrun_steps gains batch-level timeout, tool aliases, and ref shorthand
  • Animation settling — Post-mutation observations now wait for animations to settle before capturing state
  • CLI (mm) — Full CLI with --within flag, --context flag, observations output, and get_text / launch / describe_screen commands

Refactors:

  • Consumer contextFactory now owns sub-service port allocation (removes hardcoded { anvil, fixture, mock } sub-ports, introduces PortMap type and allocatePort() utility). contextFactory takes no arguments, supports sync/async return, and its return shape is validated at runtime.
  • Package version read from package.json at runtime instead of a manually-synced src/version.ts
  • KnowledgeStore is now injectable via ServerConfig instead of being instantiated internally

Test coverage — Comprehensive tests for all new modules, contextFactory error paths, batch/launch/screenshot/seeding/discovery/navigate schemas, observation compaction (option collapsing, diff-based, activeTab passthrough), cross-platform error code handling, and CLI commands. Coverage thresholds updated accordingly.

…ry point

Restructure monolithic src/mcp-server/ into focused modules:
- src/server/: HTTP server, daemon state, port allocation, request queue
- src/tools/: all tool implementations and type definitions
- src/knowledge-store/: knowledge store and tokenization
- src/validation/: schema validation
- src/utils/: shared logger, errors, time utilities
- src/cli/: new CLI entry point (mm)

Add SKILL.md and update package.json, README, and vitest config.
Tools are now classified into categories (mutating, readonly, discovery,
batch) that control whether post-execution observations appear in HTTP
responses. Mutating tools always include observations, readonly and
discovery tools omit them, and batch (run_steps) respects the new
includeObservations parameter ('all', 'none', 'failures').
… constant

Remove src/version.ts which required manual sync with package.json.
All version consumers now import directly from package.json,
with ts-bridge handling the JSON import for both CJS and ESM outputs.
@socket-security
Copy link
Copy Markdown

socket-security Bot commented Apr 16, 2026

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Added@​types/​express@​5.0.61001007185100
Addedcosmiconfig@​9.0.19910010085100

View full report

Comment thread src/cli/mm.ts
...(body === null ? {} : { body: JSON.stringify(body) }),
};
const response = await fetch(
`http://127.0.0.1:${port}${requestPath}`,
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This is fine as the http server is just a wrapper for a local running deamon. Meaning that the http server is only running locally.

…tory

- Remove ContextFactoryOptions; contextFactory now takes no arguments
- Support sync and async contextFactory return values
- Add PortMap type and optional allocatedPorts to WorkflowContext
- Validate contextFactory return shape at runtime (config.environment, allocatedPorts)
- Add startup error handling with cleanup rollback on post-contextFactory failures
- Replace hardcoded { anvil, fixture, mock } subPorts with consumer-defined PortMap
- Export allocatePort() utility for consumer convenience
- Update DaemonState.subPorts to use PortMap
- Add comprehensive tests for contextFactory error paths and /status port reporting
- Add edge-case test coverage for batch, launch, screenshot, seeding, discovery, and navigate schema
- Update coverage thresholds to reflect new test additions
unlink on a directory returns EISDIR on Linux but EPERM on macOS,
causing CI (Ubuntu) to fail. Accept both error codes in the assertion
and lower coverage thresholds to account for platform instrumentation
differences.
@cryptotavares cryptotavares marked this pull request as ready for review April 20, 2026 09:55
@cryptotavares cryptotavares requested a review from a team as a code owner April 20, 2026 09:55
@cryptotavares cryptotavares merged commit eca3ecf into main Apr 21, 2026
25 checks passed
@cryptotavares cryptotavares deleted the cryptotavares/AIENG-59-move-to-cli branch April 21, 2026 10:33
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.

4 participants