Add create_site and list_service_versions MCP tools - #80
Merged
Merged
Conversation
added 2 commits
September 1, 2026 15:01
Create a new WordPress site in Local through cradle.addSite, the same service Local's own Add Site flow drives. Provisioning plus the WordPress install takes minutes, well past most MCP clients' request timeout, so create_site returns as soon as Local registers the site and reports pending: true. AddSiteService registers the site with SiteData synchronously before its first await, so the new ID is available immediately. Callers poll site_status until it reports running, or pass wait: true to block. Because nothing awaits the creation promise once the tool returns, a later provisioning failure would otherwise vanish into a Local dialog. Record it and surface it as a creationError field on site_status. list_service_versions reports the PHP, database, and web server versions create_site accepts, flagging which are installed versus downloaded on demand. Local does not expose its preferred versions to add-ons, so the result explains that omitting a service option lets Local choose, and create_site reports what the site actually got. With enableAgentTools, the finished site is handed to the existing setupSite() so it registers with the MCP server and gets its MCP config and context files, as clicking Enable in the UI does. New site details are derived and validated in src/helpers/new-site.ts, porting Local's site nicename formatting and the checks from its renderer side validate-site-info into pure functions that return an error string instead of showing a dialog. The credential check in tests/security.test.ts guards against leaking an existing site's credentials. create_site sets credentials for a site that does not exist yet, so exempt it by name and assert the exemption list stays accurate.
…ion, and finish create_site docs
Contributor
|
Thanks Ivan. Both tools go through Local's own
I also checked the two Local internals against a running install. Lint, format, typecheck, 147 tests, and build pass locally. I will merge once CI is green. |
Coverage Report
File Coverage
|
||||||||||||||||||||||||||||||||||||||||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Tools
create_sitelist_service_versionsNotes
AddSiteServiceregisters the site with
SiteDatasynchronously before its firstawait, so the tool returns the new ID withpending: true; callers pollsite_statusuntilrunning, or passwait: trueto block.a Local dialog. It's recorded and exposed as
creationErroronsite_status.enableAgentToolshands the finished site to the existingsetupSite(), same as clicking Enable in the UI.agentspicks which (default["claude"]).src/helpers/new-site.tsports Local's nicename formatting and the checks from its renderer-sidevalidate-site-infointo pure functionsreturning an error string instead of showing a dialog.
tests/security.test.tsguards against leaking an existing site's credentials;create_sitesets credentials for a site that doesn't exist yet, so it's exempt by name, with a test asserting the exemption list stays accurate.Known limitations
/etc/hostsand the OS prompts for admin credentials — creation isnever fully unattended.
list_service_versionsreturns anotesaying omission lets Local choose;create_sitereports what the site actually got.