matter.work
Building Apps / The SDK

Connections

Call the member's connections from your app's own code, as their agents do.

Your app’s own code can use the member’s connections (Gmail, Slack, Apify, a custom MCP server and so on) the way their agents do, through matter.connectedApps. The call runs as the member, on their accounts and those teammates shared with them. Credentials stay with Matter, so your app never holds an API key, and it doesn’t care whether an app is connected through Matter’s catalog or a custom MCP server.

Declare each app your code uses in connectedApps, and the tools it runs:

matter.json
{
  "connectedApps": {
    "apify": ["APIFY_RUN_ACTOR_SYNC_GET_DATASET_ITEMS"],
    "slack": true
  }
}
worker.mjs
const { data } = await matter.connectedApps.call({
  app: 'apify',
  account: 'Team key',
  tool: 'APIFY_RUN_ACTOR_SYNC_GET_DATASET_ITEMS',
  arguments: {
    actorId: 'harvestapi~linkedin-post-search',
    input: { searchQueries: ['switching time tracking'], postedLimit: '24h', maxPosts: 10 },
  },
})
const posts = data.items

Calls#

Call Description
list() The apps your manifest declares, each with its tools, whether the member approved it on this computer, and their accounts for it: { account, status, local, instructions }.
tools(app, query?) A declared app’s tools with their inputSchema: the ones you declare, or, for an app declared with true, those matching query (at most 20).
call({ app, tool, arguments?, account? }) Runs a declared tool and resolves to { app, account, data, content? }: the tool’s output in full. data is a catalog app’s data, or an MCP server’s structured content (else its text, parsed when it’s JSON); content is an MCP server’s content blocks.

How it runs#

  • From your app’s code: call works from the worker and tools. A page calls one of your tools that calls it. Pages can list and read tools, but not call.
  • Declared, then approved: A call to an app or tool your manifest doesn’t declare fails with not_declared. The member approves what you declare on each computer, when they open your app there (see Trust and security). Until they do, calls fail with not_approved. A version that declares more asks again for what’s new. A version you published doesn’t ask when you open it (or one signed with a key on your computer): it’s your own code.
  • Which account: With one account for the app, the call uses it. With more, pass account (a label from list()); otherwise the call fails and names the labels. Accounts in a space reach the members of that space, as they do for agents.
  • The owner’s rules: An account can carry instructions from whoever connected it, such as “never post publicly”. list() returns them. Agents follow them; your code should too.
  • Long calls: A call can take up to 5 minutes, which suits synchronous runs like Apify’s.
  • Local MCP servers: Servers that run as a command on the member’s computer are started by their agents, and aren’t available to app code yet. A call to one fails with unavailable.

Older Matter#

matter.connectedApps is in Matter 0.4.9 and newer. You don’t need to raise minMatterVersion to use it: older versions ignore connectedApps, so check for it and fall back.

TypeScript
if (matter.connectedApps?.call) {
  // the member's connections
} else {
  // what the app did before
}

Errors#

Code When
not_declared The manifest doesn’t declare the app, or that tool of it.
not_approved The member hasn’t allowed it on this computer yet.
forbidden A page tried to call. Call from the worker or tools.
unavailable No account for the app reaches the member, there’s more than one and no account, the account is off or signed out, or it’s a local MCP server.
tool_failed The tool ran and the app said no. The message is the app’s.