/**
* 工具定義(靜態)
* 這些定義會在 MCP Server 啟動時載入
* 實際執行會轉發到 Cloud Run Backend
*/
/**
* 共用的 _intent 欄位定義
* 讓 Claude 填入操作意圖,方便日誌追蹤
*/
const intentProperty = {
_intent: {
type: 'string',
description: '【必填】用一句話描述這次操作的目的,例如「查詢今年贏單商機」、「更新客戶聯絡資訊」。這會記錄在審計日誌中。',
},
}
export const toolDefinitions = [
// Odoo 工具
{
name: 'odoo_search',
description: '搜尋 Odoo 資料',
inputSchema: {
type: 'object',
properties: {
...intentProperty,
model: { type: 'string', description: 'Odoo 模型名稱,例如 res.partner, product.product, purchase.order' },
domain: { type: 'array', description: '搜尋條件,Odoo domain 格式' },
fields: { type: 'array', items: { type: 'string' }, description: '要返回的欄位列表' },
limit: { type: 'number', description: '返回記錄數量限制,預設 20', default: 20 },
offset: { type: 'number', description: '跳過的記錄數(分頁用)', default: 0 },
order: { type: 'string', description: '排序方式,例如 "name asc" 或 "create_date desc"' },
},
required: ['model'],
},
},
{
name: 'odoo_read',
description: '讀取指定 ID 的 Odoo 記錄',
inputSchema: {
type: 'object',
properties: {
...intentProperty,
model: { type: 'string', description: 'Odoo 模型名稱' },
ids: { type: 'array', items: { type: 'number' }, description: '記錄 ID 列表' },
fields: { type: 'array', items: { type: 'string' }, description: '要返回的欄位列表' },
},
required: ['model', 'ids'],
},
},
{
name: 'odoo_count',
description: '計算符合條件的 Odoo 記錄數',
inputSchema: {
type: 'object',
properties: {
...intentProperty,
model: { type: 'string', description: 'Odoo 模型名稱' },
domain: { type: 'array', description: '搜尋條件' },
},
required: ['model'],
},
},
{
name: 'odoo_create',
description: '建立 Odoo 記錄(僅 admin/assistant 可用)',
inputSchema: {
type: 'object',
properties: {
...intentProperty,
model: { type: 'string', description: 'Odoo 模型名稱' },
values: { type: 'object', description: '要建立的欄位和值' },
},
required: ['model', 'values'],
},
},
{
name: 'odoo_update',
description: '更新 Odoo 記錄(僅 admin/assistant 可用)',
inputSchema: {
type: 'object',
properties: {
...intentProperty,
model: { type: 'string', description: 'Odoo 模型名稱' },
ids: { type: 'array', items: { type: 'number' }, description: '要更新的記錄 ID 列表' },
values: { type: 'object', description: '要更新的欄位和值' },
},
required: ['model', 'ids', 'values'],
},
},
{
name: 'odoo_delete',
description: '刪除 Odoo 記錄(僅 admin/assistant 可用)',
inputSchema: {
type: 'object',
properties: {
...intentProperty,
model: { type: 'string', description: 'Odoo 模型名稱' },
ids: { type: 'array', items: { type: 'number' }, description: '要刪除的記錄 ID 列表' },
},
required: ['model', 'ids'],
},
},
// Shopify 工具
{
name: 'shopify_search_products',
description: '搜尋 Shopify 產品',
inputSchema: {
type: 'object',
properties: {
...intentProperty,
query: { type: 'string', description: '搜尋關鍵字(產品名稱、SKU 等)' },
limit: { type: 'number', description: '返回數量限制,預設 20', default: 20 },
cursor: { type: 'string', description: '分頁游標(用於取得下一頁)' },
},
},
},
{
name: 'shopify_get_product',
description: '取得單一 Shopify 產品詳情',
inputSchema: {
type: 'object',
properties: {
...intentProperty,
id: { type: 'string', description: '產品 ID(格式:gid://shopify/Product/xxxxx)' },
},
required: ['id'],
},
},
{
name: 'shopify_update_product',
description: '更新 Shopify 產品(僅 admin/assistant 可用)',
inputSchema: {
type: 'object',
properties: {
...intentProperty,
id: { type: 'string', description: '產品 ID' },
title: { type: 'string', description: '新產品名稱' },
bodyHtml: { type: 'string', description: '產品描述(HTML)' },
status: { type: 'string', enum: ['ACTIVE', 'DRAFT', 'ARCHIVED'], description: '產品狀態' },
},
required: ['id'],
},
},
{
name: 'shopify_update_price',
description: '更新 Shopify 產品變體價格(僅 admin/assistant 可用)',
inputSchema: {
type: 'object',
properties: {
...intentProperty,
variantId: { type: 'string', description: '變體 ID(格式:gid://shopify/ProductVariant/xxxxx)' },
price: { type: 'string', description: '新價格' },
},
required: ['variantId', 'price'],
},
},
{
name: 'shopify_get_locations',
description: '取得 Shopify 庫存位置列表',
inputSchema: {
type: 'object',
properties: {
...intentProperty,
},
},
},
// 知識庫工具
{
name: 'knowledge_search',
description: '搜尋產品知識庫',
inputSchema: {
type: 'object',
properties: {
...intentProperty,
query: { type: 'string', description: '搜尋關鍵字' },
category: { type: 'string', enum: ['tiles', 'flooring', 'bathroom', 'countertops'], description: '產品分類(可選)' },
repo: { type: 'string', enum: ['internal', 'alliance', 'all'], description: '搜尋範圍,預設為 all', default: 'all' },
limit: { type: 'number', description: '返回數量限制,預設 20', default: 20 },
},
required: ['query'],
},
},
{
name: 'knowledge_get_file',
description: '讀取知識庫檔案內容',
inputSchema: {
type: 'object',
properties: {
...intentProperty,
repo: { type: 'string', enum: ['internal', 'alliance', 'products'], description: '來源 repo' },
path: { type: 'string', description: '檔案路徑' },
},
required: ['repo', 'path'],
},
},
{
name: 'knowledge_list_directory',
description: '列出知識庫目錄內容',
inputSchema: {
type: 'object',
properties: {
...intentProperty,
repo: { type: 'string', enum: ['internal', 'alliance', 'products'], description: '來源 repo' },
path: { type: 'string', description: '目錄路徑(可選,預設為根目錄)' },
},
required: ['repo'],
},
},
{
name: 'knowledge_get_price',
description: '查詢產品價格(含成本,僅內部可用)',
inputSchema: {
type: 'object',
properties: {
...intentProperty,
sku: { type: 'string', description: '產品 SKU' },
},
required: ['sku'],
},
},
{
name: 'knowledge_search_spec',
description: '搜尋產品規格',
inputSchema: {
type: 'object',
properties: {
...intentProperty,
query: { type: 'string', description: '搜尋關鍵字(產品名、規格等)' },
category: { type: 'string', enum: ['tiles', 'flooring', 'bathroom', 'countertops'], description: '產品分類' },
},
required: ['query'],
},
},
// FX-CRM 工具
{
name: 'fxcrm_query',
description: '查詢 FX-CRM 物件(商機、客戶、採購單等)',
inputSchema: {
type: 'object',
properties: {
...intentProperty,
object_api_name: { type: 'string', description: 'FX-CRM 物件 API 名稱,如 NewOpportunityObj, AccountObj, purchase_plan__c' },
filters: {
type: 'array',
items: {
type: 'object',
properties: {
field_name: { type: 'string' },
field_values: { type: 'array' },
operator: { type: 'string', enum: ['EQ', 'NE', 'GT', 'LT', 'GTE', 'LTE', 'LIKE', 'IN', 'CONTAIN'] },
},
required: ['field_name', 'field_values', 'operator'],
},
description: '過濾條件'
},
field_projection: { type: 'array', items: { type: 'string' }, description: '要返回的欄位' },
limit: { type: 'number', description: '返回數量限制,預設 20', default: 20 },
offset: { type: 'number', description: '跳過數量', default: 0 },
},
required: ['object_api_name'],
},
},
{
name: 'fxcrm_get',
description: '取得單一 FX-CRM 記錄',
inputSchema: {
type: 'object',
properties: {
...intentProperty,
object_api_name: { type: 'string', description: 'FX-CRM 物件 API 名稱' },
record_id: { type: 'string', description: '記錄 ID' },
field_projection: { type: 'array', items: { type: 'string' }, description: '要返回的欄位' },
},
required: ['object_api_name', 'record_id'],
},
},
{
name: 'fxcrm_create',
description: '建立 FX-CRM 記錄(需相應權限)',
inputSchema: {
type: 'object',
properties: {
...intentProperty,
object_api_name: { type: 'string', description: 'FX-CRM 物件 API 名稱' },
data: { type: 'object', description: '記錄資料' },
opportunity_id: { type: 'string', description: '關聯商機 ID(用於權限檢查)' },
},
required: ['object_api_name', 'data'],
},
},
{
name: 'fxcrm_update',
description: '更新 FX-CRM 記錄(需相應權限)',
inputSchema: {
type: 'object',
properties: {
...intentProperty,
object_api_name: { type: 'string', description: 'FX-CRM 物件 API 名稱' },
record_id: { type: 'string', description: '記錄 ID' },
data: { type: 'object', description: '要更新的資料' },
opportunity_id: { type: 'string', description: '關聯商機 ID(用於權限檢查)' },
},
required: ['object_api_name', 'record_id', 'data'],
},
},
{
name: 'fxcrm_invalid',
description: '作廢 FX-CRM 記錄(需相應權限)',
inputSchema: {
type: 'object',
properties: {
...intentProperty,
object_api_name: { type: 'string', description: 'FX-CRM 物件 API 名稱' },
record_id: { type: 'string', description: '記錄 ID' },
opportunity_id: { type: 'string', description: '關聯商機 ID(用於權限檢查)' },
},
required: ['object_api_name', 'record_id'],
},
},
]