This document guides you through creating, debugging, and using custom plugins to integrate the APIs you need.
Workflow
Create/Import a plugin: Define the plugin's basic information, or import one directly from Alibaba Cloud Marketplace.
Add a tool (This step is not required for imported plugins): Configure the specific API path, request parameters, and response data for the plugin.
Debug and publish: Test the API connectivity online and publish the tool after confirming it works as expected.
Use in an application: Associate the plugin with an agent and call it through conversational testing or API integration.
Create a custom plugin
Create a custom plugin
Step 1: Create a plugin
Go to the Plugins page and click Create Plugin.
Enter the plugin information.
Plug-in Name: Enter a descriptive name. Chinese and English are supported.
Example: Dormitory Agreement Query Tool Test
Plug-in Description: Briefly describe the plugin's features and purpose in natural language. This description helps the model decide when to use the plugin.
Example: Queries the content of a specific dormitory agreement entry based on the input numeric index.
Plug-in URL: The access endpoint of the plugin.
Example:https://domitorgreement-plugin-example-icohrkdjxy.cn-beijing.fcapp.run
Model Studio treats different paths under the same domain as different APIs. These paths correspond to the Tool Path you configure when creating a tool.
Tools within the same plugin share a domain name, but each tool's path maps to a unique API.
For example, a plugin contains two APIs:
Query: https://xxx.com/query
Delete: https://xxx.com/delete
In this example,
https://xxx.comis the Plug-in URL, while/queryand/deleteare the Tool Path values. This indicates that the plugin contains two tools.
If authentication is required, enable the Enable Authentication switch and enter the authentication settings.
After completing the form, click or click Continue to Add Tool.
Step 2: Create a tool
Enter the tool information, configure input and output parameters, and define any advanced settings.
In this example, enter "Dormitory Rules Query Tool" for Tool Name and "Queries the content of a specific dormitory rule based on the input numeric index" for Tool Description. Set the Tool Path to
/article, select POST for the Request Method, and select application/json for the Submission Method. For the input parameter, set the parameter name toarticle_index, the parameter description to "index", and the type to Number. This parameter is passed in the Body, is required, and its passing method is LLM recognition. For the output parameter, set the parameter name toarticle, the parameter description to "dormitory rule content", and the type to String. In the advanced settings, the user input query is "Query the content of the corresponding dormitory rule based on the input index value", and the value of thearticle_indexinput parameter is5.After completing the configuration, click Save Draft.
Debug the tool online to verify that the API is callable.
Click Test Tool. If you enabled authentication, enter the authentication information and input parameter values. Then, click Start Running.
If the run fails, adjust the configuration based on the error message in the Run Result section and test again until the run succeeds.
You can enter input parameter values manually or as code. For complex parameters, use Code Editing. In the code editor, you can submit the complete JSON-formatted input parameters and their corresponding values.
After the test passes, click Publish. Applications can only call tools that are Published.
Import from Marketplace
Alibaba Cloud Marketplace provides a rich selection of APIs. You can enable the APIs you need there and import them into Model Studio as plugins for your applications.
Go to the Plugins page and click Import from Marketplace.
If this is your first time importing an API from Alibaba Cloud Marketplace as a plugin, you must authorize a service-linked role.
Alibaba Cloud account
If you are logged in to Model Studio with an Alibaba Cloud account, select the checkbox to agree to the terms in the Service-linked Role Authorization dialog box, and then click Confirm Authorization.
The dialog box displays the role name as
AliyunServiceRoleForSFMAccessCloudAPIand the role policy asAliyunServiceRolePolicyForSFMAccessCloudAPI, which authorizes Alibaba Cloud Model Studio to access your Alibaba Cloud Marketplace product list and make API calls based on the plugin configuration.RAM user (sub-account)
If you are logged in to Model Studio with a RAM user (sub-account), select the checkbox to agree to the terms in the Service-linked Role Authorization dialog box. When you click Confirm Authorization, a prompt appears.
An Authorization Failed dialog box appears, indicating that the current user does not have permission to create the service-linked role. The service-linked role name is
AliyunServiceRoleForSFMAccessCloudAPI.This error occurs because the RAM user (sub-account) does not have permission to create a service-linked role. Follow these steps to grant the permission. After authorization, the RAM user can import plugins from Alibaba Cloud Marketplace to Model Studio or use plugins that are already imported by the Alibaba Cloud account.
Grant the RAM user (sub-account) permission to create a service-linked role.
Log in to the RAM console by using an Alibaba Cloud account.
In the left-side navigation pane, choose .
Click Create Policy.
In the Script Editor, enter the corresponding content from the following script into the
Effect,Action,Resource, andConditionfields.{ "Action": [ "ram:CreateServiceLinkedRole" ], "Resource": "*", "Effect": "Allow", "Condition": { "StringEquals": { "ram:ServiceName": "cloundapi-access.sfm.aliyuncs.com" } } }Click OK.
Set a name for the policy and click OK.
The Name is set to
service-linked role.In the left-side navigation pane, choose .
Find the RAM user (sub-account) that you want to authorize and click Actions in the Add Permission column.
Select the policy that you just created and click Add Authorization.
The RAM user (sub-account) now has permission to create a service-linked role.
In the Resource Scope section, select Account Level. From the policy filter drop-down list, select Custom Policy to find and select the target policy.
The RAM user can now import plugins from Alibaba Cloud Marketplace to Model Studio or use plugins already imported by the Alibaba Cloud account.
Return to the Alibaba Cloud Model Studio console, click Import from Marketplace, select the checkbox to agree to the terms in the Service-linked Role Authorization dialog box, and then click Confirm Authorization.
In the Import Plug-ins from Marketplace dialog box, click Click to View to go to Alibaba Cloud Marketplace and enable the required API.
Go to the page and wait until the Status of the product changes to Enabled.
This page also provides the AppKey, AppSecret, and AppCode for the API. If the plugin requires authentication, you can get the authentication information from this page.
After the API is enabled, return to the Alibaba Cloud Model Studio console and click Import from Marketplace to reopen the Import Plug-ins from Marketplace dialog box. Select the enabled API, click OK, and the system redirects you to the Tools page.
Plugins imported from Alibaba Cloud Marketplace are in a draft state. You must test and publish them before use.
In the row that contains the tool, click Debug to go to the Tool Test page.
Enter the parameters and click Start Running.
A Success status indicates the API is working correctly. Otherwise, use the error messages to adjust the configuration.
Return to the Edit Tool page and click Publish to publish the tool.
When you import a plugin from Alibaba Cloud Marketplace, the system autofills the input and output parameters, but some information may be missing. When you publish the tool, review any errors that prevent publishing and fix them based on the prompts.
For example, if the Tool name exceeds the 20-character limit, the character count to the right of the input box will appear in red (such as
22/20). You must shorten the name to meet the limit before you can publish.Applications can only call tools that are Published and Enable.
Also, ensure that the Debug status of the tool is Successful.
Use a plugin
Console
Method 1: Publish the plugin as an MCP service, and then add the service to an agent application.
Step 1: Publish the plugin as an MCP service
On the Plugins page, hover over the target plugin card and click Publish as MCP Service.
If the plugin has already been converted to an MCP service, the button changes to View MCP Service. Click it to go to the MCP Management page and view the service details.
After successful publication, you can view the details of the MCP service on the MCP Management page, including the service name, description, and ID.
Step 2: Add the MCP service to an agent application
Go to the orchestration canvas of the Agent Application application. In the MCP block, click +.
In the Select MCP Service panel, switch to the Custom MCPS tab, find the MCP service converted from the plugin, and click Add All to add it to the application.
You can also click Convert from Plugin to MCP to directly publish a plugin that has not yet been converted.
Test whether the plugin works as expected.
No authentication: Chat with the model in the input box to test the plugin's functionality.
user-level authenticationorservice-level authentication: Before you start a conversation, click
to configure the authentication token. You only need to configure the token once per session on this page.For plugins imported from Alibaba Cloud Marketplace, you do not need to enter an authentication token on this page.
If the Passing Method for a tool's input parameter is set to Business Pass-through, you must click
to configure the variable value before you start a conversation. You only need to enter the value once per session on this page.
After completing the test, Publish the application.
Method 2: On the Application Management page, go to the orchestration canvas for your Agent Application application, add the MCP service from the MCP block, test its functionality, and then Publish the application.
API
Get the tool ID
The tool ID identifies a specific tool. When you call a tool via an API, you must pass the correct tool ID to ensure the system correctly identifies the request.
In the Plugins list, find the plugin that contains the tool and click View Details.
Hover the pointer over the
icon next to the tool name.Click the
icon to copy the tool ID.
When you call an application by using an API, if the application's plugin uses
business pass-throughparameters or requires User-level Authentication, you must use thebiz_paramsparameter to pass the authentication information or pass-through parameter information. For more information, see DashScope API Reference for Workflows and Legacy Agent Applications.Call tools by using the Assistant API. Search for the keyword
toolsin the Assistant API documentation to learn how.
Manage plugins and tools
Error codes
The following table describes common error messages that can occur when you publish a tool.
Error code | Error message | Description |
130040 | The parameter description for xx is missing. | Cause: The description for the Solution: Add the parameter description and publish the tool again. |
130022 | Failed to save the tool information. Check whether the sample parameters are correct. | Possible cause 1: An input or output parameter of the Solution: Click the Possible cause 2: The request method is GET, but an input parameter is of the Solution: GET requests do not support the |
icon at the end of the object's row to add a sub-property.
icon next to the tool name.
icon to copy the tool ID.