Skip to content

MCP Services / MCP Coding

Added in version 7.6.0

MCP Coding is a feature of DataFlux Func that supports AI Agents in writing and managing Scripts in Func.

Users can allow AI Agents to participate in writing and managing functions in DataFlux Func through MCP Services.

1. Connection Steps

Follow the steps below to connect an MCP client / AI Agent to DataFlux Func's MCP Coding service.

1.1 Create an Access Token

Accessing DataFlux Func's MCP Coding service requires creating an Access Token and enabling the MCP Coding feature.

And you can specify the functions to be exposed in the rules (e.g., by Script Set ID).

add-access-token.png

add-access-token-2.png

1.2 Permission Rules

Permission rules can be manually edited and are matched from top to bottom; the first matching rule determines the permission. Objects not matched by any rule are inaccessible. Blank lines and # comments are preserved when saving, and comments are ignored during matching.

r (Read), w (Modify), x (Execute), and p (Publish) are independent and can be combined as needed. When saving, they are uniformly arranged in the order r, w, x, p.

Examples:

Rule (Exact Match ID) Match Target Match ID Permission
scriptSet:mytest:r Script Set mytest Read
scriptSet:mytest:rw Script Set mytest Read, Modify
scriptSet:mytest:rwx Script Set mytest Read, Modify, Execute
scriptSet:mytest:rwp Script Set mytest Read, Modify, Publish
scriptSet:mytest:rwxp Script Set mytest Read, Modify, Execute, Publish
script:mytest__demo:r Script mytest__demo Read
Rule (Wildcard ID) Match Target Wildcard ID Permission
scriptSet:my*:r Script Set Match my* as wildcard Read
script:mytest__de*:r Script Match mytest__de* as wildcard Read

Script Set rules also cover their subordinate Scripts. For Scripts, executing a draft uses the x permission, and publishing uses the p permission; publishing runs the platform's Script pre-check but does not require the x permission or prior execution of the draft.

When creating a Func API or Cron Job, or replacing their bound funcId, in addition to the w permission for the corresponding resource, the x permission for the Script to which the target function belongs is also required, because these resources will execute that function.

As of version 8.1.19, authenticated MCP Coding clients can query installed third-party Python packages and their effective versions. This requires no resource scope, and can be queried even if the rules are empty; this does not grant access to Scripts, files, or other resources.

1.3 Configure the MCP Client

DataFlux Func's MCP Services follow the MCP specification

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

Add the following configuration to the MCP client / AI Agent:

Configuration Item Value
URL {DataFlux Func access address}/mcp/coding
Request Header X-Dff-Access-Token: atk-xxxxx:xxxxx

As of version 8.1.21, the decompressed MCP request body is limited to a maximum of 4 MiB by default, and the total number of tool input elements is limited to a default maximum of 10000. To adjust these limits, configure the corresponding parameters in the configuration file config.yaml; see Deployment and Maintenance / Configuration File / Basic and Web Services.

Example: OpenCode Configuration
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
{
  "mcp": {
    "dataflux-func-mcp-coding": {
      "enabled": true,
      "type"   : "remote",
      "url"    : "{DataFlux Func access address}/mcp/coding",
      "headers": {
        "X-Dff-Access-Token": "atk-xxxxx:xxxxx"
      }
    }
  }
}
Example: Codex Configuration
1
2
3
4
[mcp_servers.dataflux-func-mcp-coding]
enabled      = true
url          = "{DataFlux Func access address}/mcp/coding"
http_headers = { "X-Dff-Access-Token" = "atk-xxxxx:xxxxx" }
Example: Claude Code Configuration
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
{
  "mcpServers": {
    "dataflux-func-mcp-coding": {
      "type": "http",
      "url": "{DataFlux Func access address}/mcp/coding",
      "headers": {
        "X-Dff-Access-Token": "atk-xxxxx:xxxxx"
      }
    }
  }
}
Example: Generic JSON Configuration
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
{
  "mcpServers": {
    "dataflux-func-mcp-coding": {
      "url": "{DataFlux Func access address}/mcp/coding",
      "headers": {
        "X-Dff-Access-Token": "atk-xxxxx:xxxxx"
      }
    }
  }
}

2. Practical Usage Examples

After configuration, first confirm in the MCP client that you have successfully connected to DataFlux Func's MCP Coding service:

opencode-mcp-status.png

After successful connection, directly describe the task to be completed, and specify the target Script Set, Script, or function, as well as whether execution or publishing is needed. For example:

  • Synchronize all code in the Script Set demo
  • Modify the function in Script demo__test and only save the draft
  • Query the failure task records of the function demo__test.run for the last day and analyze the error causes
  • Query the effective versions of the installed requests and PyYAML to confirm Script dependencies

When querying task records, you need to configure the r permission for the Script to which the Access Token belongs (or inherit it from the Script Set), or the r permission for the corresponding Func API; Cron Job records can also be read with the r / x permission of the corresponding Cron Job.

Python package queries only read the metadata of installed packages and do not install, upgrade, or execute packages. When the built-in version and the version installed via the PIP tool coexist, the built-in version preferred by the standard Worker is returned. For details, see Script Development / Installing Third-Party Packages.

After entering the task, you can view the processing progress and results in the client:

opencode-process.png

opencode-process-2.png

After the code modifications are complete, refresh in DataFlux Func to view the modification results. When only saving a draft, the effective code is not affected; after confirming the modifications, publish the Script.

code.png