开发者文档

Chronosfy MCP — Node.js

安装 @modelcontextprotocol/sdk。使用一个范围 API 这个例子中,我们使用了一个简单的例子。 JWT 获得 POST /auth/login. 相同的授权标头适用于 HTTP 以及 MCP.
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
import { StreamableHTTPClientTransport } from '@modelcontextprotocol/sdk/client/streamableHttp.js';
const base = 'https://chronosfy.com/api';
const authorization = process.env.CHRONOSFY_AUTH; // e.g. 'ApiKey ...'; never hardcode secrets
const request_key = 'person:customer-42:v1'; // preserve across retries/restarts
const person = {"name":"Alice","email":"[email protected]","external_id":"customer-42","metadata":{"source":"integration"}};
const client = new Client({ name: 'integration', version: '1' });
await client.connect(new StreamableHTTPClientTransport(new URL(base + '/mcp'), {
  requestInit: { headers: { Authorization: authorization } },
}));
try {
  const result = await client.callTool({ name: 'create_person', arguments: { ...person, request_key } });
  if (result.isError) throw new Error(JSON.stringify(result.structuredContent ?? result.content));
  const replay = await fetch(base + '/crm/persons', { method: 'POST',
    headers: { Authorization: authorization, 'Content-Type': 'application/json', 'Idempotency-Key': request_key },
    body: JSON.stringify(person) });
  if (!replay.ok) throw new Error(await replay.text());
  // Both results identify the same person.
} finally {
  await client.close();
}
使用tools/list 发现工具或 GET /mcp/tools. 两者都使用相同的名称和架构。 使用 create_checkout_session 以及 get_checkout_session 托管或嵌入式 one-off 支付、定期注册和卡片存储。 参见 /docs/quickstart/checkout. create_person, create_action 以及 create_recurrence 接受可选 request_key (8–128 letters/digits/._:-). 每次定期发送邮件时,系统都会使用所选个人或公司当时登记的电子邮箱地址。 `subject_type: "company"` · `subject_id` create_payment_link 需要它。 只对相同的逻辑请求和有效载荷重复使用密钥。 create_payment_link 接受 save_payment_method 以及 set_as_default,需要payments:setup 和 payments:links。 单独读取 payment_method_status 和付款状态。 create_recurrence 接受 first_run_at; 其持续的自动下限在暂停/恢复和编辑后仍然存在。 完整流程请参见 /docs/quickstart/renewals 。 execute_action 和 trigger_recurrence 保留其单独的要求 8–200 性格合同。 工具失败设置为 isError=true;content[0 ] . text 包含 JSON,structuredContent 包包括 error、message、status_code 和可选字段/详细信息。MCP 传输上的 HTTP 200 不是商业成功。 错误的 JSON-RPC、未知工具和不支持的任务请求是协议错误。 PSP工具: get_payment_settings, list_payment_providers, get_payment_webhook_url 以及 set_payment_settings 需要一个当前的人类所有者。要保存,获得 reauth_token 从 POST /auth/reauth 与 operation="PUT /settings/payment " , 并使用相同的登录 JWT 将其传递给 set_payment_settings。 五分钟验证仅消耗一次,包括失败保存。API密钥/服务令牌无法管理PSP凭证。 切勿在提示、日志或共享对话历史记录中包含秘密;使用可信客户端提供凭据。 RSVP organizers use /mcp with rsvp:read or rsvp:write. Create an event with create_rsvp_event, open it with update_rsvp_event, then use add_rsvp_invitees and send_rsvp_invitations. Provide request_key on MCP sends or Idempotency-Key on REST sends. Reuse the same key and guest IDs on a network retry. The receipt lists each guest's dispatch state. A dispatching or unknown delivery needs reconciliation before explicitly sending a new batch. A guest can connect to POST /rsvp/guest/mcp using the invitation UUID as a bearer credential. open_rsvp_invitation, respond_to_rsvp_invitation and open_rsvp_pass return the guest's private URL. The person confirms or declines there. The organizer scans the pass with check_in_rsvp_qr. For email delivery, use get_email_stats and list_email_recipients with action_id, page and limit for the list. Platform operators connect to POST /admin/mcp using their named X-Platform-Admin-Token header. GET /admin/mcp/tools and GET /admin/openapi.json return only the operations granted to that operator. ## 默认支付服务商 保存凭据会保留当前的默认设置,添加首个服务商时也是如此。租户所有者需要选择一个已保存的账户并确认,才能将其用于新的默认支付。在设置默认服务商前,也可以在结账时明确指定服务商。
GET /api/settings/payment
Authorization: Bearer <owner_access_token>

POST /api/auth/reauth
Authorization: Bearer <owner_access_token>
Content-Type: application/json

{"password":"<password>","operation":"PUT /settings/payment/default"}

PUT /api/settings/payment/default
Authorization: Bearer <owner_access_token>
X-Reauth-Token: <reauth_token>
Content-Type: application/json

{"config_id":"<configurations[].config_id>"}
MCP: set_default_payment_provider({config_id, reauth_token})