@alfe.ai/mcp-server 0.2.5 → 0.2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ import { Transport } from "@modelcontextprotocol/sdk/shared/transport.js";
2
3
  import { ChangelogEntry, EncryptedEnvelopeV1, FieldEnvelope, FieldFormat, FieldSensitivity, GeneratedDataKey, IntegrationConfigResult, IntegrationInstall, RegistryEntry, ScopeInfo, SecretAggregate, SecretCategory, SecretMetadata, SecretScope } from "@alfe/types";
3
4
 
4
5
  //#region ../agent-api-client/dist/index.d.ts
@@ -29,26 +30,32 @@ declare class AgentApiTransport {
29
30
  * `Content-Type: application/json` and parses a `{ data: T }` envelope,
30
31
  * neither of which fits a raw-audio flow (voice TTS/STT), so those go
31
32
  * through this instead. Auth (Bearer), the request budget, and the single
32
- * retry on transient 5xx / network errors are kept in sync with
33
- * `request()`. Retries fire only on statuses produced BEFORE the route
34
- * handler runs (authorizer-timeout 500 + LB 502/503/504), so re-issuing a
35
- * POST does not risk a duplicate side effect.
33
+ * retry policy on transient 5xx / network errors is kept in sync with
34
+ * `request()`. Safe read methods retry once by default; mutation methods do
35
+ * not, because a response can be lost after a handler or provider call has
36
+ * already succeeded.
36
37
  */
37
38
  rawRequest(path: string, init: {
38
39
  method: string;
39
40
  headers: Headers;
40
41
  body?: BodyInit | Uint8Array;
42
+ }, extra?: {
43
+ retry?: boolean;
41
44
  }): Promise<Response>;
42
45
  /**
43
46
  * @param extra.timeoutMs Per-request abort timeout (default REQUEST_TIMEOUT_MS).
44
47
  * Long endpoints (image generation) pass a larger value so the gateway's
45
48
  * own timeout wins with a readable status instead of a client-side abort.
46
- * @param extra.retry Whether to retry once on transient failures (default
47
- * true). Expensive/non-idempotent endpoints pass false.
49
+ * @param extra.retry Whether to retry once on transient failures. Safe reads
50
+ * (GET/HEAD/OPTIONS) default to true; mutations default to false. Set true
51
+ * only when the endpoint's server-side contract is explicitly idempotent.
52
+ * @param extra.signal Optional caller cancellation combined with the client's
53
+ * own timeout budget. Aborting either signal cancels the request.
48
54
  */
49
55
  request<T>(path: string, options?: RequestInit, extra?: {
50
56
  timeoutMs?: number;
51
57
  retry?: boolean;
58
+ signal?: AbortSignal;
52
59
  }): Promise<T>;
53
60
  }
54
61
  /**
@@ -64,7 +71,7 @@ declare class ApiBase {
64
71
  //# sourceMappingURL=transport.d.ts.map
65
72
  //#endregion
66
73
  //#region src/domains/workspace.d.ts
67
- /** Response of GET /agents/me/workspace (services/agents). */
74
+ /** Response of GET /agent/workspace (services/agents). */
68
75
  interface AgentWorkspaceInfo {
69
76
  templateKey?: string;
70
77
  defaultModel?: string;
@@ -92,7 +99,7 @@ interface AgentWorkspaceInfo {
92
99
  }
93
100
  declare class WorkspaceApi extends ApiBase {
94
101
  /**
95
- * GET /agents/me/workspace — workspace config for the authenticated agent
102
+ * GET /agent/workspace — workspace config for the authenticated agent
96
103
  * (template assignment, default model, org roster).
97
104
  */
98
105
  getWorkspace(): Promise<AgentWorkspaceInfo>;
@@ -235,6 +242,8 @@ declare class SyncApi extends ApiBase {
235
242
  sharedListFiles(args: {
236
243
  scope: "org" | "team" | "project";
237
244
  scopeId: string;
245
+ limit?: number;
246
+ cursor?: string;
238
247
  }): Promise<{
239
248
  files: SharedFileEntry[];
240
249
  nextCursor: string | null;
@@ -394,7 +403,9 @@ declare class KnowledgeApi extends ApiBase {
394
403
  * from `services/org`, then fetches the bytes directly from S3 (the one
395
404
  * legitimate raw fetch in a plugin — same pattern as sync).
396
405
  */
397
- readScopeDoc(scopeType: KnowledgeScopeType, scopeId: string, filePath: string): Promise<{
406
+ readScopeDoc(scopeType: KnowledgeScopeType, scopeId: string, filePath: string, opts?: {
407
+ maxBytes?: number;
408
+ }): Promise<{
398
409
  filePath: string;
399
410
  text: string;
400
411
  }>;
@@ -433,15 +444,11 @@ interface MobileAvailableNumber {
433
444
  }
434
445
  /** Approved WhatsApp content template from GET /mobile/whatsapp/templates. */
435
446
  interface WhatsAppTemplate {
436
- sid: string;
437
- friendlyName: string;
447
+ contentSid: string;
448
+ name: string;
438
449
  language: string;
439
450
  body: string;
440
451
  variables: Record<string, string>;
441
- dateCreated: string;
442
- dateUpdated: string;
443
- approvalStatus?: string;
444
- rejectionReason?: string;
445
452
  category?: string;
446
453
  }
447
454
  declare class MobileApi extends ApiBase {
@@ -689,15 +696,22 @@ declare class SearchApi extends ApiBase {
689
696
  offset?: number;
690
697
  country?: string;
691
698
  freshness?: string;
699
+ }, options?: {
700
+ signal?: AbortSignal;
692
701
  }): Promise<unknown>;
693
702
  searchImages(params: {
694
703
  query: string;
695
704
  count?: number;
705
+ }, options?: {
706
+ signal?: AbortSignal;
696
707
  }): Promise<unknown>;
697
708
  searchNews(params: {
698
709
  query: string;
699
710
  count?: number;
711
+ offset?: number;
700
712
  freshness?: string;
713
+ }, options?: {
714
+ signal?: AbortSignal;
701
715
  }): Promise<unknown>;
702
716
  /** Search news across the selected provider's corpus. → POST /agent/news/search */
703
717
  newsSearch(params: {
@@ -721,6 +735,48 @@ declare class SearchApi extends ApiBase {
721
735
  }
722
736
  //# sourceMappingURL=search.d.ts.map
723
737
  //#endregion
738
+ //#region src/domains/webhooks.d.ts
739
+ interface AgentWebhook {
740
+ webhookId: string;
741
+ tenantId: string;
742
+ agentId: string;
743
+ name: string;
744
+ provider: string;
745
+ active: boolean;
746
+ createdBy: string;
747
+ createdAt: string;
748
+ updatedAt: string;
749
+ }
750
+ interface CreatedAgentWebhook extends AgentWebhook {
751
+ url: string;
752
+ signingSecret: string;
753
+ }
754
+ interface AgentWebhookDelivery {
755
+ deliveryId: string;
756
+ webhookId: string;
757
+ status: string;
758
+ attempts: number;
759
+ createdAt: string;
760
+ deliveredAt?: string;
761
+ }
762
+ declare class WebhooksApi extends ApiBase {
763
+ createWebhook(args: {
764
+ name: string;
765
+ provider?: "generic" | "github" | "stripe" | "slack";
766
+ }): Promise<CreatedAgentWebhook>;
767
+ listWebhooks(): Promise<AgentWebhook[]>;
768
+ deleteWebhook(webhookId: string): Promise<{
769
+ webhookId: string;
770
+ active: false;
771
+ }>;
772
+ rotateWebhookSecret(webhookId: string): Promise<{
773
+ webhookId: string;
774
+ signingSecret: string;
775
+ }>;
776
+ listWebhookDeliveries(webhookId: string): Promise<AgentWebhookDelivery[]>;
777
+ }
778
+ //# sourceMappingURL=webhooks.d.ts.map
779
+ //#endregion
724
780
  //#region src/domains/chat.d.ts
725
781
  declare class ChatApi extends ApiBase {
726
782
  presignAttachments(files: {
@@ -857,8 +913,9 @@ declare class ConnectCredentialsApi extends ApiBase {
857
913
  * selector arg (e.g. `xeroTenantId`) on every credential-touching tool
858
914
  * and look up the matching account by that selector at dispatch time.
859
915
  *
860
- * Returned `accounts[i].accountIdentifier` is the Xero tenantId the
861
- * stable cross-session identifier the LLM should pass.
916
+ * `xeroTenantId` is the model-facing organisation selector. The separate
917
+ * `accountIdentifier` is the Connect persistence key used for refresh and
918
+ * may be an email; never substitute one for the other.
862
919
  */
863
920
  getXeroAccounts(): Promise<{
864
921
  accounts: {
@@ -876,12 +933,12 @@ declare class ConnectCredentialsApi extends ApiBase {
876
933
  expiresAt: string;
877
934
  }>;
878
935
  /**
879
- * Pattern A: refresh a specific Xero connection by its `accountIdentifier`
880
- * (the Xero `tenantId`). The legacy `refreshXeroToken()` only refreshes
881
- * the *primary* connection, which is wrong for multi-tenant Xero where
882
- * each tenant has its own non-interchangeable access token.
936
+ * Refresh a specific Xero Connection by its exact `accountIdentifier` from
937
+ * `getXeroAccounts()`. Do not substitute `xeroTenantId`: current Xero OAuth
938
+ * rows may use the account email as their persistence key even when a sole
939
+ * organisation tenant ID is available in provider metadata.
883
940
  */
884
- refreshXeroAccountToken(xeroTenantId: string): Promise<{
941
+ refreshXeroAccountToken(accountIdentifier: string): Promise<{
885
942
  accessToken: string;
886
943
  accessTokenExpiresAt: string;
887
944
  expiresAt: string;
@@ -1036,6 +1093,21 @@ declare class ConnectCredentialsApi extends ApiBase {
1036
1093
  accessToken: string;
1037
1094
  expiresAt: string;
1038
1095
  }>;
1096
+ /**
1097
+ * Pattern A: refresh one MYOB Connection by its stable
1098
+ * `accountIdentifier` (the MYOB business id returned by
1099
+ * `getMYOBAccounts()`).
1100
+ *
1101
+ * MYOB refresh tokens belong to individual Connection rows. A
1102
+ * multi-business client must use this method instead of refreshing the
1103
+ * primary Connection and copying that access token into every cached
1104
+ * business client.
1105
+ */
1106
+ refreshMYOBAccountToken(accountIdentifier: string): Promise<{
1107
+ accessToken: string;
1108
+ accessTokenExpiresAt: string;
1109
+ expiresAt: string;
1110
+ }>;
1039
1111
  /**
1040
1112
  * @deprecated Returns a single primary credential blob. Use
1041
1113
  * `getSalesforceAccounts()` for the multi-account shape required by
@@ -1098,9 +1170,6 @@ declare class ConnectCredentialsApi extends ApiBase {
1098
1170
  connectedAt: string;
1099
1171
  accessToken: string;
1100
1172
  accessTokenExpiresAt: string;
1101
- refreshToken: string;
1102
- clientId: string;
1103
- clientSecret: string;
1104
1173
  email: string;
1105
1174
  microsoftTenantId: string;
1106
1175
  workspaceDomain: string;
@@ -1206,10 +1275,41 @@ declare class ConnectCredentialsApi extends ApiBase {
1206
1275
  brokerName?: string;
1207
1276
  accountNumber?: string;
1208
1277
  accessToken: string;
1278
+ /**
1279
+ * The stable per-grant Connection key (`ctid:<userId>`) this account
1280
+ * belongs to. Every trading account under one cTrader login shares one
1281
+ * grant (one OAuth token), so this is the identifier the MCP server
1282
+ * passes to `refreshCTraderAccount()` to rotate the token for the whole
1283
+ * grant on a `CH_ACCESS_TOKEN_INVALID` expiry. Empty string when the
1284
+ * server did not supply one (legacy rows) — such an account can still
1285
+ * trade with its current token but cannot self-refresh.
1286
+ */
1287
+ accountIdentifier: string;
1209
1288
  }[];
1210
1289
  clientId: string;
1211
1290
  clientSecret: string;
1212
1291
  }>;
1292
+ /**
1293
+ * Pattern A: refresh a specific cTrader grant by its stable
1294
+ * `accountIdentifier` (`ctid:<userId>` from `getCTraderAccounts()`).
1295
+ *
1296
+ * cTrader access tokens live ~30 days; the `getCTraderAccounts()` /
1297
+ * credentials reads serve the STORED token without refreshing, so refresh is
1298
+ * the consumer's job. `@alfe.ai/ctrader-mcp` calls this when the cTrader Open
1299
+ * API rejects an account-auth with `CH_ACCESS_TOKEN_INVALID`, then re-runs
1300
+ * the socket handshake with the returned `accessToken`.
1301
+ *
1302
+ * Refreshing one grant rotates the single OAuth token that covers EVERY
1303
+ * trading account under that login. cTrader's refresh token itself does not
1304
+ * expire but may rotate on refresh (`rotatesRefreshToken: true`); connect
1305
+ * persists the rotated refresh token server-side, so the caller only needs
1306
+ * the new `accessToken`. Mirrors `refreshXeroAccountToken`.
1307
+ */
1308
+ refreshCTraderAccount(accountIdentifier: string): Promise<{
1309
+ accessToken: string;
1310
+ accessTokenExpiresAt: string;
1311
+ expiresAt: string;
1312
+ }>;
1213
1313
  /**
1214
1314
  * @deprecated Returns a single primary credential blob. Use
1215
1315
  * `getShopifyAccounts()` for the multi-account shape required by Pattern A
@@ -1374,59 +1474,35 @@ declare class IdentityApi extends ApiBase {
1374
1474
  }>;
1375
1475
  mergeIdentities(survivorId: string, args: {
1376
1476
  mergedId: string;
1377
- changedBy: {
1378
- type: string;
1379
- id: string;
1380
- name?: string;
1381
- };
1382
1477
  }): Promise<{
1383
1478
  ok: boolean;
1384
1479
  error?: string;
1385
1480
  }>;
1386
- unmergeIdentity(identityId: string, args: {
1387
- changedBy: {
1388
- type: string;
1389
- id: string;
1390
- name?: string;
1391
- };
1392
- }): Promise<{
1481
+ unmergeIdentity(identityId: string): Promise<{
1393
1482
  ok: boolean;
1394
1483
  error?: string;
1395
1484
  }>;
1396
1485
  addIdentityNote(identityId: string, args: {
1397
1486
  content: string;
1398
1487
  category?: string;
1399
- changedBy: {
1400
- type: string;
1401
- id: string;
1402
- name?: string;
1403
- };
1404
1488
  }): Promise<{
1405
1489
  noteId: string | null;
1406
1490
  }>;
1407
1491
  tagIdentity(identityId: string, args: {
1408
1492
  tag: string;
1409
1493
  action: "add" | "remove";
1410
- changedBy: {
1411
- type: string;
1412
- id: string;
1413
- name?: string;
1414
- };
1415
1494
  }): Promise<{
1416
1495
  ok: boolean;
1417
1496
  }>;
1418
1497
  getIdentityChangelog(identityId: string, args?: {
1419
1498
  limit?: number;
1499
+ cursor?: string;
1420
1500
  }): Promise<{
1421
1501
  entries: unknown[];
1502
+ cursor: string | null;
1422
1503
  }>;
1423
1504
  rollbackIdentity(identityId: string, args: {
1424
1505
  targetVersion: number;
1425
- changedBy: {
1426
- type: string;
1427
- id: string;
1428
- name?: string;
1429
- };
1430
1506
  }): Promise<{
1431
1507
  ok: boolean;
1432
1508
  entry?: unknown;
@@ -1465,7 +1541,7 @@ declare class IdentityApi extends ApiBase {
1465
1541
  verified: boolean;
1466
1542
  identityId?: string;
1467
1543
  /** Phase 2: how the confirm resolved — Scenario A vs B. */
1468
- action?: "merged" | "contact_verified";
1544
+ action?: "merged" | "contact_verified" | "already_confirmed";
1469
1545
  error?: string;
1470
1546
  }>;
1471
1547
  /**
@@ -1597,8 +1673,21 @@ declare class MemoryApi extends ApiBase {
1597
1673
  messageCount: number;
1598
1674
  }>;
1599
1675
  memoryLoadContext(tier?: number, topicHint?: string): Promise<{
1676
+ tier: number;
1677
+ facts: {
1678
+ subject: string;
1679
+ predicate: string;
1680
+ object: string;
1681
+ since: string;
1682
+ }[];
1683
+ memories: {
1684
+ text: string;
1685
+ topic: string;
1686
+ subtopic: string;
1687
+ score: number;
1688
+ }[];
1689
+ tokenEstimate: number;
1600
1690
  formatted: string;
1601
- [key: string]: unknown;
1602
1691
  }>;
1603
1692
  memoryLookupEntity(subject: string): Promise<{
1604
1693
  subject: string;
@@ -1830,7 +1919,7 @@ declare class TeamsApi extends ApiBase {
1830
1919
 
1831
1920
  //#endregion
1832
1921
  //#region src/index.d.ts
1833
- interface AgentApiClient extends SyncApi, IntegrationsApi, WorkspaceApi, ConnectCredentialsApi, TeamsApi, ChatApi, SecretsApi, IdentityApi, MemoryApi, SearchApi, KnowledgeApi, DatabaseApi, MobileApi, RemoteApi, SelfApi, VoiceApi, ImagesApi {}
1922
+ interface AgentApiClient extends SyncApi, IntegrationsApi, WorkspaceApi, ConnectCredentialsApi, TeamsApi, ChatApi, SecretsApi, IdentityApi, MemoryApi, SearchApi, KnowledgeApi, DatabaseApi, MobileApi, RemoteApi, SelfApi, VoiceApi, ImagesApi, WebhooksApi {}
1834
1923
  declare class AgentApiClient extends ApiBase {
1835
1924
  constructor(config: AgentApiClientConfig);
1836
1925
  }
@@ -1881,8 +1970,8 @@ declare const SERVER_BIN_PATH: string;
1881
1970
  type ServerProfile = 'default' | 'claude-code';
1882
1971
  interface ServerOptions {
1883
1972
  /**
1884
- * Optional override for the API client tests inject a fake so the
1885
- * server can be exercised end-to-end without real network I/O.
1973
+ * Optional pre-bound API client. Must be supplied together with `apiUrl` so
1974
+ * the client authority and the OAuth URL authority cannot diverge.
1886
1975
  */
1887
1976
  client?: AgentApiClient;
1888
1977
  /** Pre-resolved context fields. If omitted, the server calls `whoami()` itself. */
@@ -1890,7 +1979,7 @@ interface ServerOptions {
1890
1979
  agentId: string;
1891
1980
  tenantId: string;
1892
1981
  };
1893
- /** Override apiUrl reported in the ToolContext. Defaults to the resolved CLI config. */
1982
+ /** Authority bound to an injected `client`. Omit both to use resolved CLI config. */
1894
1983
  apiUrl?: string;
1895
1984
  /**
1896
1985
  * Tool surface to register. Defaults to `default` (integrations only) so
@@ -1912,9 +2001,9 @@ interface ServerOptions {
1912
2001
  * Pure construction — does not connect a transport. Callers (the bin
1913
2002
  * entry, or tests) attach `StdioServerTransport` or any other transport.
1914
2003
  *
1915
- * `resolveConfig()` is only called when neither `client` nor `apiUrl`
1916
- * is provided tests can fully construct the server without touching
1917
- * `~/.alfe/config.toml`.
2004
+ * `resolveConfig()` is only called when the main `client`/`apiUrl` pair is
2005
+ * omitted. Tests and alternate hosts can inject a complete pair without
2006
+ * touching `~/.alfe/config.toml`.
1918
2007
  */
1919
2008
  declare function createServer(opts?: ServerOptions): Promise<McpServer>;
1920
2009
  /**
@@ -1925,14 +2014,13 @@ declare function createServer(opts?: ServerOptions): Promise<McpServer>;
1925
2014
  */
1926
2015
  declare function parseProfileArg(argv: string[]): ServerProfile;
1927
2016
  /**
1928
- * Entry point boot the server on stdio. Used by `bin.ts`. Any
1929
- * startup failure is fatal: log and exit non-zero so the bundler's
1930
- * connection attempt surfaces a clear error rather than a hung
1931
- * handshake.
2017
+ * Boot the server and attach its transport. Used by `bin.ts`; tests can inject
2018
+ * an in-memory transport. Process policy (logging, exit code, signals) remains
2019
+ * in the executable boundary rather than this reusable library function.
1932
2020
  */
1933
- declare function main(opts?: {
1934
- profile?: ServerProfile;
1935
- }): Promise<void>;
2021
+ declare function main(opts?: ServerOptions & {
2022
+ transport?: Transport;
2023
+ }): Promise<McpServer>;
1936
2024
  //# sourceMappingURL=index.d.ts.map
1937
2025
 
1938
2026
  //#endregion