Use MCP services

Updated at:
Copy as MD

The Agent Data Gateway MCP service wraps data asset discovery, permission queries, DataWiki knowledge retrieval, and SQL execution into standard MCP tools. After you configure the service in an MCP-enabled AI client, agents can access enterprise data within the existing identity, permission, security policy, and audit constraints of Agent Data Gateway. This topic describes how to configure and use the Agent Data Gateway MCP service.

Overview

The Agent Data Gateway MCP service is built on the MCP (Model Context Protocol) Streamable HTTP protocol and opens the core capabilities of Agent Data Gateway to MCP-enabled AI clients such as Qoder, Cursor, Codex, Claude Code, and OpenCode. After configuration, the agent in your AI client can call standard MCP tools to discover data assets, verify permissions, retrieve knowledge, and execute SQL. Every call stays within the existing identity, permission, security policy, and audit constraints of Agent Data Gateway.

The MCP service has the following characteristics:

  • Transport protocol: MCP Streamable HTTP.

  • Authentication: Each request must carry the Authorization: Bearer <Access Token> header.

  • Permission boundary: MCP does not expand user permissions. Calls still enforce the ACL, security policies, and auditing of Agent Data Gateway.

  • Credential handling: The MCP service does not store your access token.

Preparations

Before you use the MCP service, complete the following preparations:

  1. Log on to the Agent Data Gateway console, activate the service, and create an agent identity. For more information, see Quick guide for Agent Data Gateway access.

  2. Grant the agent identity the permissions on the instances or data that you want to access. For more information, see Manage data sources and Manage access tokens and permissions.

  3. Obtain the agent access token for the corresponding region.

  4. Select an MCP endpoint in the same region as the access token.

Important

The service rejects a request when the access token has expired, has been revoked, or belongs to a region that does not match the endpoint. Never put a full token in a prompt, screenshot, log, or code repository.

Service endpoints

The MCP service provides a separate endpoint for each region. Select the endpoint that matches the region of your access token. The production environment currently supports the following regions:

Region

MCP endpoint

China (Hangzhou)

https://dgate-mcp-cn-hangzhou.aliyuncs.com/mcp/dgate

China (Shanghai)

https://dgate-mcp-cn-shanghai.aliyuncs.com/mcp/dgate

China (Beijing)

https://dgate-mcp-cn-beijing.aliyuncs.com/mcp/dgate

China (Shenzhen)

https://dgate-mcp-cn-shenzhen.aliyuncs.com/mcp/dgate

China (Zhangjiakou)

https://dgate-mcp-cn-zhangjiakou.aliyuncs.com/mcp/dgate

China (Hong Kong)

https://dgate-mcp-cn-hongkong.aliyuncs.com/mcp/dgate

Singapore

https://dgate-mcp-ap-southeast-1.aliyuncs.com/mcp/dgate

Malaysia (Kuala Lumpur)

https://dgate-mcp-ap-southeast-3.aliyuncs.com/mcp/dgate

Japan (Tokyo)

https://dgate-mcp-ap-northeast-1.aliyuncs.com/mcp/dgate

Note

The endpoint path is fixed as /mcp/dgate. The access token, resources, and endpoint must belong to the same region. Cross-region calls return error code 401.

Configure the MCP client

Add the following content to your MCP client configuration, and replace the endpoint and access token with your production environment values:

{
  "mcpServers": {
    "dgate": {
      "url": "https://dgate-mcp-cn-hangzhou.aliyuncs.com/mcp/dgate",
      "headers": {
        "Authorization": "Bearer <ACCESS_TOKEN>"
      }
    }
  }
}

The configuration file location and the UI entry point vary by client, but only two settings are essential: the MCP URL and the Authorization header. After you save the configuration, reload the MCP service. Some clients require a restart or a new session to refresh the tool list.

Verify the connection and permissions

Verify in an AI client

After configuration, send the following instruction to the agent in your AI client to check whether the tools are available:

Check whether the dgate MCP is available, and then perform the following steps in order:
1. Call acl_whoami to confirm the current identity.
2. Call acl_my_permissions to list the actual data permissions of the current identity.
3. Call meta_catalog_list to list the data instances that are visible to you.
4. If an authorized database exists, call exec_sql to run SELECT 1.
5. Summarize the status of each step. If a step fails, report the errorCode, errorMessage, and requestId. Do not output the access token.

The connection is successful when the following conditions are met:

  • The client can discover the dgate tools.

  • acl_whoami returns the current agent identity.

  • acl_my_permissions returns the authorization list or an explicitly empty list.

  • A read-only statement runs successfully against an authorized database.

Verify the protocol chain with curl

Alternatively, use curl to verify the MCP protocol chain directly:

curl -sS -X POST \
  'https://dgate-mcp-cn-hangzhou.aliyuncs.com/mcp/dgate' \
  -H 'Authorization: Bearer <ACCESS_TOKEN>' \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json, text/event-stream' \
  --data '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-06-18","capabilities":{},"clientInfo":{"name":"curl","version":"1.0"}}}'

A successful connection returns HTTP 200, and result.serverInfo.name is dgate-mcp.

Tools

The production service currently registers 13 MCP tools, grouped into six categories by purpose: metadata, data sources, permissions, knowledge, execution, and extensions.

Category

Tool

Purpose

Metadata

meta_catalog_list

Lists the data instances that are visible to the current identity.

meta_catalog_search

Searches for instances by keyword, resource type, or database type.

meta_database_list

Lists the databases under a specified instance.

meta_table_list

Lists the tables in a specified database.

meta_table_columns

Views the columns, data types, and comments of a specified table.

meta_table_indexes

Views the index definitions of a specified table.

Data sources

datasource_list

Lists the control-plane metadata of data sources.

Permissions

acl_whoami

Queries the platform role and administrator flag of the current identity.

acl_my_permissions

Queries the actual data permissions granted to the current identity.

Knowledge

wiki_search

Retrieves table meanings, sample SQL statements, and business definitions from DataWiki.

Execution

exec_sql

Executes a single SQL statement or command through Agent Data Gateway and returns the result.

Extensions

gateway_describe

Views the actions and parameters available for extension calls.

gateway_call

Calls long-tail control actions that do not yet have a dedicated tool.

Common parameters:

  • List tools paginate with MaxResults and NextToken. When the response returns pagination.hasMore=true, pass pagination.nextToken unchanged into the next call.

  • meta_database_list requires CatalogUuid. meta_table_list requires DatabaseUuid.

  • meta_table_columns and meta_table_indexes require databaseUuid and tableQualifiedName.

  • wiki_search requires wikiUuid and query.

  • Before you use gateway_call, call gateway_describe to view the action, its parameters, and whether it is a write operation.

Execute SQL statements or commands

exec_sql executes only one statement at a time. Specify the target in at least one of the following ways:

  • databaseUuid.

  • catalogUuid, optionally with qualifiedName to specify a database or schema.

  • catalogName, optionally with qualifiedName to specify a database or schema.

Common optional parameters include timeout, maxRows, columnTruncate, and waitSeconds. Run a read-only statement with LIMIT first, and then narrow the query scope step by step.

Important

If the response returns NEEDS_CONFIRMATION, the statement has hit the ASK security gate of Agent Data Gateway. A user must read the risk and the reason and explicitly confirm before you retry in the same call with a confirm reason. Agents must not attach a confirmation reason by default or bypass the gate automatically.

Response results and common statuses

Business tools return structured results. The requestId is key information for tracing the call chain during troubleshooting. List tools use the pagination field to indicate whether more pages exist.

The following table describes the common execution statuses of exec_sql:

Status

Meaning

Recommended action

SUCCEEDED

The execution succeeded.

Read the result. If the result is truncated, narrow the scope and retry.

FAILED

The execution failed.

Check the errorCode, errorMessage, and requestId.

NEEDS_CONFIRMATION

The statement hit a manual confirmation gate.

After manual review, retry with a confirm reason.

TIMED_OUT_WAITING

The synchronous wait timed out.

Check the execution status, or adjust waitSeconds and retry.

RUNNING

The execution has switched to asynchronous mode.

Keep the returned task information and query the progress as prompted.

Permissions and security

Permission semantics

When you use the MCP service, distinguish between the following three concepts:

  1. The ADMIN value returned by acl_whoami is a platform role. It does not mean that you have query permissions on all instances.

  2. Seeing a resource in meta_catalog_list or datasource_list only means that the metadata is visible. It does not mean that you can execute SQL.

  3. The actual data authorization of the current identity is determined by the result of acl_my_permissions.

Therefore, if you can see an instance but cannot query it, check acl_my_permissions first, and then have an administrator grant the permissions on the target instance or database.

Security recommendations

  • Transmit credentials only over HTTPS and through the Authorization: Bearer <Access Token> header.

  • Do not put tokens in URLs, prompts, screenshots, logs, ticket bodies, or code repositories.

  • Rotate a token immediately after a leak, an expiration, or a change in personnel permissions.

  • SQL write operations and dangerous statements are always subject to the security policies of Agent Data Gateway.

  • Write operations of gateway_call are not allowed by default. Actions that involve credential ciphertext are prohibited from being returned through MCP.

  • MCP calls enter the audit chain of Agent Data Gateway under the current actual agent identity.

FAQ

The following are common issues that you may encounter when you use the MCP service, together with the corresponding solutions. If your issue is not covered here, you can submit feedback.

When you submit an issue, provide the time of occurrence, region, MCP tool name, masked parameters, errorCode, errorMessage, and requestId. Do not provide a full access token.

Symptom

Possible cause

Solution

401 or AUTH_CREDENTIAL_NOT_FOUND is returned.

The token is missing, expired, or revoked, or the region does not match.

Check the Bearer header, reissue the token, and confirm that the token and the endpoint belong to the same region.

403 or ACCESS_DENIED is returned.

The current identity does not have permissions on the target resource.

Call acl_my_permissions to verify the authorization, and contact an administrator to grant the permissions.

The client cannot see the dgate tools.

The MCP configuration did not take effect, the client was not refreshed, or the URL is incorrect.

Reload or restart the client, and use the curl initialize request to verify the endpoint.

Instances can be listed but SQL cannot be executed.

Visible metadata does not equal execution permission.

Verify the instance authorization against acl_my_permissions.

NEEDS_CONFIRMATION is returned.

The SQL statement hit an ASK security policy.

Manually review the risk, enter a confirmation reason, and retry. Automatic confirmation is prohibited.

429 is returned.

The call frequency exceeds the limit.

Back off according to the Retry-After value or the retry hint in the response.

The result is incomplete or truncated.

The row count or response size limit is reached.

Add filter conditions, use LIMIT, or adjust maxRows as needed.