qfield-mcp

v0.3.0
qfield-mcp Checked 1 day ago Published 5 days ago

MCP server driving a real QField app, for agents exploring and testing plugins

These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.

start_device

Start a QField with its own profile and display. :param version: QField release, `latest` for the newest. Without it the server's `$QFIELD_APP_BINARY` runs if set, else 4.2.9 :param plugin_dir: Plugin to load with its root reachable as `plugin` :param project: Project file to open after start :param grant_project_plugin: Answer the project plugin permission prompt :param settings: QSettings written before start, `{"myplugin/key": 1}`

ParameterTypeDescription
grant_project_pluginboolean
namestring
plugin_dir
project
settings
version

stop_device

Stop a QField and remove it from the running devices.

ParameterTypeDescription
namestring

list_devices

Names of the running devices.

reload_plugin

Load the hosted plugin again from its directory, edits included.

ParameterTypeDescription
devicestring

eval_js

Run a JS function body in QField and return its JSON result. The body sees `iface`, `find` (iface.findItemByObjectName), `findItem` (search by objectName in the scene, popups and the hosted plugin), `search`, `walk`, `walkAll`, `scene`, `state` (kept between calls), `plugin`, `qgisProject`, `layerObserver`, `pluginManager`, `settings`, `platformUtilities`, `messageLogModel`, `featureHistory`, `flatLayerTree`, `trackingModel`, `LayerUtils`, `GeometryUtils`, `FeatureUtils`, `StringUtils` and `Theme`. Use `return` to get a value back. QML exposes less of the QGIS API than PyQGIS. `qgisProject.m…

ParameterTypeDescription
code *string
devicestring

item_tree

List items on screen as an indented tree. Each line has type, #objectName, text, icon, [clickable], @x,y window position and size. Positions are tap targets. :param root: objectName of the item to start from, the whole window by default :param named_only: Only list items with an objectName or text :param clickable_only: Only list items that react to taps

ParameterTypeDescription
clickable_onlyboolean
devicestring
max_depthinteger
max_itemsinteger
named_onlyboolean
root
visible_onlyboolean

find_items

Find visible items whose objectName, text or icon contains `query`. Case is ignored, and items are listed one per line as in item_tree.

ParameterTypeDescription
query *string
clickable_onlyboolean
devicestring
max_itemsinteger

wait_for

Wait until a JS function body returns something truthy, or text shows. With `text`, waits until an item with the text is visible. :param gone: Wait for the text to disappear instead

ParameterTypeDescription
devicestring
goneboolean
js
text
timeoutnumber

screenshot

Take a PNG of the window, or of one item. Refused while a camera is open. :param scale: Size factor, 0.5 gives a quarter of the pixels

ParameterTypeDescription
devicestring
object_name
scalenumber

messages

Newest messages of QField's message log, what iface.logMessage writes.

ParameterTypeDescription
devicestring
lastinteger
tag

log

QField's stdout and stderr since the previous call.

ParameterTypeDescription
devicestring

tap

Tap an item by objectName or visible text, or a window position.

ParameterTypeDescription
devicestring
long_pressboolean
object_name
text
x
y

tap_map

Tap the map where a project CRS coordinate is drawn.

ParameterTypeDescription
x *number
y *number
devicestring
long_pressboolean

frame_map

Show the map around a project CRS coordinate.

ParameterTypeDescription
x *number
y *number
devicestring
half_sizenumber

type_text

Type into whatever has keyboard focus, tap a field first.

ParameterTypeDescription
text *string
devicestring

key

Press one key by keysym name: Return, Escape, BackSpace, Tab.

ParameterTypeDescription
name *string
devicestring

open_project

Open a project file.

ParameterTypeDescription
path *string
devicestring
grant_project_pluginboolean

set_position

Feed a GNSS fix at a project CRS coordinate through a fake receiver. The accuracies are in metres. fix_quality is how the receiver computed the fix: rtk (centimetres), float_rtk (decimetres), dgps (below a metre), gps (metres) or no_fix, which QField receives but shows no position for.

ParameterTypeDescription
x *number
y *number
devicestring
fix_qualitystring
horizontal_accuracynumber
vertical_accuracynumber

features

Attribute values of a layer's features, filtered by a QGIS expression.

ParameterTypeDescription
fields *array
layer *string
devicestring
expressionstring

open_feature_form

Open the form of the first feature matching a QGIS expression.

ParameterTypeDescription
expression *string
layer *string
devicestring
editboolean

set_field

Change a field of the open feature form through its editor widget. Works on the form of an existing feature and on the form of a feature that digitizing just added, whichever is open. :param label: The field's alias, its name when it has none

ParameterTypeDescription
label *string
value *
devicestring

save_form

Save the open feature form, a digitized feature's form too.

ParameterTypeDescription
devicestring

close_feature_form

Close the feature form and list without saving.

ParameterTypeDescription
devicestring

delete_feature

Delete the first feature matching a QGIS expression, as a user would. Opens its form, taps the form menu, `Delete Feature` and `OK`.

ParameterTypeDescription
expression *string
layer *string
devicestring

set_active_layer

Make a layer the one that digitizing adds features to.

ParameterTypeDescription
layer *string
devicestring

digitize_point

Add a point by tapping the map in digitize mode, fill one field and save. The point must be on screen, use frame_map first. To fill several fields, switch to digitize mode with eval_js, use tap_map, set_field and save_form. :param x: Project CRS coordinate :param label: The field to fill, its alias, its name when it has none

ParameterTypeDescription
label *string
layer *string
value *
x *number
y *number
devicestring

add_feature

Add a feature and commit it, as plugin JS does, without any form. :param wkt: Geometry in the layer's CRS, `Point (385000 6672000)` :param attributes: Values by field name

ParameterTypeDescription
attributes *object
layer *string
devicestring
wkt

change_geometry

Replace the geometry of the first feature matching an expression and save. :param wkt: New geometry in the layer's CRS

ParameterTypeDescription
expression *string
layer *string
wkt *string
devicestring

cloud_up

Start a local QFieldCloud of a release and return its URL. The first start of a release builds images, which takes many minutes. To use a stack that already runs, see cloud_attach. :param ref: `hosted` (what app.qfield.cloud runs), `latest` or a tag. Without it the server's `$QFIELDCLOUD_SOURCE_DIR` checkout runs if set, else hosted :param port_offset: Move every port and the compose project up by this much, so stacks of parallel checkouts do not collide. Without it `$QFIELDCLOUD_PORT_OFFSET` or 0 :param name: Compose project name instead of the one derived from the release

ParameterTypeDescription
name
port_offset
ref

cloud_attach

Use a local QFieldCloud that already runs, without building or starting it. Give what cloud_up was given, or the compose project `name` and `https_port` of a stack some other run started, such as an e2e run's. Use it after the server restarted too, the stack keeps running meanwhile. The admin tools and cloud_login then use this stack.

ParameterTypeDescription
https_port
name
port_offset
ref

cloud_status

Show the local QFieldCloud the cloud tools use, its URL and if it answers.

cloud_user

Create a user on the local QFieldCloud, or leave an existing one alone. Give each device a user of its own, a login ends the user's other sessions.

ParameterTypeDescription
password *string
username *string
superuserboolean

cloud_create_project

Create a project on the local QFieldCloud and return its id. With `directory` the project's files go up and the project is packaged, which is what a device needs to download it. :param directory: A QField project directory to upload :param collaborators: Usernames added as editors, they must exist :param username: Owner of the project, the admin by default

ParameterTypeDescription
name *string
collaborators
directory
password
username

cloud_add_collaborator

Give a user a role on a project of the local QFieldCloud. :param role: `reader`, `reporter`, `editor`, `manager` or `admin` :param username: A user who may manage the project, the admin by default

ParameterTypeDescription
collaborator *string
project_id *string
password
rolestring
username

cloud_upload

Upload a project directory to the local QFieldCloud, and package it. :param package: Run the package job devices download from

ParameterTypeDescription
directory *string
project_id *string
packageboolean
password
username

cloud_package

Run the package job of a project and wait for it to finish.

ParameterTypeDescription
project_id *string
password
username

cloud_deltas

Deltas a project received, with their status, such as `STATUS_APPLIED`.

ParameterTypeDescription
project_id *string
password
username

cloud_login

Log a device in to a QFieldCloud. :param url: Without it the stack of cloud_up or cloud_attach

ParameterTypeDescription
devicestring
password
url
username

cloud_download

Download a cloud project the device's user can see, and open it. :param grant_project_plugin: Answer the project plugin permission prompt while opening

ParameterTypeDescription
project_id *string
devicestring
grant_project_pluginboolean
open_itboolean

cloud_synchronize

Push local edits and download the latest state, as Synchronize does.

ParameterTypeDescription
project_id *string
devicestring