@tenkeybridge/mcp 0.8.0 → 0.9.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/index.d.cts CHANGED
@@ -1,5 +1,13 @@
1
1
  import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
- import { QueryOptions, EntityName } from '@tenkeybridge/client';
2
+ import { AccessSummary, QueryOptions, EntityName } from '@tenkeybridge/client';
3
+
4
+ /**
5
+ * Should this tool be listed for a credential with this access? True when
6
+ * `access` is absent (older gateway: unknown means list everything). For
7
+ * entity-scoped tools one granting rule anywhere keeps the tool; the gateway
8
+ * still refuses entities outside the rule, and SCOPE_DENIED text surfaces.
9
+ */
10
+ declare function toolVisible(access: AccessSummary | undefined, tool: string): boolean;
3
11
 
4
12
  interface EntityAccessorLike {
5
13
  get?(id?: string): Promise<unknown>;
@@ -31,10 +39,11 @@ type GatewayClient = Record<string, unknown> & {
31
39
  txnType: string;
32
40
  }): Promise<unknown>;
33
41
  };
34
- declare function registerTools(server: McpServer, client: GatewayClient): void;
42
+ declare function registerTools(server: McpServer, client: GatewayClient, access?: AccessSummary): void;
35
43
 
36
44
  declare const SERVER_NAME = "tenkeybridge";
37
- declare function buildServer(client: GatewayClient): McpServer;
45
+ /** `access`: from `client.access()`; omit (or undefined) to list every tool. */
46
+ declare function buildServer(client: GatewayClient, access?: AccessSummary): McpServer;
38
47
 
39
48
  declare function registerResources(server: McpServer): void;
40
49
 
@@ -88,6 +97,6 @@ declare function resolveEntityName(name: string): EntityName | undefined;
88
97
  type CatalogSummaryRow = Pick<CatalogEntry, "entity" | "verdict" | "group" | "read" | "write" | "headline" | "usage">;
89
98
  declare function catalogSummary(): CatalogSummaryRow[];
90
99
 
91
- declare const PKG_VERSION = "0.8.0";
100
+ declare const PKG_VERSION = "0.9.0";
92
101
 
93
- export { CATALOG, type CatalogEntry, type CatalogField, type CatalogSummaryRow, type CatalogUnsupported, type EntityAccessorLike, type GatewayClient, type McpAuth, type McpConfig, PKG_VERSION, SERVER_NAME, buildServer, catalogSummary, defaultTokenFile, loadConfig, persistRefreshToken, readStoredRefreshToken, registerResources, registerTools, resolveCatalog, resolveEntityName };
102
+ export { CATALOG, type CatalogEntry, type CatalogField, type CatalogSummaryRow, type CatalogUnsupported, type EntityAccessorLike, type GatewayClient, type McpAuth, type McpConfig, PKG_VERSION, SERVER_NAME, buildServer, catalogSummary, defaultTokenFile, loadConfig, persistRefreshToken, readStoredRefreshToken, registerResources, registerTools, resolveCatalog, resolveEntityName, toolVisible };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,13 @@
1
1
  import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
- import { QueryOptions, EntityName } from '@tenkeybridge/client';
2
+ import { AccessSummary, QueryOptions, EntityName } from '@tenkeybridge/client';
3
+
4
+ /**
5
+ * Should this tool be listed for a credential with this access? True when
6
+ * `access` is absent (older gateway: unknown means list everything). For
7
+ * entity-scoped tools one granting rule anywhere keeps the tool; the gateway
8
+ * still refuses entities outside the rule, and SCOPE_DENIED text surfaces.
9
+ */
10
+ declare function toolVisible(access: AccessSummary | undefined, tool: string): boolean;
3
11
 
4
12
  interface EntityAccessorLike {
5
13
  get?(id?: string): Promise<unknown>;
@@ -31,10 +39,11 @@ type GatewayClient = Record<string, unknown> & {
31
39
  txnType: string;
32
40
  }): Promise<unknown>;
33
41
  };
34
- declare function registerTools(server: McpServer, client: GatewayClient): void;
42
+ declare function registerTools(server: McpServer, client: GatewayClient, access?: AccessSummary): void;
35
43
 
36
44
  declare const SERVER_NAME = "tenkeybridge";
37
- declare function buildServer(client: GatewayClient): McpServer;
45
+ /** `access`: from `client.access()`; omit (or undefined) to list every tool. */
46
+ declare function buildServer(client: GatewayClient, access?: AccessSummary): McpServer;
38
47
 
39
48
  declare function registerResources(server: McpServer): void;
40
49
 
@@ -88,6 +97,6 @@ declare function resolveEntityName(name: string): EntityName | undefined;
88
97
  type CatalogSummaryRow = Pick<CatalogEntry, "entity" | "verdict" | "group" | "read" | "write" | "headline" | "usage">;
89
98
  declare function catalogSummary(): CatalogSummaryRow[];
90
99
 
91
- declare const PKG_VERSION = "0.8.0";
100
+ declare const PKG_VERSION = "0.9.0";
92
101
 
93
- export { CATALOG, type CatalogEntry, type CatalogField, type CatalogSummaryRow, type CatalogUnsupported, type EntityAccessorLike, type GatewayClient, type McpAuth, type McpConfig, PKG_VERSION, SERVER_NAME, buildServer, catalogSummary, defaultTokenFile, loadConfig, persistRefreshToken, readStoredRefreshToken, registerResources, registerTools, resolveCatalog, resolveEntityName };
102
+ export { CATALOG, type CatalogEntry, type CatalogField, type CatalogSummaryRow, type CatalogUnsupported, type EntityAccessorLike, type GatewayClient, type McpAuth, type McpConfig, PKG_VERSION, SERVER_NAME, buildServer, catalogSummary, defaultTokenFile, loadConfig, persistRefreshToken, readStoredRefreshToken, registerResources, registerTools, resolveCatalog, resolveEntityName, toolVisible };
package/dist/index.js CHANGED
@@ -3979,6 +3979,36 @@ function registerResources(server) {
3979
3979
  // src/tools.ts
3980
3980
  import { ENTITIES as ENTITIES2, TenkeyBridgeApiError } from "@tenkeybridge/client";
3981
3981
  import { z } from "zod";
3982
+
3983
+ // src/access.ts
3984
+ var NEEDS = {
3985
+ query: { op: "read" },
3986
+ get: { op: "read" },
3987
+ create: { op: "create" },
3988
+ update: { op: "update" },
3989
+ delete: { op: "delete" },
3990
+ void: { op: "void" },
3991
+ run_report: { op: "read", entity: "Report" },
3992
+ get_cleared_status: { op: "read", entity: "ClearedStatus" },
3993
+ set_cleared_status: { op: "update", entity: "ClearedStatus" }
3994
+ };
3995
+ function layerAllows(rules, op, entity) {
3996
+ return rules.some((r) => {
3997
+ if (!r.ops.includes(op)) return false;
3998
+ if (!entity) return true;
3999
+ return r.entity === "*" || r.entity === entity;
4000
+ });
4001
+ }
4002
+ function toolVisible(access, tool) {
4003
+ if (!access) return true;
4004
+ const need = NEEDS[tool];
4005
+ if (!need) return true;
4006
+ if (!layerAllows(access.rules, need.op, need.entity)) return false;
4007
+ if (access.companyRules && !layerAllows(access.companyRules, need.op, need.entity)) return false;
4008
+ return true;
4009
+ }
4010
+
4011
+ // src/tools.ts
3982
4012
  function ok(result) {
3983
4013
  return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
3984
4014
  }
@@ -3994,7 +4024,9 @@ function failure(err) {
3994
4024
  code: err.code,
3995
4025
  message: err.message,
3996
4026
  fixes: err.tkb?.fixes,
3997
- docsUrl: err.tkb?.docsUrl
4027
+ docsUrl: err.tkb?.docsUrl,
4028
+ ...err.code === "SCOPE_DENIED" ? { hint: "This credential is restricted. Ask the owner of this OAuth app to widen its access in the TenkeyBridge portal. Do not retry." } : {},
4029
+ ...err.code === "IP_NOT_ALLOWED" ? { hint: "This OAuth app only accepts calls from certain IP addresses and this server is not one of them. Ask the owner to add this server's public address under Allowed IP addresses in the TenkeyBridge portal. Do not retry or re-authorize." } : {}
3998
4030
  },
3999
4031
  null,
4000
4032
  2
@@ -4029,9 +4061,12 @@ function readOnly(name) {
4029
4061
  `${name} is read-only through TenkeyBridge (write: ${ENTITIES2[name].write}).` + (entry ? ` ${entry.headline}` : "") + ` Detail: compat://entity/${name.toLowerCase()}`
4030
4062
  );
4031
4063
  }
4032
- function registerTools(server, client) {
4064
+ function registerTools(server, client, access) {
4065
+ const hide = (name, tool) => {
4066
+ if (!toolVisible(access, name)) tool.disable();
4067
+ };
4033
4068
  const entityArg = z.string().describe('Entity name, e.g. "Invoice" or "Customer" (case-insensitive). See compat://catalog.');
4034
- server.registerTool(
4069
+ hide("query", server.registerTool(
4035
4070
  "query",
4036
4071
  {
4037
4072
  description: "Run a QBO-style query against the connected QuickBooks Desktop company file. Supports AND-joined WHERE conditions (=, !=, <, >, <=, >=, IN, LIKE; no OR) plus startPosition/maxResults paging. Check the compat://catalog resource for entity support first.",
@@ -4055,8 +4090,8 @@ function registerTools(server, client) {
4055
4090
  return failure(err);
4056
4091
  }
4057
4092
  }
4058
- );
4059
- server.registerTool(
4093
+ ));
4094
+ hide("run_report", server.registerTool(
4060
4095
  "run_report",
4061
4096
  {
4062
4097
  description: "Run a QuickBooks Desktop report and get QBO-style report JSON (Header, Columns, Rows). Report names are QBO names such as ProfitAndLoss, BalanceSheet or CashFlow, plus Desktop extension reports. Params use QBO names, e.g. start_date, end_date, date_macro, accounting_method, summarize_column_by, customer, vendor, item, class, account, account_type, transaction_type, columns, report_date, start_moddate, end_moddate. BudgetOverview and BudgetVsActuals take fiscal_year instead of dates; MissingChecks requires account, and JobProfitabilityDetail and JobEstimatesVsActualsDetail require customer. ClassSales gives income by class; TransactionListWithSplits lists every split line. Read compat://entity/reports for the available reports and which params each takes.",
@@ -4073,8 +4108,8 @@ function registerTools(server, client) {
4073
4108
  return failure(err);
4074
4109
  }
4075
4110
  }
4076
- );
4077
- server.registerTool(
4111
+ ));
4112
+ hide("get", server.registerTool(
4078
4113
  "get",
4079
4114
  {
4080
4115
  description: "Fetch one entity by Id (singletons like CompanyInfo and Preferences need no id).",
@@ -4096,8 +4131,8 @@ function registerTools(server, client) {
4096
4131
  return failure(err);
4097
4132
  }
4098
4133
  }
4099
- );
4100
- server.registerTool(
4134
+ ));
4135
+ hide("create", server.registerTool(
4101
4136
  "create",
4102
4137
  {
4103
4138
  description: "Create an entity from QBO-shaped JSON (same payloads as the QuickBooks Online API). Check compat://entity/{name} for field support first.",
@@ -4116,8 +4151,8 @@ function registerTools(server, client) {
4116
4151
  return failure(err);
4117
4152
  }
4118
4153
  }
4119
- );
4120
- server.registerTool(
4154
+ ));
4155
+ hide("update", server.registerTool(
4121
4156
  "update",
4122
4157
  {
4123
4158
  description: "Sparse-update an entity: payload must include Id plus only the fields to change.",
@@ -4139,8 +4174,8 @@ function registerTools(server, client) {
4139
4174
  return failure(err);
4140
4175
  }
4141
4176
  }
4142
- );
4143
- server.registerTool(
4177
+ ));
4178
+ hide("delete", server.registerTool(
4144
4179
  "delete",
4145
4180
  {
4146
4181
  description: "Delete an entity by Id (SyncToken optional, as in QBO).",
@@ -4160,8 +4195,8 @@ function registerTools(server, client) {
4160
4195
  return failure(err);
4161
4196
  }
4162
4197
  }
4163
- );
4164
- server.registerTool(
4198
+ ));
4199
+ hide("void", server.registerTool(
4165
4200
  "void",
4166
4201
  {
4167
4202
  description: 'Void a transaction by Id + SyncToken (QBO ?operation=void). Supported: Invoice, SalesReceipt, Purchase, BillPayment, and as TenkeyBridge extensions Bill, VendorCredit, Deposit, JournalEntry, InventoryAdjustment. Destructive: on QuickBooks Desktop the record stays but its totals are zeroed and its memo is prefixed "VOID:". Returns the post-void record. Fetch the current SyncToken with the get tool first.',
@@ -4184,9 +4219,9 @@ function registerTools(server, client) {
4184
4219
  return failure(err);
4185
4220
  }
4186
4221
  }
4187
- );
4222
+ ));
4188
4223
  const CLEARED_NEEDS = "This TenkeyBridge client has no cleared status methods; upgrade @tenkeybridge/client to 0.8.0.";
4189
- server.registerTool(
4224
+ hide("set_cleared_status", server.registerTool(
4190
4225
  "set_cleared_status",
4191
4226
  {
4192
4227
  description: "Set QuickBooks Desktop's cleared status (Cleared, NotCleared, Pending) on an existing Purchase (check), Deposit, BillPayment (check) or JournalEntry. A TenkeyBridge extension (QBO has no equivalent). With only the transaction id it sets the transaction's own bank/card side (a journal entry's first line); with line_id it sets that one line's account side, which must be a bank or other balance sheet account other than A/R and A/P (an expense or income line is refused). A Transfer cannot be cleared through the API. Setting a status is idempotent, so retrying is safe; pass request_id (and txn_type) for replay protection. Use get_cleared_status to confirm what stuck.",
@@ -4209,8 +4244,8 @@ function registerTools(server, client) {
4209
4244
  return failure(err);
4210
4245
  }
4211
4246
  }
4212
- );
4213
- server.registerTool(
4247
+ ));
4248
+ hide("get_cleared_status", server.registerTool(
4214
4249
  "get_cleared_status",
4215
4250
  {
4216
4251
  description: "Read the cleared status of each bank / balance sheet split of one transaction (Purchase, Deposit, BillPayment, JournalEntry, or Transfer). Costs one extra bounded QuickBooks read (the transaction's own accounts on its own date). Each split has Role, LineId (to send to set_cleared_status) and ClearedStatus; SetByTxnId marks the split a set without line_id would change. Other values QuickBooks reports (such as a reconciled state) are passed through as it spells them.",
@@ -4227,17 +4262,17 @@ function registerTools(server, client) {
4227
4262
  return failure(err);
4228
4263
  }
4229
4264
  }
4230
- );
4265
+ ));
4231
4266
  }
4232
4267
 
4233
4268
  // src/version.ts
4234
- var PKG_VERSION = "0.8.0";
4269
+ var PKG_VERSION = "0.9.0";
4235
4270
 
4236
4271
  // src/server.ts
4237
4272
  var SERVER_NAME = "tenkeybridge";
4238
- function buildServer(client) {
4273
+ function buildServer(client, access) {
4239
4274
  const server = new McpServer2({ name: SERVER_NAME, version: PKG_VERSION });
4240
- registerTools(server, client);
4275
+ registerTools(server, client, access);
4241
4276
  registerResources(server);
4242
4277
  return server;
4243
4278
  }
@@ -4318,6 +4353,7 @@ export {
4318
4353
  registerResources,
4319
4354
  registerTools,
4320
4355
  resolveCatalog,
4321
- resolveEntityName
4356
+ resolveEntityName,
4357
+ toolVisible
4322
4358
  };
4323
4359
  //# sourceMappingURL=index.js.map