Access Context Graph via MCP
This topic describes how to connect DataWorks Context Graph to MCP-enabled clients such as Qwen Work and Qoder through Alibaba Cloud OpenAPI MCP Server. You can retrieve business knowledge, read original text, and query object relationships within the semantic knowledge bases that you are authorized to use.
Overview
Through Alibaba Cloud OpenAPI MCP Server, you can connect DataWorks Context Graph to MCP-enabled clients such as Qwen Work and Qoder, and then retrieve business knowledge in semantic knowledge bases, read original text, and view object relationships in natural language in the client. No dedicated knowledge base skill is required. Key capabilities:
Retrieve business knowledge: Search the knowledge base for relevant knowledge and evidence around a business question.
Read original text and sources: View the original content and source files of the retrieved knowledge.
View object relationships: View the associations between knowledge objects from a knowledge graph perspective.
Manage knowledge bases: Manage knowledge bases, knowledge sources, knowledge objects, and build tasks within your permissions.
Prerequisites
Account permissions: The identity used for authorization has the required OpenAPI call permissions and knowledge base access permissions.
Knowledge base ready: The target knowledge base has completed at least one successful build, and the current identity has access to it. For how to create and build a knowledge base, see Create a semantic knowledge base.
OAuth application: For first-time use, an administrator must install and assign the OpenAPI MCP OAuth application. For details, see Alibaba Cloud OpenAPI MCP Server user guide.
Local environment: Node.js and npm are installed on your machine to start the MCP remote connection through npx.
Procedure
The connection process consists of two steps: obtain the MCP endpoint, and then configure the client and complete authorization. You can verify the connection after both steps.
Step 1: Obtain the MCP endpoint
Open the Alibaba Cloud OpenAPI MCP console and obtain the endpoint by using one of the following methods.
Method 1: Custom edition (recommended)
Create the service: In the left-side navigation pane, choose Custom and click Create.
Fill in basic information:
Parameter
Action
Name
Enter a name. The name must be 3 to 16 characters in length and can contain lowercase letters, digits, underscores (_), and hyphens (-).
Document Language
Select the language used for API descriptions in the tools, for example, English.
OAuth Configuration
We recommend that you use Alibaba Cloud official OAuth. You can also use Custom OAuth.
Configure multi-account access: In Multi-Account MCP, select a configuration method based on the access scope.
Access only the current account: Select Current Account Only. No cross-account role is required.
Access member accounts across accounts: Select Multi-Account and configure the Multi-Account RAM Role Name. Select one of the following role methods based on how your accounts are managed.
Role method
Configuration
Resource Directory management role
Select this method when you use a Resource Directory management account to access member accounts. The Multi-Account RAM Role Name defaults to
ResourceDirectoryAccountAccessRoleand does not need to be entered.Custom role
Create a RAM role in the target account, then select Custom Role and enter the role name.
If you select Custom Role, create a RAM role in each target account first. Configuration steps:
Log on to the RAM console of the target account and create a role.
Set the trusted principal type to Alibaba Cloud Account and the trusted principal to Other Alibaba Cloud Account, and enter the ID of the Alibaba Cloud account where the MCP service is created.
After the role is created, find the role under Identities > Roles, click Grant Permissions to grant the required DataWorks API call permissions, and confirm that the role has access to the target knowledge base.
Create a role with the same name in each target account, and enter the role name in the Custom Role configuration of the MCP service.
For multi-account configuration details, see Multi-account configuration. For role authorization details, see Grant permissions to a RAM role.
Select APIs: In the Cloud Products and API List, select DataWorks and set the API version to
2024-05-18. Search for knowledge base-related APIs and select the APIs you need.Complete creation: Click Create and confirm the risk warnings on the page.
Obtain the endpoint: After the service is created, choose Custom > View in the left-side navigation pane to open the service details page. In the Public Network area of Configuration Information, copy the Streamable HTTP Endpoint for client configuration. Alternatively, click One-click Configuration. In the dialog box that appears, select an authentication method (OAuth Authentication by default, or Static Credential Authentication) and a client tab (such as Cherry Studio, Lingma/Cursor/Windsurf/VSCode, Claude Code, or Codex), and then copy the configuration template for the client, or click One-click Configure to to write the configuration to the target client automatically.
Method 2: Core edition
Log on to the console and choose Core in the left-side navigation pane.
Copy the Streamable HTTP Endpoint on the page for client configuration.
Step 2: Configure the client and complete authorization
The following steps use Alibaba Cloud official OAuth as an example and all require the Streamable HTTP Endpoint obtained in Step 1. Node.js and npm must be installed on your machine.
Qwen Work
Open the desktop client and go to Extensions > Connectors.
Click + Add > Manual Configuration.
Enter a name, set the server type to STDIO, and enter the following command:
npx -y mcp-remote-alibaba-cloud "<Streamable HTTP Endpoint>"Replace
<Streamable HTTP Endpoint>with the actual endpoint and click Add.Sign in to your Alibaba Cloud account in the browser and consent to authorization.
Return to Connectors > Installed, enable the service, and expand it to view the tool list.
For Qwen Work configuration details, see Qwen Work configuration guide.
Qoder (IDE)
Click the user icon in the upper-right corner and go to Qoder Settings > MCP.
On the My Servers page, click + Add to open the configuration editor.
Enter the following JSON and replace the sample endpoint with the full endpoint you obtained. If other services already exist, add only the new service entry to the existing
mcpServers:{ "mcpServers": { "dataworks-knowledge": { "command": "npx", "args": [ "-y", "mcp-remote-alibaba-cloud", "https://openapi-mcp.cn-hangzhou.aliyuncs.com/id/YOUR_MCP_SERVER_ID/mcp" ] } } }Close the configuration file and click Save as prompted.
Sign in to your Alibaba Cloud account in the browser and consent to authorization.
Return to My Servers, confirm that the connection succeeds, and expand it to view the tool list.
For Qoder configuration details, see Qoder configuration guide.
Codex Desktop
In the desktop app, open Settings > MCP servers and click Add server. If you already added and enabled the service through Codex CLI on the same computer, you do not need to add it again.
Select STDIO and configure the settings as described in the following table. In this example, the Alibaba Cloud MCP proxy on your machine connects to the remote service, so select STDIO instead of Streamable HTTP in the client.
Setting
Description
Name
Custom name, for example,
dataworks-knowledge.Command
npx. If the desktop app cannot find the command, enter the absolute path ofnpx.Arguments
Add
-y,mcp-remote-alibaba-cloud, and the full Streamable HTTP Endpoint copied from the Alibaba Cloud console, in that order. Enter each item separately.Save the configuration and click Restart. On the first connection, follow the prompts of the local proxy to sign in to your Alibaba Cloud account in the browser and complete OAuth authorization. You do not need to enter an AccessKey.
Return to the desktop app and enter
/mcpin the session input box to view the service connection status. Then verify the connection as described below.
For Codex Desktop configuration details, see Codex MCP configuration guide.
Codex CLI
In the terminal, run the following command. Replace
<Streamable HTTP Endpoint>with the full endpoint obtained in Step 1:codex mcp add dataworks-knowledge -- npx -y mcp-remote-alibaba-cloud "<Streamable HTTP Endpoint>"Run
codex mcp listand confirm that the list containsdataworks-knowledge.Start a new Codex CLI session, then sign in to your Alibaba Cloud account in the browser and complete OAuth authorization as prompted. In this example, the local proxy handles authorization, so you do not need to run
codex mcp loginseparately.Return to the terminal and enter
/mcpin the session to view the service connection status.
For Codex CLI configuration details, see Codex CLI configuration guide.
Claude Code
In the project directory where you use Claude Code, run the following command. Replace
<Streamable HTTP Endpoint>with the full endpoint obtained in Step 1:claude mcp add --transport stdio --scope local dataworks-knowledge -- npx -y mcp-remote-alibaba-cloud "<Streamable HTTP Endpoint>"Run
claude mcp listand confirm that the list containsdataworks-knowledge.NoteThis example adds the service to the local configuration of the current project (
--scope local). Start Claude Code in the same project directory.Sign in to your Alibaba Cloud account in the browser and complete OAuth authorization as prompted.
Return to Claude Code and enter
/mcpin the session to view the service connection status.
For Claude Code configuration details, see Claude Code configuration guide.
Verify the result
Enter the following question in the client:
List the DataWorks knowledge bases that I have permission to access in [region].After the client returns the target knowledge base, enter another question whose answer exists in the knowledge base and request the original source. If the client retrieves and reads the details correctly, the connection is successful.
FAQ
Q: Is an AccessKey required?
A: No. OAuth is used by default. Sign in and authorize in the browser; no AccessKey is required.
Q: Must I specify a region before querying?
A: No. Complete the connection and authorization first, then specify the target region in your question when you retrieve knowledge, for example, "List the knowledge bases I can access in Chengdu."
Q: I connected to MCP but cannot find my knowledge base. Why?
A: Check the authorized identity, the target region, and the knowledge base access permissions. An empty result for one query does not mean there are no knowledge bases in other regions.
Q: What if OAuth authorization fails?
A: Confirm that the account and the OAuth application are installed and assigned. Follow the platform prompts to contact the administrator. Do not switch to another identity or credential on your own.
Q: Why can't I find a specific knowledge base API tool?
A: For the Custom edition, confirm that the API is selected and reconnect. For the Core edition, the client discovers tools through API discovery; confirm the API version, the region release status, and your permissions.
Q: What if the client reports that npx or uvx is not found?
A: Check the client runtime environment and PATH. If necessary, use the absolute path of the local executable.