> ## Documentation Index
> Fetch the complete documentation index at: https://datagen.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# MCP 工具參考

> 所有 DataGen MCP 工具的完整參數參考

## 程式碼執行

### executeCode

在遠端沙盒中執行可整合 MCP 工具的 Python 程式碼。

| 參數 | 型別 | 必填 | 預設值 | 說明 |
| - | - | - | - | - |
| `script` | string | 是 | -- | 要執行的 Python 程式碼 |
| `name` | string | 否 | -- | 用於追蹤的描述性名稱 |
| `description` | string | 否 | -- | 簡述程式碼的用途 |
| `session_id` | string | 否 | -- | 用來將相關執行分組的 session ID |
| `input_vars` | object | 否 | -- | 腳本中可使用的變數 |
| `output_vars` | object | 否 | -- | 預期的輸出變數與型別 |
| `required_tools` | string\[] | 否 | -- | 需要的 MCP 工具（例如 `["mcp_Supabase_list_projects"]`） |
| `additional_imports` | string\[] | 否 | -- | 要匯入的 PyPI 套件（只填套件名稱） |
| `local` | boolean | 否 | -- | 在本機執行（true）或在 E2B 沙盒中執行（false） |
| `mcp_server_names` | string\[] | 否 | -- | 要啟動的 MCP server（可縮短啟動時間） |
| `timeout` | number | 否 | 300 | 執行逾時秒數（30-300） |
| `required_secrets` | string\[] | 否 | -- | 要注入為 Python 變數的 secret 名稱 |

**注意：** 支援 Python 3.12，且僅支援同步程式碼。HTTP 請求請使用 `httpx`（不要用 `requests`）。I/O 密集的工作請使用 `ThreadPoolExecutor`。

***

## 自訂工具管理

### createCustomTool

將 Python 工作流程部署為可重複使用的 API 端點。

| 參數 | 型別 | 必填 | 預設值 | 說明 |
| - | - | - | - | - |
| `script` | string | 是 | -- | 要部署的 Python 程式碼 |
| `deployment_name` | string | 是 | -- | API 名稱（例如 `sync_supabase_to_heyreach`） |
| `description` | string | 是 | -- | 自訂工具的用途 |
| `input_schema` | object | 否 | -- | 用於輸入驗證的 OpenAPI/JSON Schema |
| `output_variables` | string\[] | 否 | -- | 輸出變數名稱（例如 `["result", "status"]`） |
| `required_tools` | string\[] | 否 | -- | 需要的 MCP 工具 |
| `additional_imports` | string\[] | 否 | -- | Python 套件（只填名稱，不含版本） |
| `deployment_type` | `"private"` \| `"public"` | 否 | `"private"` | 可見性 |
| `is_code_public` | boolean | 否 | false | 公開時是否顯示原始碼 |
| `local` | boolean | 否 | -- | 在本機或 E2B 沙盒中執行 |
| `mcp_server_names` | string\[] | 否 | -- | 工具所屬的 MCP server 名稱 |
| `default_input_vars` | object | 否 | -- | 輸入變數的預設值 |
| `required_secrets` | string\[] | 否 | -- | 來自 secret 管理的 secret 名稱 |

**回傳：** 成功時回傳 `deployment_uuid`。

### updateCustomTool

更新既有的自訂工具。只會更新有提供的欄位。

| 參數 | 型別 | 必填 | 預設值 | 說明 |
| - | - | - | - | - |
| `custom_tool_uuid` | string | 是 | -- | 要更新之工具的 UUID |
| `name` | string | 否 | -- | 更新後的名稱 |
| `description` | string | 否 | -- | 更新後的說明 |
| `final_code` | string | 否 | -- | 更新後的 Python 程式碼 |
| `input_schema` | object | 否 | -- | 更新後的輸入 schema |
| `output_variables` | string\[] | 否 | -- | 更新後的輸出變數名稱 |
| `default_input_vars` | object | 否 | -- | 更新後的預設輸入值 |
| `additional_imports` | string\[] | 否 | -- | 更新後的 Python 匯入套件 |
| `expected_tools` | string\[] | 否 | -- | 更新後需要的 MCP 工具 |
| `required_secrets` | string\[] | 否 | -- | 更新後需要的 secret |
| `is_code_public` | boolean | 否 | -- | 切換原始碼可見性 |
| `deployment_type` | `"private"` \| `"public"` | 否 | -- | 切換部署可見性 |
| `mcp_server_names` | string\[] | 否 | -- | 更新後的 MCP server 名稱 |

### getCustomToolDetails

取得自訂工具的完整規格、程式碼、輸入範例與 curl 指令。

| 參數 | 型別 | 必填 | 預設值 | 說明 |
| - | - | - | - | - |
| `custom_tool_uuid` | string | 是 | -- | 自訂工具的 UUID |
| `brief` | boolean | 否 | false | 設為 true 時只回傳基本資訊（名稱、說明、schema） |

### submitCustomToolRun

以非同步方式執行已部署的自訂工具。回傳 `run_uuid`，可用 `checkRunStatus` 監控。

| 參數 | 型別 | 必填 | 預設值 | 說明 |
| - | - | - | - | - |
| `custom_tool_uuid` | string | 是 | -- | 要執行之自訂工具的 UUID |
| `input_vars` | object | 否 | -- | 輸入資料（例如 `{"url": "https://example.com", "count": 10}`） |

### checkRunStatus

自動輪詢，監控自訂工具執行的進度與結果。

| 參數 | 型別 | 必填 | 預設值 | 說明 |
| - | - | - | - | - |
| `run_uuid` | string | 否 | -- | 來自 `submitCustomToolRun` 的 run UUID |
| `custom_tool_uuid` | string | 否 | -- | 用來找出最近一次執行的自訂工具 UUID |
| `timeout_seconds` | number | 否 | 180 | 最長等待時間（上限 600） |
| `poll_interval_seconds` | number | 否 | 5 | 每次檢查間隔秒數（2-30） |

請提供 `run_uuid` 或 `custom_tool_uuid` 其中之一。

***

## 工具探索與執行

### searchTools

依功能、關鍵字或提供者尋找工具。

| 參數 | 型別 | 必填 | 預設值 | 說明 |
| - | - | - | - | - |
| `query` | string | 是 | -- | 你想完成的事（例如 "send email"） |
| `provider` | string | 否 | -- | 依提供者篩選（例如 "Supabase"、"GitHub"） |
| `limit` | number | 否 | 10 | 最多回傳筆數（1-100） |
| `offset` | number | 否 | 0 | 分頁時略過前 N 筆結果 |

### getToolDetails

取得特定工具的完整文件。

| 參數 | 型別 | 必填 | 預設值 | 說明 |
| - | - | - | - | - |
| `tool_name` | string | 是 | -- | 工具的確切名稱（例如 `mcp_Supabase_execute_sql`） |

### executeTool

以別名執行任何 MCP 工具或預設工具。

| 參數 | 型別 | 必填 | 預設值 | 說明 |
| - | - | - | - | - |
| `tool_alias_name` | string | 是 | -- | 工具別名（例如 `mcp_github_search_repositories`） |
| `parameters` | object | 否 | -- | 以鍵值對傳入的參數 |

***

## MCP Server 管理

### addRemoteMcpServer

連接外部 MCP server。支援以範本連接（自動處理 OAuth）或手動填入 URL。

| 參數 | 型別 | 必填 | 預設值 | 說明 |
| - | - | - | - | - |
| `template_id` | string | 否 | -- | 預先設定 server 的範本 ID（例如 `linear-mcp`） |
| `server_name` | string | 否 | -- | 顯示名稱（CamelCase，例如 `GoogleDrive`） |
| `server_url` | string | 否 | -- | Server 端點 URL |
| `credentials` | object | 否 | -- | 範本所需的 API key/token |

請提供 `template_id`，或同時提供 `server_name` 與 `server_url`。

### searchBuiltInServers

瀏覽預先設定的 MCP server 範本。

| 參數 | 型別 | 必填 | 預設值 | 說明 |
| - | - | - | - | - |
| `name` | string | 否 | -- | 依名稱篩選（不分大小寫的子字串比對） |

### getBuiltInServerDetails

取得內建 server 範本的完整設定細節。

| 參數 | 型別 | 必填 | 預設值 | 說明 |
| - | - | - | - | - |
| `template_id` | string | 是 | -- | 來自 `searchBuiltInServers` 的範本 ID |

### checkRemoteMcpOauthStatus

從 `addRemoteMcpServer` 取得授權 URL 後，輪詢 OAuth 是否完成。

| 參數 | 型別 | 必填 | 預設值 | 說明 |
| - | - | - | - | - |
| `flow_id` | string | 是 | -- | 來自 `addRemoteMcpServer` 的 OAuth flow ID |
| `timeout_seconds` | number | 否 | 120 | 最長等待時間（上限 300） |

### ReAuthRemoteMcpServer

為 OAuth token 已過期的既有 MCP server 重新驗證。

| 參數 | 型別 | 必填 | 預設值 | 說明 |
| - | - | - | - | - |
| `server_name` | string | 是 | -- | Server 名稱（CamelCase，例如 `GitHub`） |

### updateRemoteMcpServer

更新既有 MCP server 的 URL 與憑證。

| 參數 | 型別 | 必填 | 預設值 | 說明 |
| - | - | - | - | - |
| `server_name` | string | 是 | -- | Server 名稱（CamelCase） |
| `server_url` | string | 是 | -- | 新的端點 URL |
| `env_args` | object | 是 | -- | 更新後的環境變數/設定 |

***

## 公用工具

### datagen-sdk-doc

從 GitHub 取得 DataGen Python SDK 文件。回傳不含圖片的 README 內容。

**參數：** 無


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.