Import MCP tools and bind an agent

Import tools, then update the target agent’s bindings. On binding failure, read back tools and bindings.

POST https://api.moi.matrixorigin.cn/v5/workspaces/{workspace_id}/agents/{agent_id}/actions/import-workspace-mcp

Before you call this API

Obtain a personal access token and Workspace ID for the current environment as described in AI Studio. The active role must permit the operation. Also prepare the target agent ID; even a dry run first checks target update permission.

Request parameters

curl -X POST "https://api.moi.matrixorigin.cn/v5/workspaces/$WORKSPACE_ID/agents/$AGENT_ID/actions/import-workspace-mcp" \
  -H "X-API-Key: $AI_STUDIO_API_KEY" \
  -H "X-Workspace-ID: $WORKSPACE_ID" \
  -H "Content-Type: application/json" \
  --data '{"dry_run":true,"tool_names":["qa_echo"]}'

Parameter

Type

Required

Description

workspace_id

string

Yes

Target workspace ID in the current environment, matching the header.

X-Workspace-ID

string

Yes

Workspace ID in the current environment.

X-API-Key

string

Yes

Personal access token in the current environment.

dry_run

boolean

No

JSON request body. true performs a dry run only; omission, null, or false performs the import.

tool_names

string (array of strings)

No

JSON request body. Choose exact names returned by the dry run. Omission, null, or [] selects all candidates.

tools

object (array of objects)

No

Additional descriptors. Omit for ordinary tasks; see the shared contract for subfields.

agent_id

string

Yes

Updatable target agent ID in the path.

agent_workspace_id

string

No

Query parameter; defaults to the current Workspace. system does not authorize updates to system agents.

Explicitly send dry_run=true first, choose importable names from the result, and explicitly supply tool_names for the actual call. Dry runs may include nonimportable product_api tools; do not write the entire dry-run result back directly. See Import contract for filtering, descriptors, and partial writes. The response has no bound flag; returned tools do not establish that the entire binding transaction completed.

Successful response

{
  "code": 0,
  "data": {
    "dry_run": true,
    "tools": [
      {
        "name": "qa_echo",
        "kind": "operator",
        "origin": "api_service"
      }
    ]
  }
}

Field

Type

Description

code

integer

0 on success.

data.dry_run

boolean

Whether this request is a dry run.

data.tools

object (array of objects)

Selected import results; may be empty when nothing matches.

data.tools[].name

string

Candidate tool name.

data.tools[].description

string

Description returned when nonempty.

data.tools[].kind

string

Currently projected as operator.

data.tools[].operator_id

string

Optional identifier. New API services currently bind by name, so this is not guaranteed.

data.tools[].workflow_id

string

Optional identifier; unpopulated in the current name-binding branch.

data.tools[].version

string

Optional version. Current API services do not pin node versions.

data.tools[].node_id

string

Returned only when the corresponding source value exists; not ordinary client import input.

data.tools[].tool_id

string

Existing or actually created tool ID; may be omitted for new candidates during a dry run.

data.tools[].origin

string

Source, such as api_service or product_api. Product API supports dry runs only and cannot actually be imported as an agent tool.

data.tools[].existing

boolean

true when reusing a same-name tool; false may be omitted and does not establish equality of all configuration.

Error responses

HTTP / code

Conditions and handling

400 / 2

Invalid parameters, candidate, or target state. Actual selections containing product_api are rejected before creation.

403 / 5

Current operation is unauthorized or the tool is read-only.

409 / 4、9

Tool name or update-version conflict. Read back the existing tool first.

503 / 15

Workspace MCP import or authorization dependencies are unavailable.

The authentication stage may also return string code/msg. See errors and environments.

Last updated on