Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Langgenius Dify FetchCollectionList

From Leeroopedia


Knowledge Sources
Domains Plugin Management Tool Integration Agent Capabilities
Last Updated 2026-02-08 00:00 GMT

Overview

Concrete tool for discovering and managing tool providers and their tools provided by the Dify tool service layer.

Description

This module provides seven API functions that power the tool integration workflow. fetchCollectionList retrieves all registered tool providers across every type (built-in, custom API, workflow, model, MCP, datasource, trigger). Type-specific functions -- fetchBuiltInToolList, fetchCustomToolList, fetchModelToolList, and fetchWorkflowToolList -- retrieve the individual tools within a provider of the corresponding type. updateBuiltInToolCredential saves or updates the API credentials required by a built-in tool provider. createWorkflowToolProvider registers a Dify workflow as a callable tool provider. Together, these functions enable browsing the full tool catalog, drilling into individual providers, managing credentials, and extending the system with workflow-based tools.

Usage

Use these functions when:

  • Rendering the tool provider listing on the tools management page.
  • Populating tool selector dropdowns in workflow node editors and agent configurations.
  • Fetching the tools available within a specific provider for display in a detail panel.
  • Saving or updating API credentials for a built-in tool provider.
  • Publishing a workflow as a reusable tool via the workflow tool creation flow.

Code Reference

Source Location

  • Repository: Dify
  • File: web/service/tools.ts (lines 14-125)

Signature

// Retrieve all tool providers in the workspace
export const fetchCollectionList = (): Promise<Collection[]>
// GET /workspaces/current/tool-providers

// Retrieve tools from a built-in provider
export const fetchBuiltInToolList = (
  collectionName: string
): Promise<Tool[]>
// GET /workspaces/current/tool-provider/builtin/{collectionName}/tools

// Retrieve tools from a custom API provider
export const fetchCustomToolList = (
  collectionName: string
): Promise<Tool[]>
// GET /workspaces/current/tool-provider/api/tools?provider={collectionName}

// Retrieve tools from a model provider
export const fetchModelToolList = (
  collectionName: string
): Promise<Tool[]>
// GET /workspaces/current/tool-provider/model/tools?provider={collectionName}

// Retrieve tools from a workflow provider
export const fetchWorkflowToolList = (
  appID: string
): Promise<Tool[]>
// GET /workspaces/current/tool-provider/workflow/tools?workflow_tool_id={appID}

// Update credentials for a built-in tool provider
export const updateBuiltInToolCredential = (
  collectionName: string,
  credential: Record<string, unknown>
): Promise<void>
// POST /workspaces/current/tool-provider/builtin/{collectionName}/update

// Create a workflow-based tool provider
export const createWorkflowToolProvider = (
  payload: WorkflowToolProviderRequest & { workflow_app_id: string }
): Promise<void>
// POST /workspaces/current/tool-provider/workflow/create

Import

import {
  fetchCollectionList,
  fetchBuiltInToolList,
  fetchCustomToolList,
  fetchModelToolList,
  fetchWorkflowToolList,
  updateBuiltInToolCredential,
  createWorkflowToolProvider,
} from '@/service/tools'

I/O Contract

Inputs

Name Type Required Description
collectionName string Yes (built-in, custom, model) Name identifier of the tool provider collection
appID string Yes (workflow) Application ID of the Dify workflow to retrieve tools from
credential Record<string, unknown> Yes (update credential) Key-value pairs of credential fields for the built-in provider
payload WorkflowToolProviderRequest & { workflow_app_id: string } Yes (create workflow tool) Workflow tool configuration including name, label, description, parameters, and the source workflow app ID

Outputs

Name Type Description
Collection[] array Array of tool provider objects with id, name, author, label, icon, description, type, team_credentials, is_team_authorization, allow_delete, labels, and optional plugin_id
Tool[] array Array of tool objects within a provider, each with identity (name, label, description), parameter schemas, and invocation metadata

Dependencies

Dependency Purpose
@/service/base (get) HTTP GET requests for list and detail retrieval
@/service/base (post) HTTP POST requests for credential updates and provider creation
./_tools_util (buildProviderQuery) Query string builder for custom and model tool provider name encoding

Usage Examples

import {
  fetchCollectionList,
  fetchBuiltInToolList,
  updateBuiltInToolCredential,
  createWorkflowToolProvider,
} from '@/service/tools'

// 1. List all tool providers in the workspace
const collections = await fetchCollectionList()
console.log(collections.map(c => `${c.name} (${c.type})`))
// ["google_search (builtin)", "my_api (api)", "my_workflow (workflow)", ...]

// 2. Get tools from a built-in provider
const builtInTools = await fetchBuiltInToolList('google_search')
console.log(builtInTools.map(t => t.name))
// ["google_search", "google_news"]

// 3. Configure credentials for a built-in provider
await updateBuiltInToolCredential('google_search', {
  api_key: 'AIzaSy...your_google_api_key',
  search_engine_id: 'a1b2c3d4e5f...',
})

// 4. Publish a workflow as a tool
await createWorkflowToolProvider({
  workflow_app_id: 'app-abc123',
  name: 'data_enrichment',
  label: 'Data Enrichment',
  description: 'Enriches contact data using multiple sources',
  parameters: [
    { name: 'email', type: 'string', required: true, description: 'Contact email address' },
  ],
})

Related Pages

Implements Principle

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment