Skip to content

Add MCP tools to list, id-list, and delete source assets - #1096

Open
ehoogerbeets wants to merge 1 commit into
mcp-08-assetsfrom
mcp-09-assets-more
Open

ehoogerbeets wants to merge 1 commit into
mcp-08-assetsfrom
mcp-09-assets-more

Conversation

@ehoogerbeets

Copy link
Copy Markdown
Contributor

Transferred from ehoogerbeets#18 onto box/mojito (rebased onto master).

Stack note: this PR targets mcp-08-assets — merge bottom-up.

What an asset is

In Mojito, an asset is one source resource file inside a repository — the English (or other source-locale) file that contains the strings to translate. Typical examples are messages.properties, en.lproj/Localizable.strings, or res/values/strings.xml. Mojito identifies it by a logical path (the path stored in the TM, not necessarily a path on the agent's machine) that is unique within that repository.

It is not a localized copy (messages_fr-FR.properties), and it is not an individual string. Extraction splits the asset's content into text units (the rows translators see in the workbench). The previous PR in this stack (mojito_asset_import) uploads one of these files; this PR is how an agent lists what is already there and deletes one by id.

What this adds

Three MCP tools around existing source assets:

  • mojito_asset_list — summaries of the source files in a repository
  • mojito_asset_ids — the same query, but only numeric ids
  • mojito_asset_delete — remove one asset by id

Until now the only asset tool was import. An agent could push a file in, but could not answer “what source files does this Mojito repo already have?” or remove one that was uploaded by mistake.

What the underlying APIs do

GET /api/assets returns the full filtered set of asset summaries in one response (id, logical path, deleted/virtual flags, repository, last successful extraction, created-by). It is not paginated — same reason as repository list: do not pass --paginate. repositoryId is required. Optional filters:

  • path — exact logical path (e.g. src/main/resources/messages.properties)
  • deleted — true only deleted, false only live, omit both
  • virtual — true only virtual assets, false only real files, omit both
  • branchId — assets associated with that Mojito branch

There is no GET-by-id for a single asset. To resolve a path, filter list with that path. To go from an id back to a path, use list, not ids.

GET /api/assets/ids uses the same query fields and returns a flat list of numbers ([12, 13, …]). Cheaper when the caller already knows it only needs ids.

DELETE /api/assets/{assetId} deletes one asset. Successful empty CLI stdout maps to null. This is a single-id delete, not the bulk unused-asset cleanup CLI push uses (DELETE /api/assets with a body of ids). That bulk endpoint is intentionally not exposed: an agent deleting one file should not sweep the rest of the repository.

Why an agent would use them

Typical flow after import: list the repo to confirm the new path is there, or to pick which file to talk about when the user says “the properties file.” Use ids when you are about to delete and only need the number. Delete is for “remove this source file from Mojito” after confirming environment and id — prefer mojito-dev while experimenting.

Localize, bulk unused-asset cleanup, and XLIFF export stay out of this slice.

Test plan

  • cd mojito-mcp && pnpm test
  • cd mojito-mcp && pnpm run build

Made with Cursor

These cover GET /api/assets, GET /api/assets/ids, and DELETE /api/assets/{id} without the localize endpoints.

Co-authored-by: Cursor <cursoragent@cursor.com>

This branch has not been deployed

No deployments
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