Skip to content

MCP tools

lo mcp serves the operations of localspace to a coding agent through the Model Context Protocol. This page gives the facts about the server and all its tools. For the steps to turn it on and register it, see coding agents.

Item Value
Command lo mcp
Transport stdio. The agent starts lo mcp and talks to it on stdin and stdout.
Server name localspace
Default state Off. Turn it on in Settings › MCP of the dashboard, or set mcp: {enabled: true} in config.yaml.
If it is off lo mcp stops with a conflict error. A session that runs when you turn it off refuses each call.
Tool list The list is fixed when the session starts. A plugin that you install after that adds its tools to the next session.
Instructions The server sends a short guide to the client when it connects.

Each tool has an effect. The server sends the effect to the client as an MCP annotation. The client can use it to prompt you before a call.

Effect Meaning Annotation
reads The tool changes nothing. It lists, reads and measures. readOnlyHint
changes The tool changes state, but it does not lose data. destructiveHint: false
destroys The tool can delete data. destructiveHint: true

A tool of a plugin can have no effect. The server then sends no annotation, and MCP assumes that the tool can change and destroy anything.

Tool Effect Action Main arguments
workspaces reads Lists all workspaces with status, sources, services (with hostPort and publicUrl), resources and external parts. With workspace or dir, it gives one workspace. With stats, it gives the CPU (percent of one core) and memory (bytes) of the units that run. workspace or dir, stats
templates reads Lists the templates. With template, or dir for the .localspace.yaml of a repository, it checks it and starts nothing. The problems are in the report. template or dir
guide reads Gives the guide for agents as Markdown. topic template gives the guide to write a template. topic
new_workspace changes Makes a workspace from a template. It starts nothing. Call up next. name, template, picks, attrs, match, env, share, own, isolation
up changes Starts a workspace, or some of its services, and waits until each is ready. It refuses if the machine has too little free memory or disk. workspace or dir, services, anyway
down changes Stops the services of a workspace. It keeps the worktrees, the data and the ports. It refuses while a running service of a different workspace uses it, unless force is true. workspace or dir, services, force
restart changes Stops and starts the services again. workspace or dir, services
set changes Switches services or repositories of a workspace to other branches or checkouts, or a service or resource to a remote. It keeps the data and restarts the units that ran from them. It refuses if a worktree that it replaces holds unsaved work. workspace, picks, attrs
remove_workspace destroys Stops a workspace, drops its resources and worktrees, and forgets it. It refuses if a worktree that localspace made holds uncommitted or unpushed work. workspace
service reads Gives the resolved env of a service, with secrets masked. It also gives its source: branch, checkout path, unsaved work and latest commits. workspace, service, limit
logs reads Gives the last lines of the logs of the services and resources, unit by unit. With runs and one unit, it lists the logs of the earlier runs of that unit. With run, it reads one of them. workspace, units, tail, runs, run
exec destroys Runs a command in the directory of a service with its env, or in its container. workspace, service, command
checkout_plan reads Shows the effect of checkout, with the aliases that it takes and from which workspace. It changes nothing. workspace or dir, hosts
checkout changes Binds the canonical ports of the template to a workspace, and points its aliases (fixed host names) to the services of the workspace. The workspace that had them stops receiving them, and keeps running. With hosts, it moves only the aliases. With release, it stops the binding, frees the aliases and returns the ports and aliases that it freed. workspace or dir, hosts, release
db_reset destroys Makes a resource, such as a database, again from its seed. Its data is lost. workspace, resource

The arguments of a call are in a JSON object. The server checks them against the schema of the tool.

Argument Type Meaning
workspace string The name of the workspace.
dir string A directory in a git worktree of a repository with .localspace.yaml. It selects the workspace with the name of the branch. Use it when you give no workspace. For templates, it is a repository or its .localspace.yaml file. Give it in place of template.
services list of strings Only these services, and the units that they use. All services when the list is empty.
force boolean down only. Stop the workspace although a running service of a different workspace uses it. Use it only after the user agrees.
anyway boolean Start although the machine has less free memory or disk than the workspace uses on average. Use it only after the user agrees.
name string The name of the new workspace.
template string The name of the template.
topic string The guide to read. Empty gives the guide to use localspace. template gives the guide to write a template.
picks object A branch or a checkout path for each service or repository, or remote:<name> or a URL for a service or resource that runs elsewhere. new_workspace uses the default of the template for the others.
attrs object The attributes of the remote of a service or resource, for example {"booking": {"api_key": "..."}}. A value can be ${secret:path}.
match string A word. new_workspace selects the one branch of each repository that has the word in its name.
env object The value of a variable for a service, as {"service": {"KEY": "value"}}. It replaces the value of the template.
share list of strings The services that use a shared instance.
own list of strings The services that the template shares, but this workspace runs itself.
isolation object The isolation of a resource, as {"resource": "instance"} or {"resource": "database"}.
service string The name of the service.
resource string The name of the resource, such as a database.
units list of strings The services and resources to read. All when empty.
stats boolean workspaces only. Give the CPU and memory of the units that run, of workspace or of all workspaces.
runs boolean logs only. List the earlier runs of the one unit in units.
run string logs only. The ID of one earlier run of the one unit in units.
hosts boolean checkout and checkout_plan only. Move only the aliases, not the ports.
release boolean checkout only. Stop the binding of the canonical ports and free the aliases. Give no workspace with it.
tail integer The number of last lines to return. The default is 50 for each unit, and 200 for one earlier run.
limit integer The number of latest commits. The default is 10.
command list of strings The program and its arguments. The server does not run them through a shell.

A tool with workspace or dir in the table takes one of the two. If you give none, the tool returns invalid.

A tool returns the result as JSON text. An empty list is [].

  • up and restart send each step as a progress notification, if the client gives a progress token.
  • logs and exec remove color codes from the output.
  • exec returns exitCode, stdout and stderr. It keeps the last 32 KiB of each output. If it cuts the start, the output starts with [first <n> bytes cut].
  • exec gives the command an empty stdin.
  • workspaces with stats and workspace gives only the units of that workspace.

A failed call returns an error result, with the same JSON that lo --json prints:

{ "error": { "code": "not_found", "message": "..." } }

The codes are invalid, not_found, conflict and unavailable. See errors.

If up refuses because of the start guard, the code is conflict. The message tells the agent to get the decision of the user, and to call up again with anyway: true only if the user agrees.

A plugin can add tools. They have the same form as the tools above, and they show in the MCP section of the dashboard with the name of the plugin. A plugin cannot give a tool the name of a tool of lo. See write a plugin.