@frihet/mcp-server 1.17.0 → 2.0.0

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.
Files changed (87) hide show
  1. package/README.md +84 -59
  2. package/dist/agent-onboarding.d.ts +1 -1
  3. package/dist/agent-onboarding.js +3 -3
  4. package/dist/canary/mcp-harness.d.ts +1 -1
  5. package/dist/canary/mcp-harness.js +4 -1
  6. package/dist/capability-truth.js +20 -12
  7. package/dist/claude-candidate-contract.d.ts +482 -0
  8. package/dist/claude-candidate-contract.js +87 -0
  9. package/dist/claude-output-privacy.d.ts +17 -0
  10. package/dist/claude-output-privacy.js +240 -0
  11. package/dist/claude-profile.d.ts +18 -0
  12. package/dist/claude-profile.js +260 -0
  13. package/dist/client-interface.d.ts +26 -20
  14. package/dist/client.d.ts +65 -29
  15. package/dist/client.js +278 -167
  16. package/dist/demo-client.d.ts +27 -21
  17. package/dist/demo-client.js +31 -14
  18. package/dist/deposit-contract.d.ts +29 -0
  19. package/dist/deposit-contract.js +76 -0
  20. package/dist/fetch-no-redirect.d.ts +3 -0
  21. package/dist/fetch-no-redirect.js +16 -0
  22. package/dist/fiscal-aliases.d.ts +2 -2
  23. package/dist/fiscal-aliases.js +2 -2
  24. package/dist/fiscal-period.d.ts +26 -0
  25. package/dist/fiscal-period.js +31 -0
  26. package/dist/google-profile.d.ts +19 -0
  27. package/dist/google-profile.js +122 -0
  28. package/dist/index.js +31 -7
  29. package/dist/logger.d.ts +1 -1
  30. package/dist/logger.js +2 -2
  31. package/dist/muse-profile.d.ts +19 -0
  32. package/dist/muse-profile.js +122 -0
  33. package/dist/observability.js +3 -2
  34. package/dist/openai-profile.d.ts +2 -2
  35. package/dist/openai-profile.js +37 -11
  36. package/dist/openai-review-contract.d.ts +1 -1
  37. package/dist/openai-review-contract.js +4 -5
  38. package/dist/openai-review-oauth.d.ts +107 -7
  39. package/dist/openai-review-oauth.js +161 -17
  40. package/dist/prompts/register-all.js +32 -78
  41. package/dist/redaction.d.ts +5 -0
  42. package/dist/redaction.js +9 -0
  43. package/dist/resources/register-all.js +150 -54
  44. package/dist/retry-after.d.ts +19 -0
  45. package/dist/retry-after.js +84 -0
  46. package/dist/server-composition.d.ts +5 -2
  47. package/dist/server-composition.js +35 -5
  48. package/dist/tool-exposure.d.ts +6 -5
  49. package/dist/tool-exposure.js +15 -13
  50. package/dist/tools/audit_gl.js +8 -8
  51. package/dist/tools/backend-availability.d.ts +8 -29
  52. package/dist/tools/backend-availability.js +31 -30
  53. package/dist/tools/bank_rules.js +66 -15
  54. package/dist/tools/banking.js +5 -13
  55. package/dist/tools/clients.js +252 -6
  56. package/dist/tools/deposits.js +107 -97
  57. package/dist/tools/einvoice.d.ts +17 -3
  58. package/dist/tools/einvoice.js +59 -12
  59. package/dist/tools/fiscal.d.ts +3 -4
  60. package/dist/tools/fiscal.js +93 -60
  61. package/dist/tools/gestoria.js +15 -7
  62. package/dist/tools/hr.js +41 -11
  63. package/dist/tools/igic.d.ts +9 -8
  64. package/dist/tools/igic.js +34 -64
  65. package/dist/tools/impuesto_sociedades.d.ts +4 -5
  66. package/dist/tools/impuesto_sociedades.js +16 -37
  67. package/dist/tools/intelligence.js +164 -10
  68. package/dist/tools/invoices.js +109 -42
  69. package/dist/tools/kitchen.js +19 -9
  70. package/dist/tools/quotes.js +86 -25
  71. package/dist/tools/recurring.js +26 -25
  72. package/dist/tools/register-all.d.ts +2 -2
  73. package/dist/tools/register-all.js +9 -6
  74. package/dist/tools/search.d.ts +19 -0
  75. package/dist/tools/search.js +84 -0
  76. package/dist/tools/shared.d.ts +17 -37
  77. package/dist/tools/shared.js +96 -30
  78. package/dist/tools/team.js +8 -16
  79. package/dist/tools/time.js +4 -12
  80. package/dist/tools/vendors.js +240 -6
  81. package/dist/types.d.ts +3 -1
  82. package/dist/workflows/daily-operational-brief.d.ts +163 -0
  83. package/dist/workflows/daily-operational-brief.js +881 -0
  84. package/docs/agent-onboarding.json +15 -5
  85. package/package.json +26 -12
  86. package/dist/tools/onboarding.d.ts +0 -19
  87. package/dist/tools/onboarding.js +0 -64
package/dist/client.d.ts CHANGED
@@ -63,11 +63,30 @@ export interface XmlDocument {
63
63
  }
64
64
  /** `/invoices/:id/xml` serves XML or a Factur-X PDF, depending on storage MIME. */
65
65
  export type EInvoiceDocument = XmlDocument | BinaryDocument;
66
+ /** Ergonomic values accepted by the MCP `einvoice_export` tool. This is
67
+ * deliberately narrower than the asynchronous dispatch/validation format
68
+ * family: the public export API exposes only the EN16931 Factur-X profile. */
69
+ export type McpEInvoiceExportFormat = "facturae" | "xrechnung-cii" | "xrechnung-ubl" | "facturx-en16931" | "fatturapa" | "peppol-bis-3" | "fa-2-ksef" | "ubl" | "cii";
70
+ /** Exact, case-sensitive enum accepted by the ERP export endpoint. */
71
+ export type ApiEInvoiceExportFormat = "Facturae" | "XRechnung-CII" | "XRechnung-UBL" | "Factur-X" | "FatturaPA" | "PEPPOL-BIS-3" | "FA-2-KSeF" | "UBL" | "CII";
72
+ export interface EInvoiceExportResult {
73
+ xml: string;
74
+ contentType: string;
75
+ filename: string;
76
+ signed: boolean;
77
+ format: ApiEInvoiceExportFormat;
78
+ }
79
+ export declare function isLocalInputValidationError(error: unknown): boolean;
80
+ export declare function toApiEInvoiceExportFormat(format: string): ApiEInvoiceExportFormat;
66
81
  export declare class FrihetApiError extends Error {
67
82
  readonly statusCode: number;
68
83
  readonly errorCode: string;
69
84
  readonly detail?: string | undefined;
70
- constructor(statusCode: number, errorCode: string, message?: string, detail?: string | undefined);
85
+ /** Backend correlation id (`meta.requestId` or `X-Request-Id`); carried for diagnostics, never echoed to agents. */
86
+ readonly requestId?: string | undefined;
87
+ constructor(statusCode: number, errorCode: string, message?: string, detail?: string | undefined,
88
+ /** Backend correlation id (`meta.requestId` or `X-Request-Id`); carried for diagnostics, never echoed to agents. */
89
+ requestId?: string | undefined);
71
90
  }
72
91
  export interface FrihetClientOptions {
73
92
  /**
@@ -76,17 +95,22 @@ export interface FrihetClientOptions {
76
95
  */
77
96
  timeoutMs?: number;
78
97
  /**
79
- * Internal second factor for API keys provisioned by Frihet OAuth Workers.
80
- * Ordinary dashboard/API keys must omit it. The value is sent only to the
81
- * already-normalized API origin and is never included in logs or errors.
98
+ * Cumulative time one call may sleep across 429 retries. A server-requested
99
+ * wait that does not fit is never shortened: the call fails with a
100
+ * `rate_limit_deferred` error carrying the wait to honor. Defaults to 30000.
82
101
  */
83
- oauthServiceSecret?: string;
102
+ retryBudgetMs?: number;
103
+ /** Test seams: timer and wall clock used for 429 waits. */
104
+ sleep?: (ms: number) => Promise<void>;
105
+ now?: () => number;
84
106
  }
85
107
  export declare class FrihetClient {
86
108
  private readonly apiKey;
87
109
  private readonly baseUrl;
88
110
  private readonly timeoutMs;
89
- private readonly oauthServiceSecret?;
111
+ private readonly retryBudgetMs;
112
+ private readonly sleepFn;
113
+ private readonly nowFn;
90
114
  constructor(apiKey: string, baseUrl?: string, options?: FrihetClientOptions);
91
115
  private request;
92
116
  /** Fetch a raw response. The caller owns timeout and body consumption. */
@@ -101,7 +125,13 @@ export declare class FrihetClient {
101
125
  * A 429 may retry, matching the generic JSON client path.
102
126
  */
103
127
  private requestDocument;
104
- private sleep;
128
+ /**
129
+ * Wait before the next 429 retry: the server's `Retry-After` when it parses
130
+ * (RFC 9110 §10.2.3), otherwise exponential backoff. Either wait that does
131
+ * not fit the remaining cumulative budget is deferred to the caller; a server
132
+ * wait is never shortened into an early retry.
133
+ */
134
+ private rateLimitDelayMs;
105
135
  /**
106
136
  * Wrapper for endpoints whose backend wraps the payload in a `{ data, meta }`
107
137
  * envelope. This is the UNIFORM convention across the Frihet `/v1` REST API:
@@ -130,12 +160,12 @@ export declare class FrihetClient {
130
160
  * Only unwraps when the body is an object carrying a `data` property that is
131
161
  * itself a (non-array) object — i.e. a genuine single-object envelope. It is
132
162
  * deliberately distinct from {@link requestPaginated}, which keeps the
133
- * `{ data: [...] , meta }` shape intact for list endpoints. If the body is
163
+ * list rows and pagination fields while omitting transport metadata. If the body is
134
164
  * not an envelope (legacy endpoints that return the item directly), it is
135
165
  * returned unchanged so existing callers keep working.
136
166
  */
137
167
  private requestUnwrapped;
138
- /** Wrapper for paginated endpoints — validates response shape has `data` array. */
168
+ /** Validate list rows and emit only the declared MCP pagination envelope. */
139
169
  private requestPaginated;
140
170
  listInvoices(params?: {
141
171
  limit?: number;
@@ -280,6 +310,21 @@ export declare class FrihetClient {
280
310
  createWebhook(data: CreateWebhookInput): Promise<CreateWebhookResult>;
281
311
  updateWebhook(id: string, data: UpdateWebhookInput): Promise<Webhook>;
282
312
  deleteWebhook(id: string): Promise<void>;
313
+ globalSearch(params: {
314
+ q: string;
315
+ types?: ReadonlyArray<"invoices" | "expenses" | "vendors" | "clients" | "products">;
316
+ limit?: number;
317
+ offset?: number;
318
+ }): Promise<{
319
+ data: Record<string, unknown>[];
320
+ total: number;
321
+ limit: number;
322
+ offset: number;
323
+ hasMore: boolean;
324
+ query: string;
325
+ types: ReadonlyArray<"invoices" | "expenses" | "vendors" | "clients" | "products">;
326
+ truncated?: boolean;
327
+ }>;
283
328
  listClientContacts(clientId: string, params?: {
284
329
  limit?: number;
285
330
  offset?: number;
@@ -357,14 +402,9 @@ export declare class FrihetClient {
357
402
  }>;
358
403
  exportEInvoice(params: {
359
404
  invoiceId: string;
360
- format: string;
405
+ format: McpEInvoiceExportFormat;
361
406
  signed?: boolean;
362
- }): Promise<{
363
- xmlUrl: string;
364
- filename: string;
365
- format: string;
366
- signed: boolean;
367
- }>;
407
+ }): Promise<EInvoiceExportResult>;
368
408
  faceSubmit(params: {
369
409
  invoiceId: string;
370
410
  mode: "mock" | "sandbox" | "production";
@@ -580,10 +620,12 @@ export declare class FrihetClient {
580
620
  };
581
621
  }): Promise<Record<string, unknown>>;
582
622
  getGestoriaAgingConsolidated(params?: {
583
- ownerUid?: string;
623
+ workspaceIds?: string[];
624
+ asOf?: string;
625
+ bustCache?: boolean;
584
626
  }): Promise<Record<string, unknown>>;
585
627
  approveGLEntry(entryId: string, notes?: string): Promise<Record<string, unknown>>;
586
- rejectGLEntry(entryId: string, reason: string): Promise<Record<string, unknown>>;
628
+ rejectGLEntry(entryId: string, note: string): Promise<Record<string, unknown>>;
587
629
  getGLEntryAuditLog(entryId: string): Promise<Record<string, unknown>>;
588
630
  addCustomPortalDomain(data: {
589
631
  domain: string;
@@ -625,15 +667,13 @@ export declare class FrihetClient {
625
667
  }): Promise<PaginatedResponse<Record<string, unknown>>>;
626
668
  createBankRule(data: {
627
669
  name: string;
628
- conditions: Array<{
670
+ bankConditions: Array<{
629
671
  field: string;
630
672
  operator: string;
631
673
  value: string;
632
674
  }>;
633
- actions: Array<{
634
- type: string;
635
- value: string;
636
- }>;
675
+ action: string;
676
+ actionConfig: Record<string, unknown>;
637
677
  isActive?: boolean;
638
678
  }): Promise<Record<string, unknown>>;
639
679
  listLeaves(params?: {
@@ -663,8 +703,8 @@ export declare class FrihetClient {
663
703
  employeeId: string;
664
704
  mood?: string;
665
705
  location?: string;
666
- }): Promise<Record<string, unknown>>;
667
- attendanceClockOut(entryId: string): Promise<Record<string, unknown>>;
706
+ }, idempotencyKey?: string): Promise<Record<string, unknown>>;
707
+ attendanceClockOut(entryId: string, idempotencyKey?: string): Promise<Record<string, unknown>>;
668
708
  getOvertimeReport(params: {
669
709
  period: string;
670
710
  employeeId?: string;
@@ -687,10 +727,6 @@ export declare class FrihetClient {
687
727
  getPayrollChecklist(params: {
688
728
  month: string;
689
729
  }): Promise<Record<string, unknown>>;
690
- getOnboardingStatus(): Promise<Record<string, unknown>>;
691
- setOnboardingPersona(data: {
692
- persona: "autonomo" | "empresa" | "agencia" | "gestoria";
693
- }): Promise<Record<string, unknown>>;
694
730
  getPermissionsMatrix(): Promise<Record<string, unknown>>;
695
731
  getMyPermissions(): Promise<Record<string, unknown>>;
696
732
  getCurrentPeriod(params?: {