Skip to content

feat: expose structured MCP command tools#593

Merged
thymikee merged 32 commits into
mainfrom
feat/semantic-mcp-tools
May 28, 2026
Merged

feat: expose structured MCP command tools#593
thymikee merged 32 commits into
mainfrom
feat/semantic-mcp-tools

Conversation

@thymikee
Copy link
Copy Markdown
Member

@thymikee thymikee commented May 26, 2026

Summary

Expose agent-device mcp as a first-class structured tool server instead of discovery-only metadata. CLI, MCP, and the Node client now share command contracts; CLI grammar only reads positional/flag input, while command projection owns typed input to daemon request projection for the Node client and batch execution.

Batch is structured at every public interface: MCP and client.batch.run() use { command, input, runtime? } steps, and CLI batch --steps now prefers the same shape. Existing CLI positionals/flags batch files still run through a CLI-only compatibility normalizer with a deprecation warning; that legacy shape is documented for removal in the next major version.

Review hardening: MCP JSON-RPC batches and separate stdio request payloads execute serially, fallback MCP infrastructure errors preserve the request id when available, MCP stateDir is stripped before command validation, hybrid batch step shapes are rejected, structured input accepts target as a device-form alias only where it cannot conflict with UI targeting, Maestro replay backend projection now works for both replay.run and replay.test, and the MCP session tool preserves common request options such as daemonBaseUrl.

Deletes the old command codec/request helpers, legacy CommandDefinition metadata, MCP catalog placeholder, and thin dedicated CLI wrapper modules that only delegated into shared execution. CLI help/schema code is split into focused modules, command schemas derive from the command surface, capability decisions stay in capabilities, and MCP tools are generated from command contracts.

Updates agent setup docs with copy-paste Cursor and Claude paths for CLI-only and MCP workflows, plus MCP isError: true tool-result handling guidance.

Current branch diff is +7,819 / -5,446 against origin/main after rebasing on latest main. Touched-file count: 104. Scope is the CLI/MCP/Node interface layer; daemon architecture and platform handlers are preserved.

Validation

Ran pnpm format, pnpm check:quick, pnpm build, pnpm check:fallow --base origin/main, pnpm exec vitest run src/__tests__/client.test.ts, and focused Vitest coverage for the command-interface surface: pnpm exec vitest run src/__tests__/cli-grammar.test.ts src/__tests__/cli-batch.test.ts src/__tests__/client.test.ts src/mcp/__tests__/command-tools.test.ts src/mcp/__tests__/router.test.ts src/utils/__tests__/args.test.ts.

For the CI regression, ran pnpm test:integration:provider and the previously failing file directly: pnpm exec vitest run test/integration/provider-scenarios/android-test-suite.test.ts --project provider-integration. Also attempted full pnpm test:coverage; local execution still hit unrelated iOS unit-test timing/mock interference in src/platforms/ios/__tests__/index.test.ts, after the provider Maestro suite passed.

MCP e2e was verified at the stdio boundary with the built bin/agent-device.mjs mcp: sent initialize, notifications/initialized, tools/list, ping, and tools/call against a loopback daemon-compatible HTTP endpoint. The server returned 46 tools and routed the session tool to daemon command session_list with structured content { sessions: [] }.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 26, 2026

PR Preview Action v1.8.1

QR code for preview link

🚀 View preview at
https://callstackincubator.github.io/agent-device/pr-preview/pr-593/

Built to branch gh-pages at 2026-05-28 06:14 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cb650cfeba

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/commands/semantic-common.ts Outdated
Comment on lines +160 to +163
return compactRecord({
...commandOptions,
...commonToClientOptions(readCommonInput(record)),
}) as TOptions;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Preserve element target when deviceTarget is present

readClientOptions currently spreads commonToClientOptions after command-specific fields, and commonToClientOptions maps deviceTarget onto target. For commands that also use a semantic element target object (notably get/longpress), providing deviceTarget overwrites that object with a string, so downstream target conversion throws (Expected target to be an object). This is a behavioral regression for requests that select both a device form and an element target.

Useful? React with 👍 / 👎.

Comment thread src/mcp/server.ts Outdated

async function handleMcpBatch(messages: JsonRpcMessage[]): Promise<JsonRpcResponse[] | null> {
const responses = (
await Promise.all(messages.map(async (message) => await handleMcpMessage(message)))
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Process JSON-RPC batch messages in order

Using Promise.all here executes all batch entries concurrently, which makes dependent mutating requests race each other (for example, open and then click in one JSON-RPC batch can run out of order and fail with no active session). The previous implementation handled batch entries serially, and this parallelization changes MCP into a concurrent execution path for stateful session commands.

Useful? React with 👍 / 👎.

@thymikee thymikee changed the title feat: expose semantic MCP tools feat: expose structured MCP command tools May 27, 2026
@thymikee thymikee force-pushed the feat/semantic-mcp-tools branch from 72f65bb to 118999c Compare May 27, 2026 18:23
@thymikee thymikee force-pushed the feat/semantic-mcp-tools branch from ef20069 to 1f6136f Compare May 27, 2026 19:55
@thymikee thymikee merged commit 819d7dc into main May 28, 2026
19 checks passed
@thymikee thymikee deleted the feat/semantic-mcp-tools branch May 28, 2026 07: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.

1 participant