Skip to content

Add push/pull/import/export MCP tools for AI agents#3022

Merged
youknowriad merged 1 commit intotrunkfrom
cli-push-pull-check
Apr 9, 2026
Merged

Add push/pull/import/export MCP tools for AI agents#3022
youknowriad merged 1 commit intotrunkfrom
cli-push-pull-check

Conversation

@youknowriad
Copy link
Copy Markdown
Contributor

Related issues

How AI was used in this PR

AI-assisted implementation. All code reviewed and validated by human.

Proposed Changes

  • Add 4 new MCP tools (site_push, site_pull, site_import, site_export) to the AI agent toolset, exposing the recently added CLI commands to AI agents
  • Make site_create and site_pull available in the remote site MCP context so agents can pull a WordPress.com site to a new local site
  • Update both local and remote system prompts to document the new tools
  • Improve needs-transfer error handling in sync-site-picker.ts to show an actionable message with a link to enable hosting features (matching the desktop app UX)

Testing Instructions

  • Build the CLI with npm run cli:build
  • Verify the MCP server registers the new tools: node apps/cli/dist/cli/main.mjs mcp (in non-TTY mode the server starts; in TTY mode it shows setup instructions)
  • Test that site_push / site_pull require authentication and a valid remote site
  • Test that site_import / site_export work with backup files
  • Verify a needs-transfer site shows the hosting features URL in the error message

Pre-merge Checklist

  • Have you checked for TypeScript, React or other console errors?

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@wpmobilebot
Copy link
Copy Markdown
Collaborator

📊 Performance Test Results

Comparing 7cad285 vs trunk

app-size

Metric trunk 7cad285 Diff Change
App Size (Mac) 1260.99 MB 1261.00 MB +0.00 MB ⚪ 0.0%

site-editor

Metric trunk 7cad285 Diff Change
load 1846 ms 1829 ms 17 ms ⚪ 0.0%

site-startup

Metric trunk 7cad285 Diff Change
siteCreation 8173 ms 9140 ms +967 ms 🔴 11.8%
siteStartup 4227 ms 4314 ms +87 ms 🔴 2.1%

Results are median values from multiple test runs.

Legend: 🟢 Improvement (faster) | 🔴 Regression (slower) | ⚪ No change (<50ms diff)

Copy link
Copy Markdown
Member

@sejas sejas left a comment

Choose a reason for hiding this comment

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

Thanks for adding the new sync tools to the MCP! ✨

I confirm I was able to push my site to https://staging-531d-sejasdotblog.wpcomstaging.com/

Image

And the Agent is aware of all the new tools:

Image

I'll create a follow-up issues to polish this flow. Currently the agent preferred to publish the website to a preview site and I had to enter the site url manually. I think we could make it easier for the user to pick or create a remote site.

Things we can improve in follow-ups:

Prefers to use preview sites Don't offer the list of remote sites
Image Image

@youknowriad youknowriad merged commit 83fbc14 into trunk Apr 9, 2026
10 checks passed
@youknowriad youknowriad deleted the cli-push-pull-check branch April 9, 2026 12:24
youknowriad added a commit that referenced this pull request Apr 9, 2026
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
sejas added a commit that referenced this pull request Apr 9, 2026
* [skip ci] Code freeze: Update translatable strings for 1.7.8

* [skip ci] Code freeze: Add draft release notes for 1.7.8

* Add push/pull/import/export MCP tools for AI agents (#3022)

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>

* Sort studio code commands and subcommands alphabetically (#3027)

* Moved the `code` command registration in `apps/cli/index.ts` so that top-level CLI commands appear in alphabetical order

* Strip unnecessary fields in wpcom_request response (#3005)

* Strip bloated plan.features from wpcom_request responses

The WP.com /sites/{id} endpoint returns a plan object whose features
sub-field alone is 60K+ characters, pushing the total response past
Claude Code's ~100K character MCP tool result limit. The agent only
needs product_slug, is_free, and expired to gate features, since the
system prompt hardcodes what each plan tier can and can't do. Strip
plan.features and keep only essential plan properties.

* Also compact large array responses by stripping content and _links

List endpoints like GET /templates can return 80K+ chars of block markup.
Strip content and _links from array items when the response exceeds 80K
chars — the agent can still identify items by slug/title and fetch
individual ones for full content.

* Add _fields prompt guidance and scope plan compaction as special case

Add system prompt hint instructing the agent to use _fields on wp/v2
listing endpoints to minimize response sizes. Scope compactResponse()
to only handle plan.features stripping with a clear comment that this
is a special case (the API doesn't support sub-field filtering). Remove
the generic array compaction in favor of prompt-driven field selection.

* Add fields guidance for v1.1, rename stripOversizedFields

Update system prompt to instruct the agent to use fields (v1.1) and
_fields (wp/v2) to minimize response sizes, always including ID for
v1.1 requests. Rename compactResponse to stripOversizedFields for
clarity.

* Remove indentation in JSON to save tokens

* Fix dark mode visibility for error/success text in site list (#3034)

* Fix dark mode onbiarding screen (#3025)

Co-authored-by: Kateryna Kodonenko <kateryna@automattic.com>

* Studio: Filter out deprecated warnings from fatal errors (#3018)

* Filter out deprecated warnings from fatal errors

* Ensure our error filtering approach is consistent with CLI

* Apply changes to default exporter

* Fix unit tests

---------

Co-authored-by: Kateryna Kodonenko <kateryna@automattic.com>

* [skip ci] Update translations

* [skip ci] Bump version to 1.7.8-beta1

* CLI: ensure Studio root exists before starting code agent (#3039)

* Ensure startAiAgent() checks whether ~/Studio exists before launching the Claude SDK.

* Define a localeData type to fix lint error: The inferred type of this
node exceeds the maximum length the compiler will serialize. An explicit
type annotation is needed. (ts 7056)

* [skip ci] Bump version to 1.7.8-beta2

---------

Co-authored-by: Riad Benguella <benguella@gmail.com>
Co-authored-by: Antonio Sejas <antonio.sejas@automattic.com>
Co-authored-by: Roberto Aranda <roberto.aranda@automattic.com>
Co-authored-by: Bernardo Cotrim <bmmcotrim@gmail.com>
Co-authored-by: katinthehatsite <katerynakodonenko@gmail.com>
Co-authored-by: Kateryna Kodonenko <kateryna@automattic.com>
Co-authored-by: Jorge Costa <jorge.costa@developer.pt>
Co-authored-by: Antonio Sejas <antonio@sejas.es>
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.

3 participants