Skip to content

MCP Services / MCP Functions

Added in version 7.5.0

"MCP Functions" is a feature of DataFlux Func that supports AI Agents in calling functions in Func.

Users can provide some functions in DataFlux Func to AI Agents through MCP Services.

1. Integration Steps

Follow the steps below to connect MCP clients / AI Agents to the MCP Services of DataFlux Func.

1.1 Create an Access Token

To access the MCP Services of DataFlux Func, you need to create an Access Token and enable the "MCP Functions" feature.

You can also specify the functions to be exposed in the rules, such as by the value of the category field.

add-access-token.png

add-access-token-2.png

1.2 Permission Rules

Permission rules can be edited manually. They are matched sequentially from top to bottom, and permissions are determined according to the first matching rule.

Examples:

Rules (exact ID match) Allowed Functions
category:math Functions with category set to math
scriptSet:mytest Functions belonging to the mytest script set
script:mytest__demo Functions belonging to the mytest__demo script
func:mytest__demo.func The function with the ID mytest__demo.func
Rules (wildcard ID) Allowed Functions
scriptSet:myte* Functions matching myte* by script set ID
script:mytest__de* Functions matching mytest__de* by script ID
func:mytest__demo.fu* Functions matching mytest__demo.fu* by function ID
Rules (prohibited) Prohibited Functions
!category:math Functions with category set to math

1.3 Configure MCP Clients

The MCP Services of DataFlux Func follow the MCP specification

Before actual integration, it is recommended to use MCP Inspector for debugging.

Add the following configuration in MCP clients / AI Agents:

Configuration Item Value
URL {DataFlux Func access address}/mcp
or /mcp2 or /mcp3
See "MCP Server Mode" below for specific differences.
Request Header X-Dff-Access-Token: atk-xxxxx:xxxxx
Example: OpenCode configuration
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
{
  "mcp": {
    "dataflux-func-mcp": {
      "enabled": true,
      "type"   : "remote",
      "url"    : "{DataFlux Func access address}/mcp",
      "headers": {
        "X-Dff-Access-Token": "atk-xxxxx:xxxxx"
      }
    }
  }
}

Restart the AI Agent after modifying the configuration

Many AI Agents only load MCP Service configurations at startup. If the new configuration does not take effect after modifying the MCP Service configuration, restart the AI Agent. For example, when using AI Agent plugins such as Codex in VS Code, you can enter >Reload Window by pressing Ctrl + P to reload the window.

2. MCP Server Mode

The MCP Services of DataFlux Func support 3 modes based on different access paths:

Path Mode
/mcp Basic Mode
/mcp2 List-Call Mode
/mcp3 Search-Call Mode* (recommended) *

Assume that the Access Token is configured as follows, and that the following functions exist in the codebase:

Prohibit category:test and allow category:math
1
2
!category:test
category:math

code.png

2.1 /mcp Basic Mode

List all available functions directly as Tools.

Note: When the function list changes, the client must reconnect to update the list.

2.2 /mcp2 List-Call Mode

Only two Tools are provided:

  • list-func: List functions
  • call-func: Call functions

A dynamic function list can be implemented, but the AI Agent / model must be able to properly follow the List-Call method for invocation.

2.3 /mcp3 Search-Call Mode

Only two Tools are provided:

  • search-func: Search for functions
  • call-func: Call functions

Functions can be queried by keywords, but the AI Agent / model must be able to properly follow the Search-Call method for invocation.

When there are many functions, the context length can be significantly reduced.