Skip to content

artifactr.connect

Connected apps, behind the connect extra: uv add "artifactr-ai[connect]" (ADR-0085, the guide).

Connected apps: an operator's own FreeCAD or Blender, through its vetted MCP server (ADR-0085).

The operator runs the app, a desktop window or a headless instance they trust, with its community server's add-on; the runner spawns the server on stdio for each call, on the same machine, and the agent gets the app's tools: its reads and edits while connect:<app> is on, and, opt-in at every level and approved by a person on every call, its code and network tools. Nothing here opens a file for anyone: a file the operator saves is uploaded as a native file, and scanned.

LOOPBACK module-attribute

LOOPBACK: Final = frozenset({'127.0.0.1', '::1'})

The hosts an app is reached on without remote=True: loopback's addresses, not a name that a resolver could answer otherwise.

PER_HOUR module-attribute

PER_HOUR: Final = 30

How many code and network calls each workspace may run in an hour, by default.

RETRY_AFTER module-attribute

RETRY_AFTER: Final = 30.0

The seconds a failed listing is remembered before the server is asked again.

TAILNET module-attribute

TAILNET: Final = (
    ipaddress.ip_network("100.64.0.0/10"),
    ipaddress.ip_network("fd7a:115c:a1e0::/48"),
)

The addresses a tailnet gives its machines: a remote host is one of these, or a .ts.net name.

PerHour module-attribute

PerHour = Callable[[str, str], Awaitable[int]]

The application's limit of a workspace's code and network calls in an hour, by its tenant and its id.

ToolsFor module-attribute

ToolsFor = Callable[[str, str], Awaitable[frozenset[str]]]

Which of an app's tools a workspace offers, by its tenant and its id.

BLENDER module-attribute

BLENDER: Final = ConnectedServer(
    app="blender",
    title="Blender",
    source="https://github.com/ahujasid/blender-mcp",
    version="mcp-for-blender==2.2.2",
    reported_version="1.30.0",
    tools=MappingProxyType(
        {
            "get_scene_info": Vetted(
                "read",
                "b18eb1eebf7972d27ad9aa600fabbe692496095beac26a9f52a5fe650baba156",
            ),
            "get_addon_status": Vetted(
                "read",
                "65e6378d1dbb792dcd83097fd7ff4fd97b37a3828769f34d0bd55bf56fdd5680",
            ),
            "look": Vetted(
                "read",
                "ca94c06a85727714a0c0b5a6c30acb06e9176e94212cae55504b2691a38b1e44",
            ),
            "execute_blender_code": Vetted(
                "code",
                "94e43ecf9f7d861ee709cb5b5ba8bf58dde25e0420985ebf8fd04477b8efa784",
            ),
            "search_assets": Vetted(
                "network",
                "ecc65dae1a069d4bd00eeb30d0965f90486e5b49fa9be3e8f3b3b96937493fbf",
            ),
            "import_asset": Vetted(
                "network",
                "71f00a7edc8934ee3c186bd3c199d664765d6ce3794a669c3abbbd7789def5de",
            ),
            "generate_3d": Vetted(
                "network",
                "da28f6bd8f9a6004277bdc9f99f9fc5ce093197e080012c326140a47b91746c7",
            ),
            "disable_telemetry": Vetted(
                "host",
                "fb9daf4cb5fe5945e843e7fe462f8e354db0b127e273f3129f026e2c29e5d810",
            ),
            "record_trajectory_feedback": Vetted(
                "host",
                "43aaa752d42c245ab57f3ecbcb562d377fa2549fcaa5aa41c6147cf976895ce7",
            ),
        }
    ),
    code=MappingProxyType({"execute_blender_code": "code"}),
    reaches=MappingProxyType(
        {
            "search_assets": ("source", _LIBRARIES, None),
            "import_asset": ("source", _LIBRARIES, None),
            "generate_3d": (
                "provider",
                _GENERATORS,
                _IMAGE,
            ),
        }
    ),
    env=MappingProxyType({"DISABLE_TELEMETRY": "true"}),
    ports=True,
)

ahujasid's Blender server: an add-on's socket in Blender, on port 9876, with no token, sending no telemetry.

FREECAD module-attribute

FREECAD: Final = ConnectedServer(
    app="freecad",
    title="FreeCAD",
    source="https://github.com/neka-nat/freecad-mcp",
    version="freecad-mcp==0.1.27",
    reported_version="",
    tools=MappingProxyType(
        {
            "list_documents": Vetted(
                "read",
                "7063c78dcd515bbcd51703bd321792872200fa8a2a21d764af0c029e0780c951",
            ),
            "get_objects": Vetted(
                "read",
                "4c2c83c279817d926dc4f0cd2df2ef506f3d1016d2fbcc32116159a1be661026",
            ),
            "get_object": Vetted(
                "read",
                "64314e6b2afca29596cc9b12d39396d9249e71f8879b5e12417fce05d0718a5b",
            ),
            "get_parts_list": Vetted(
                "read",
                "7255537e2c0d06926882f97bf6afa3be7818711e4f4858e5c3457a2927a5bdac",
            ),
            "get_view": Vetted(
                "read",
                "dc7c99aa6729c34018ab259a395b8511dbe85ad7213e203abbebd981a28c5a06",
            ),
            "get_rpc_status": Vetted(
                "read",
                "3b517f7367fe79fc0fe025e3521075ff0abe00d81d085c9da8d25d8381f8a713",
            ),
            "get_async_status": Vetted(
                "read",
                "ab00bd59279ceeccefaa8cdf1756af20af73b8f0d93a0d1ec76e93b428ff6962",
            ),
            "create_document": Vetted(
                "edit",
                "e14a671226faa889ab939083e6462cd645090b3b317ed5f6712d97a4b7104c00",
            ),
            "create_object": Vetted(
                "edit",
                "a214acc079fc7f78dc5c2a30fdd380093a8957f812859b1db4e32eeccea1f936",
            ),
            "edit_object": Vetted(
                "edit",
                "55ecb3a330350db2046bd1c0182b3af9335ef92911d4a60ed65be2e365f2c868",
            ),
            "delete_object": Vetted(
                "edit",
                "d9e8b0296af4a958932ebcdd1fdc4028211bc8dc00ece0b2161ff8d7442dc9fd",
            ),
            "execute_code": Vetted(
                "code",
                "a1817e33675e73a449a0d78d45237e0e74ea4daba669cb8494d80ef056182e20",
            ),
            "execute_code_async": Vetted(
                "code",
                "1d120340936308e02c815ff497a0cbb42336b15c7e7eb745af44fda27bb22d6e",
            ),
            "execute_code_headless": Vetted(
                "host",
                "f54beef639c40dfa213d4565d09a84b1d8dfa78317f41358c95fb7c385b92cf5",
            ),
            "reload_document": Vetted(
                "host",
                "d6b38dc6375e621f12c8e4a8eb1bb1150162ca0ca46ff401da0172ebfbcb776c",
            ),
            "insert_part_from_library": Vetted(
                "host",
                "0c9adfd8243c3100d07e6b9e47097d627c8066b10e9649f2d6d0f7a9a2c50d74",
            ),
            "run_fem_analysis": Vetted(
                "host",
                "9eb4b96f5bd71b3dacf378cb23d3d745646bd54afc8da0047b9a2c0956bffb66",
            ),
        }
    ),
    code=MappingProxyType(
        {
            "execute_code": "code",
            "execute_code_async": "code",
        }
    ),
    properties=MappingProxyType(
        {
            "create_object": "obj_properties",
            "edit_object": "obj_properties",
        }
    ),
    token="FREECAD_MCP_TOKEN",
)

neka-nat's FreeCAD server: an add-on's XML-RPC server in FreeCAD's window, on port 9875.

PROTECTED module-attribute

PROTECTED: Final[frozenset[Risk]] = frozenset(
    {"code", "network"}
)

The risks offered only when the operator allows the tool, the workspace's code key is on and the person holds the action, and run only once a person who holds it approves the call.

TIERS module-attribute

TIERS: Final[Mapping[Risk, Tier | None]] = MappingProxyType(
    {
        "read": "read",
        "edit": "write",
        "code": "run_code",
        "network": "outbound",
        "host": None,
    }
)

Each risk's capability tier (lattice RFC-0011): a read tool reads, an edit tool writes, a code tool runs code, and a network tool reaches outside the deployment. A host tool has no tier, since it is never offered (artifactr ADR-0099).

UNSET module-attribute

UNSET: Final = frozenset({'ExpressionEngine', 'Proxy'})

Properties no edit sets by name: an expression is code FreeCAD evaluates, and a proxy is an object's Python.

Risk module-attribute

Risk = Literal['read', 'edit', 'code', 'network', 'host']

What a tool does, and so when it is offered.

CALLED module-attribute

CALLED: Final = 'artifactr.connect.called'

The app_event a code or network call records in its workspace's log as it runs, which the hourly limit counts.

CODE_BYTES module-attribute

CODE_BYTES: Final = 64 * 1024

The most code one call may carry, checked before anyone is asked to approve it.

DESCRIPTION_CHARS module-attribute

DESCRIPTION_CHARS: Final = 1000

The most of a tool's description, which is the server's words, the model is given.

IMAGE_BYTES module-attribute

IMAGE_BYTES: Final = 2 * 1024 * 1024

The largest image of a reply the model is given, and the most all of a reply's images may hold together; past it, an image is left out, with a note.

IMAGES module-attribute

IMAGES: Final = {
    "image/png": b"\x89PNG\r\n\x1a\n",
    "image/jpeg": b"\xff\xd8\xff",
}

The images the model is given, by their media type and the bytes each starts with.

PARTS module-attribute

PARTS: Final = 32

The most parts of a reply that are read; the rest are left out, with a note.

REPLY_CHARS module-attribute

REPLY_CHARS: Final = 16000

The most of a reply's text the model is given.

RUN_CODE module-attribute

RUN_CODE: Final = 'artifactr:run_connected_code'

The action a person holds for the agent acting for them to run code in a connected app.

AppLock

Bases: Protocol

What calls to one app take turns by: a lock for each app, by its server and address.

held

held(
    key: str, *, wait: float
) -> AbstractAsyncContextManager[None]

Hold the key's lock, waiting for whoever holds it for at most wait seconds.

Raises:

Type Description
TimeoutError

If it wasn't taken within wait.

Connection

Connection(
    server: ConnectedServer,
    *,
    command: Sequence[str],
    host: str = "127.0.0.1",
    port: int | None = None,
    remote: bool = False,
    secrets: Sequence[str] = (),
    allow: Sequence[str] = (),
    unauthenticated: bool = False,
    scan: Literal["warn", "block"] = "warn",
    deadline: float = 30.0,
    approval_ttl: float = 15 * 60,
    lock: AppLock = PROCESS,
    per_hour: int | PerHour = PER_HOUR,
    offer: Sequence[str] | None = None,
    workspace_tools: ToolsFor | None = None,
)

How the runner reaches an operator's app: its vetted server, started on stdio.

Parameters:

Name Type Description Default
server ConnectedServer

The vetted server.

required
command Sequence[str]

How to start the server, installed ahead at the entry's release, so nothing is fetched within a call's deadline: the installed command, such as ("/opt/connected/freecad/bin/freecad-mcp",). lattice doesn't verify the install; it refuses a server that says it is another version.

required
host str

The app's address, which the server is given as --host.

'127.0.0.1'
port int | None

The app's port, given as --port, for a server that takes one.

None
remote bool

That the host is on the operator's tailnet, which encrypts and authenticates what the add-on's plain RPC doesn't: a tailnet's address or a .ts.net name.

False
secrets Sequence[str]

The names of variables in the runner's environment the server is given, such as FREECAD_MCP_TOKEN: read as it is spawned, and passed to nothing else. The add-on's token must then be set, or nothing is started.

()
allow Sequence[str]

The code and network tools the operator allows, by the server's name.

()
unauthenticated bool

That the operator allows code and network tools through an add-on that takes no token, such as Blender's, which any local process can drive as well.

False
scan Literal['warn', 'block']

Whether a finding in the agent's code is shown to the approver (warn), or refuses the call before anyone is asked (block).

'warn'
deadline float

The seconds one call may take, the server's start included.

30.0
approval_ttl float

The seconds an approval holds once asked: an older one runs nothing.

15 * 60
lock AppLock

What calls to the app take turns by: this process's lock by default; with more than one runner process, PostgreSQL's artifactr.sql.AdvisoryLock.

PROCESS
per_hour int | PerHour

How many tries at code and network calls each workspace may make to the app an hour: a number for every workspace, or the application's answer for each, by tenant and workspace, read each call: per_hour_setting(grants, app) reads the setting its admins narrow. Counted in the workspace's log; 0 if it can't be read.

PER_HOUR
offer Sequence[str] | None

The read and edit tools the operator offers, by the server's name: every one by default. With allow, the operator's layer of the tools a workspace may offer.

None
workspace_tools ToolsFor | None

Which of the app's tools each workspace offers, by tenant and workspace, read each listing and each call: tools_setting(grants, app) reads the setting its admins narrow. It only ever narrows offer and allow; none if it can't be read.

None

Raises:

Type Description
ValueError

If the host isn't loopback without remote, or a tailnet's with it; if remote is given without the add-on's token; if a port is given to a server that takes none; if allow names a tool that isn't the server's code or network, or names one without the add-on's token, or, for an add-on that takes none, without unauthenticated; if offer names a tool that isn't its read or edit.

server property

The vetted server.

allow property

allow: frozenset[str]

The code and network tools the operator allows.

scan property

scan: Literal['warn', 'block']

Whether a finding is shown to the approver, or refuses the call.

deadline property

deadline: float

The seconds one call may take.

approval_ttl property

approval_ttl: float

The seconds an approval holds once asked.

workspace_offers async

workspace_offers(
    tenant_id: str, workspace_id: str
) -> frozenset[str]

The tools the workspace offers, of the operator's: read now, and none if it can't be.

The operator's offer and allow, narrowed by workspace_tools where it is given.

per_hour async

per_hour(tenant_id: str, workspace_id: str) -> int

How many tries at code and network calls the workspace may make an hour, read now.

A PerHour that fails, such as a settings store that can't be read, answers 0, so the call is refused rather than run uncounted.

tools async

tools() -> list[Tool]

The tools the server lists, read once in the process and kept.

Raises:

Type Description
ConnectionFailed

If listing failed, now or within the last RETRY_AFTER seconds.

call async

call(
    name: str, arguments: dict[str, Any]
) -> CallToolResult

Call one of the server's tools, once the server it spawned still says it is as vetted.

The server is a new process for each call, so the tool is checked against its entry's digest in the same session that calls it. Calls to one app run one at a time.

ConnectionFailed

Bases: Exception

The server didn't start, didn't answer in time, made no sense, or isn't as vetted.

Its message is lattice's own words, never the server's, so it can be shown to the model.

ProcessLock

ProcessLock()

A lock for each key in this process, on its one event loop.

anyio's lock refuses to leave its event loop, and two runner processes don't share it: with more than one, on PostgreSQL, use artifactr.sql.AdvisoryLock; on any other database, run one runner process.

held async

held(key: str, *, wait: float) -> AsyncGenerator[None]

Hold the key's lock, waiting at most wait seconds for it.

ConnectedServer dataclass

ConnectedServer(
    app: str,
    title: str,
    source: str,
    version: str,
    reported_version: str,
    tools: Mapping[str, Vetted],
    code: Mapping[str, str] = dict[str, str](),
    reaches: Mapping[str, Reach] = dict[str, Reach](),
    properties: Mapping[str, str] = dict[str, str](),
    token: str | None = None,
    env: Mapping[str, str] = dict[str, str](),
    ports: bool = False,
)

A vetted server: its app, the version vetted, and every tool it may offer.

Raises:

Type Description
ValueError

If the app isn't a lowercase ASCII name, or a code tool names no code argument, or another tool names one.

app instance-attribute

app: str

The app's name: its keys' (connect:<app>) and its tools' prefix (<app>_).

title instance-attribute

title: str

The app's name, for people: "FreeCAD".

source instance-attribute

source: str

Where the server comes from, for the admin: its repository.

version instance-attribute

version: str

The release vetted, as an installer names it: freecad-mcp==0.1.27.

reported_version instance-attribute

reported_version: str

The version that release says it is as it starts, which a server must say: its own, and not always its release's (FreeCAD's says none), so it catches an accident, not a forgery.

tools instance-attribute

tools: Mapping[str, Vetted]

Every tool it may offer, by the server's own name.

code class-attribute instance-attribute

code: Mapping[str, str] = field(
    default_factory=dict[str, str]
)

The argument that holds the code, by each code tool.

reaches class-attribute instance-attribute

reaches: Mapping[str, Reach] = field(
    default_factory=dict[str, Reach]
)

Where each network tool fetches from, which its approver is shown: the argument that names the service, the hosts each of its values reaches, as read in the server's source, and an argument that names somewhere else of the model's choosing, if the tool takes one.

properties class-attribute instance-attribute

properties: Mapping[str, str] = field(
    default_factory=dict[str, str]
)

The argument of each tool that sets an object's properties by name, whose names are held to plain ones: none starting with _, and none of UNSET (an expression, a proxy).

token class-attribute instance-attribute

token: str | None = None

The variable the server reads the add-on's token from, if the add-on takes one.

env class-attribute instance-attribute

env: Mapping[str, str] = field(
    default_factory=dict[str, str]
)

What the server is always given in its environment.

ports class-attribute instance-attribute

ports: bool = False

Whether the server takes the app's port as --port, as well as its host as --host.

key property

key: str

The integration that switches its read and edit tools: connect:<app>.

code_key property

code_key: str

The integration that switches its code and network tools: connect-code:<app>.

Vetted

Bases: NamedTuple

One tool, as it was vetted: its risk, and the digest of what the server said it is.

per_hour_setting

per_hour_setting(settings: Settings, app: str) -> PerHour

The limit a settings store holds for an app: connect-per-hour:<app>, read each call.

The store's own answer while it can't be read is its floor, 0; a value that isn't a number, or a key it doesn't declare, raises, which Connection answers with 0 too (lattice ADR-0030).

tools_setting

tools_setting(settings: Settings, app: str) -> ToolsFor

The tools a settings store holds for an app's workspaces: connect-tools:<app>.

It is read each time. A value that isn't names raises, which Connection answers with no tools (lattice ADR-0030, artifactr ADR-0089).

digest

digest(
    name: str,
    description: str | None,
    input_schema: Mapping[str, Any],
) -> str

The SHA-256 of a tool's name, description and input schema, as canonical JSON.

Escaped to ASCII, so text no encoding takes, a lone surrogate, digests too, and can't match.

connected_app_tools

connected_app_tools(
    connection: Connection,
    *,
    integrations: Integrations,
    clock: Callable[[], datetime] = _utc_now,
) -> AbstractToolset[Session[Any]]

Build the toolset for one connected app.

Parameters:

Name Type Description Default
connection Connection

The operator's connection to their app.

required
integrations Integrations

Whether the app's keys are on in the run's workspace. Both are off by default.

required
clock Callable[[], datetime]

The current time, which an approval's age is measured by against its pause's, as the workspace's log keeps it.

_utc_now