@sendora/mcp 1.3.3 → 1.4.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.
package/dist/errors.js CHANGED
@@ -17,8 +17,13 @@ const capOwner = {
17
17
  */
18
18
  const hints = {
19
19
  invalid_request: null,
20
- unauthorized: () => `The key was revoked or mistyped. A server key is made under its server in the dashboard, ${KEYS_PAGE}, and an account key by an administrator under Account › API keys (Konto › API-nycklar), ${ACCOUNT_KEYS_PAGE}; restart the connection with the new one.`,
20
+ unauthorized: (_error, connection) => connection.kind === 'grant'
21
+ ? `This connection has ended, or the person who approved it may no longer open this server. They see their connections under Account › Connected apps (Konto › Anslutna appar), ${DASHBOARD}/account/apps, and can connect the app again.`
22
+ : `The key was revoked or mistyped. A server key is made under its server in the dashboard, ${KEYS_PAGE}, and an account key by an administrator under Account › API keys (Konto › API-nycklar), ${ACCOUNT_KEYS_PAGE}; restart the connection with the new one.`,
21
23
  wrong_token_kind: null,
24
+ not_for_connections: null,
25
+ read_only_connection: () => 'The person approved this connection without changes on live servers, and the account is read only through a connection. They can connect again and tick "Tillåt ändringar på liveservrar" on the approval page, or the change can be made on a test server.',
26
+ test_server_only: () => 'Through a connected app, keys, webhooks and what cannot be undone happen on test servers only. Make the change on a test server, or in the dashboard.',
22
27
  payment_required: null,
23
28
  account_paused: null,
24
29
  account_not_active: null,
@@ -68,22 +73,23 @@ const hints = {
68
73
  invalid_signature: null,
69
74
  stale_signature: null,
70
75
  };
71
- /** The hint for a refusal, or undefined when the API's message says all there is. */
72
- export function hintFor(error) {
76
+ /** The hint for a refusal on this connection, or undefined when the API's message says all there is. */
77
+ export function hintFor(error, connection) {
73
78
  const hint = hints[error.code];
74
- return hint === null ? undefined : hint(error);
79
+ return hint === null ? undefined : hint(error, connection);
75
80
  }
76
81
  /**
77
82
  * A refusal from the API as a tool's error (docs/design/mcp.md §7), which
78
83
  * the model reads and can act on: the code, the API's message and the next
79
- * step, with the error's fields as the SDK has them. Anything that is not a
80
- * `SendoraError` is the server's own fault and is thrown.
84
+ * step on this connection, with the error's fields as the SDK has them.
85
+ * Anything that is not a `SendoraError` is the server's own fault and is
86
+ * thrown.
81
87
  */
82
- export function toolError(error) {
88
+ export function toolError(error, connection) {
83
89
  if (!(error instanceof SendoraError)) {
84
90
  throw error;
85
91
  }
86
- const hint = hintFor(error);
92
+ const hint = hintFor(error, connection);
87
93
  return {
88
94
  content: [
89
95
  {