Use MCP services
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:
-
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.
-
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.
-
Obtain the agent access token for the corresponding region.
-
Select an MCP endpoint in the same region as the access token.
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) |
|
|
China (Shanghai) |
|
|
China (Beijing) |
|
|
China (Shenzhen) |
|
|
China (Zhangjiakou) |
|
|
China (Hong Kong) |
|
|
Singapore |
|
|
Malaysia (Kuala Lumpur) |
|
|
Japan (Tokyo) |
|
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_whoamireturns the current agent identity. -
acl_my_permissionsreturns 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 |
|
Lists the data instances that are visible to the current identity. |
|
|
Searches for instances by keyword, resource type, or database type. |
|
|
|
Lists the databases under a specified instance. |
|
|
|
Lists the tables in a specified database. |
|
|
|
Views the columns, data types, and comments of a specified table. |
|
|
|
Views the index definitions of a specified table. |
|
|
Data sources |
|
Lists the control-plane metadata of data sources. |
|
Permissions |
|
Queries the platform role and administrator flag of the current identity. |
|
|
Queries the actual data permissions granted to the current identity. |
|
|
Knowledge |
|
Retrieves table meanings, sample SQL statements, and business definitions from DataWiki. |
|
Execution |
|
Executes a single SQL statement or command through Agent Data Gateway and returns the result. |
|
Extensions |
|
Views the actions and parameters available for extension calls. |
|
|
Calls long-tail control actions that do not yet have a dedicated tool. |
Common parameters:
-
List tools paginate with
MaxResultsandNextToken. When the response returnspagination.hasMore=true, passpagination.nextTokenunchanged into the next call. -
meta_database_listrequiresCatalogUuid.meta_table_listrequiresDatabaseUuid. -
meta_table_columnsandmeta_table_indexesrequiredatabaseUuidandtableQualifiedName. -
wiki_searchrequireswikiUuidandquery. -
Before you use
gateway_call, callgateway_describeto 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 withqualifiedNameto specify a database or schema. -
catalogName, optionally withqualifiedNameto 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.
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 |
|
|
The execution succeeded. |
Read the result. If the result is truncated, narrow the scope and retry. |
|
|
The execution failed. |
Check the |
|
|
The statement hit a manual confirmation gate. |
After manual review, retry with a |
|
|
The synchronous wait timed out. |
Check the execution status, or adjust |
|
|
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:
-
The
ADMINvalue returned byacl_whoamiis a platform role. It does not mean that you have query permissions on all instances. -
Seeing a resource in
meta_catalog_listordatasource_listonly means that the metadata is visible. It does not mean that you can execute SQL. -
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_callare 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 |
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 |
The current identity does not have permissions on the target resource. |
Call |
|
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 |
|
Instances can be listed but SQL cannot be executed. |
Visible metadata does not equal execution permission. |
Verify the instance authorization against |
|
|
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 |
|
The result is incomplete or truncated. |
The row count or response size limit is reached. |
Add filter conditions, use |