All Products
Search
Document Center

Platform For AI:Connect a DSW instance to an Agent through MCP

Last Updated:Sep 16, 2026

After you enable the MCP service on a DSW instance, you can connect the instance to an Agent client. The Agent can then run commands, read and write files, and execute code directly in the instance, letting you hand off cloud-based development tasks to AI.

Prerequisites

A VPC and a security group are configured for the DSW instance or the resource quota to which it belongs.

Use cases

Connecting a DSW instance to an Agent gives the Agent a ready-to-use cloud development machine. It can read and write code, run commands, and execute experiments directly in the instance, freeing you from repetitive environment operations. Typical scenarios include:

  • Remote code development and debugging: Have the Agent create and modify code in the instance, run it, locate errors, fix them, and rerun to complete a full development loop.

  • Environment preparation and dependency management: Ask the Agent to install missing Python or system dependencies, check CUDA and framework versions, and verify the runtime environment, saving you from typing commands one by one.

  • Training and experiment hosting: The Agent starts training scripts and waits asynchronously, monitors logs and outputs, and summarizes results automatically when training finishes.

  • Data processing and documentation organization: Batch search and clean data files in the instance, or convert web pages, PDFs, and Office documents to Markdown for later analysis.

Connect a DSW instance to an Agent through MCP

Step 1: Create a DSW instance and enable the MCP service

Enable the MCP service in three steps: turn on the service switch, generate access credentials, and open the port in the security group. After that, the Agent can access the instance through the MCP protocol.

  1. Enable the MCP service switch. The following example shows how to create an instance by using public resources. Configure the key parameters as described in this section. You can configure other parameters as needed.

    For an existing instance, go to the instance list, click Change Configuration in the Actions column, and reconfigure the DSW instance.
    • Resource Type: Select public resources.

    • VPC Settings: Select a VPC in the same region. A VPC is required to enable the MCP service.

    • Security Group: Select the created security group.

    • VSwitch: Select the created vSwitch.

    • Enable MCP Service: Turn on the switch. When the switch is on, a service named MCP appears and listens on port 9806 of the instance by default.

    If you want to access the DSW instance from the internet (for example, through a local Agent client), configure the following parameters:

    • Service Access and Port Configuration:

      • Access over Internet: Select the checkbox.

      • Internet Access Port: For example, 1078.

    • Public Network Access: Select DNAT + EIP

      • NAT Gateway: Select the NAT gateway created in the same region.

      • EIP: Select the EIP associated with the NAT gateway.

        Important

        Important: To allow the DSW instance to access the internet, configure an SNAT entry for the NAT gateway. For more information, see Improve public access speed through a dedicated gateway.

    After you complete the configuration, click OK to create the instance.

  2. Generate access credentials. After the DSW instance is created, click the instance name to go to the details page. In the Access Configuration section, click Generate Access Credentials. The credentials are used to authenticate the Agent when it calls the MCP service. Pass the credentials as a Bearer Token in the request header.

    You now have the MCP access endpoint and access credentials.

    Note

    The credentials are valid for 7 days by default. When they expire, regenerate them in the same location. After you regenerate them, update the credentials in the Agent configuration.

Step 2: Open the port and IP in the security group

On the DSW details page, in the Network Information section, click the security group name to go to the security group details page. On the Inbound tab, click Add Rule. Configure the following parameters. You can use the default values for other parameters.

  • Source: Enter the IP address of the Agent deployment location (for example, the public IP address of the local computer that runs the Agent).

  • Destination (this instance): Enter port 9806.

Step 3: Connect the Agent to the DSW instance

The DSW MCP service uses the standard Streamable HTTP protocol and is compatible with mainstream Agent clients. Open the Agent client (such as Open Code or Qoder CLI) and send the following prompt to the Agent, replacing <MCP access endpoint> and <access credentials> with the actual values. The Agent will automatically complete the MCP connection.

If you use a local Agent client to connect to a DSW instance, use the public access endpoint.
Add an MCP server named dsw-mcp with the Streamable HTTP protocol, endpoint http://<MCP access endpoint>, and request header Authorization: Bearer <access credentials>. Complete the setup automatically using your MCP configuration method.

After the connection is established, enter the following command in the Agent client to test connectivity.

Create a hello_world Python file in the /mnt/workspace directory on the DSW instance.

After the command runs, open the DSW instance. The hello_world.py file appears in the workspace.

Supported tools

The DSW MCP service exposes a set of tools through the standard Streamable HTTP protocol. The Agent loads the tool list automatically after it connects. The tools are grouped into five categories: Shell, File, System, Format conversion, and Code, for a total of 16.

Shell tools

Run commands inside the instance. Consecutive commands share the working directory, which is useful for running scripts, installing dependencies, and starting training jobs.

Tool

Function

Key parameters

shell_exec

Run a shell command

cmd (required), cwd, new_session, timeout

shell_view

View accumulated output and status of a session

session_id, limit

shell_wait

Wait for an asynchronous command to complete

session_id, seconds

shell_write

Send input to a running process

session_id, input, press_enter

shell_kill

Terminate and clean up a session

session_id

File tools

Read, write, search, and edit files inside the instance.

Tool

Function

Key parameters

file_read

Read file content (by line range)

path (required), start_line, end_line, sudo

file_write

Write or append to a file; supports base64 binary

path, content, encoding, append

file_str_replace

Replace strings globally within a file

path, old_str, new_str

file_search

Search file content by regular expression

path, regex

file_find

Find files by glob pattern

path, pattern

file_list

List directories (recursive, filter by type)

path, recursive, file_types

file_edit

Undo-capable editor

command (view/create/str_replace/insert/undo_edit), path, and so on

System tools

Query the instance environment and installed dependencies.

Tool

Function

Key parameters

system_info

Query the instance environment (OS, Python, Node, available tools)

None

system_packages

List installed Python or Node.js packages

language

Format conversion tools

Tool

Function

Key parameters

util_to_markdown

Convert web pages, PDFs, Office files, images, and so on to Markdown

uri

Code tools

Tool

Function

Key parameters

code_run

Run code (currently supports Python)

code, language, timeout

After the MCP service is enabled, the tools are available immediately. No additional configuration is required.