Chronosfy MCP — Node.js
تثبيت @modelcontextprotocol/sdk. استخدم مفتاح API (crm:write للمثال ده)، أو 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, بتحتاج المدفوعات: الإعداد وكمان المدفوعة: الروابط.
قراءة payment_method_status بشكل منفصل عن حالة الدفع. create_recurrence accepts first_run_at;
الحد الأدنى التلقائي المستمر بيبقى على قيد الحياة بعد التوقف/الاستئناف والتعديلات. انظر /docs/quickstart/renewals عشان التدفق الكامل.
execute_action و trigger_recurrence الحفاظ على اشتراطاتهم المنفصلة 8–200 عقد الشخصية.
قائمة أخطاء الأدوات set isError=true; content[0].text بتحتوي على JSON و structuredContent بتحتوي علي خطأ، رسالة، status_code و حقول/تفاصيل اختيارية. HTTP 200 على MCP النقل ليس نجاح تجاري.
JSON-RPC المشكلة، الأدوات المجهولة وطلبات المهام غير المدعومة هي أخطاء البروتوكول.
أدوات PSP: get_payment_settings, list_payment_providers, get_payment_webhook_url و set_payment_settings بتحتاج مالك بشري حالي. الحفظ، الحصول. reauth_token من POST /auth/reauth مع
العمليات".PUT /settings/payment" ونقله set_payment_settings باستخدام نفس كلمة المرور JWT.
الـ five-minute الدليل بيتم استهلاكه مرة واحدة، بما فيهم الحفظ الفاشل. 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})