@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/cli.js +60 -24
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +62 -25
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +14 -5
- package/dist/index.d.ts +14 -5
- package/dist/index.js +60 -24
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -4049,6 +4049,36 @@ function registerResources(server) {
|
|
|
4049
4049
|
// src/tools.ts
|
|
4050
4050
|
import { ENTITIES as ENTITIES2, TenkeyBridgeApiError } from "@tenkeybridge/client";
|
|
4051
4051
|
import { z } from "zod";
|
|
4052
|
+
|
|
4053
|
+
// src/access.ts
|
|
4054
|
+
var NEEDS = {
|
|
4055
|
+
query: { op: "read" },
|
|
4056
|
+
get: { op: "read" },
|
|
4057
|
+
create: { op: "create" },
|
|
4058
|
+
update: { op: "update" },
|
|
4059
|
+
delete: { op: "delete" },
|
|
4060
|
+
void: { op: "void" },
|
|
4061
|
+
run_report: { op: "read", entity: "Report" },
|
|
4062
|
+
get_cleared_status: { op: "read", entity: "ClearedStatus" },
|
|
4063
|
+
set_cleared_status: { op: "update", entity: "ClearedStatus" }
|
|
4064
|
+
};
|
|
4065
|
+
function layerAllows(rules, op, entity) {
|
|
4066
|
+
return rules.some((r) => {
|
|
4067
|
+
if (!r.ops.includes(op)) return false;
|
|
4068
|
+
if (!entity) return true;
|
|
4069
|
+
return r.entity === "*" || r.entity === entity;
|
|
4070
|
+
});
|
|
4071
|
+
}
|
|
4072
|
+
function toolVisible(access, tool) {
|
|
4073
|
+
if (!access) return true;
|
|
4074
|
+
const need = NEEDS[tool];
|
|
4075
|
+
if (!need) return true;
|
|
4076
|
+
if (!layerAllows(access.rules, need.op, need.entity)) return false;
|
|
4077
|
+
if (access.companyRules && !layerAllows(access.companyRules, need.op, need.entity)) return false;
|
|
4078
|
+
return true;
|
|
4079
|
+
}
|
|
4080
|
+
|
|
4081
|
+
// src/tools.ts
|
|
4052
4082
|
function ok(result) {
|
|
4053
4083
|
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
4054
4084
|
}
|
|
@@ -4064,7 +4094,9 @@ function failure(err) {
|
|
|
4064
4094
|
code: err.code,
|
|
4065
4095
|
message: err.message,
|
|
4066
4096
|
fixes: err.tkb?.fixes,
|
|
4067
|
-
docsUrl: err.tkb?.docsUrl
|
|
4097
|
+
docsUrl: err.tkb?.docsUrl,
|
|
4098
|
+
...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." } : {},
|
|
4099
|
+
...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." } : {}
|
|
4068
4100
|
},
|
|
4069
4101
|
null,
|
|
4070
4102
|
2
|
|
@@ -4099,9 +4131,12 @@ function readOnly(name) {
|
|
|
4099
4131
|
`${name} is read-only through TenkeyBridge (write: ${ENTITIES2[name].write}).` + (entry ? ` ${entry.headline}` : "") + ` Detail: compat://entity/${name.toLowerCase()}`
|
|
4100
4132
|
);
|
|
4101
4133
|
}
|
|
4102
|
-
function registerTools(server, client) {
|
|
4134
|
+
function registerTools(server, client, access) {
|
|
4135
|
+
const hide = (name, tool) => {
|
|
4136
|
+
if (!toolVisible(access, name)) tool.disable();
|
|
4137
|
+
};
|
|
4103
4138
|
const entityArg = z.string().describe('Entity name, e.g. "Invoice" or "Customer" (case-insensitive). See compat://catalog.');
|
|
4104
|
-
server.registerTool(
|
|
4139
|
+
hide("query", server.registerTool(
|
|
4105
4140
|
"query",
|
|
4106
4141
|
{
|
|
4107
4142
|
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.",
|
|
@@ -4125,8 +4160,8 @@ function registerTools(server, client) {
|
|
|
4125
4160
|
return failure(err);
|
|
4126
4161
|
}
|
|
4127
4162
|
}
|
|
4128
|
-
);
|
|
4129
|
-
server.registerTool(
|
|
4163
|
+
));
|
|
4164
|
+
hide("run_report", server.registerTool(
|
|
4130
4165
|
"run_report",
|
|
4131
4166
|
{
|
|
4132
4167
|
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.",
|
|
@@ -4143,8 +4178,8 @@ function registerTools(server, client) {
|
|
|
4143
4178
|
return failure(err);
|
|
4144
4179
|
}
|
|
4145
4180
|
}
|
|
4146
|
-
);
|
|
4147
|
-
server.registerTool(
|
|
4181
|
+
));
|
|
4182
|
+
hide("get", server.registerTool(
|
|
4148
4183
|
"get",
|
|
4149
4184
|
{
|
|
4150
4185
|
description: "Fetch one entity by Id (singletons like CompanyInfo and Preferences need no id).",
|
|
@@ -4166,8 +4201,8 @@ function registerTools(server, client) {
|
|
|
4166
4201
|
return failure(err);
|
|
4167
4202
|
}
|
|
4168
4203
|
}
|
|
4169
|
-
);
|
|
4170
|
-
server.registerTool(
|
|
4204
|
+
));
|
|
4205
|
+
hide("create", server.registerTool(
|
|
4171
4206
|
"create",
|
|
4172
4207
|
{
|
|
4173
4208
|
description: "Create an entity from QBO-shaped JSON (same payloads as the QuickBooks Online API). Check compat://entity/{name} for field support first.",
|
|
@@ -4186,8 +4221,8 @@ function registerTools(server, client) {
|
|
|
4186
4221
|
return failure(err);
|
|
4187
4222
|
}
|
|
4188
4223
|
}
|
|
4189
|
-
);
|
|
4190
|
-
server.registerTool(
|
|
4224
|
+
));
|
|
4225
|
+
hide("update", server.registerTool(
|
|
4191
4226
|
"update",
|
|
4192
4227
|
{
|
|
4193
4228
|
description: "Sparse-update an entity: payload must include Id plus only the fields to change.",
|
|
@@ -4209,8 +4244,8 @@ function registerTools(server, client) {
|
|
|
4209
4244
|
return failure(err);
|
|
4210
4245
|
}
|
|
4211
4246
|
}
|
|
4212
|
-
);
|
|
4213
|
-
server.registerTool(
|
|
4247
|
+
));
|
|
4248
|
+
hide("delete", server.registerTool(
|
|
4214
4249
|
"delete",
|
|
4215
4250
|
{
|
|
4216
4251
|
description: "Delete an entity by Id (SyncToken optional, as in QBO).",
|
|
@@ -4230,8 +4265,8 @@ function registerTools(server, client) {
|
|
|
4230
4265
|
return failure(err);
|
|
4231
4266
|
}
|
|
4232
4267
|
}
|
|
4233
|
-
);
|
|
4234
|
-
server.registerTool(
|
|
4268
|
+
));
|
|
4269
|
+
hide("void", server.registerTool(
|
|
4235
4270
|
"void",
|
|
4236
4271
|
{
|
|
4237
4272
|
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.',
|
|
@@ -4254,9 +4289,9 @@ function registerTools(server, client) {
|
|
|
4254
4289
|
return failure(err);
|
|
4255
4290
|
}
|
|
4256
4291
|
}
|
|
4257
|
-
);
|
|
4292
|
+
));
|
|
4258
4293
|
const CLEARED_NEEDS = "This TenkeyBridge client has no cleared status methods; upgrade @tenkeybridge/client to 0.8.0.";
|
|
4259
|
-
server.registerTool(
|
|
4294
|
+
hide("set_cleared_status", server.registerTool(
|
|
4260
4295
|
"set_cleared_status",
|
|
4261
4296
|
{
|
|
4262
4297
|
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.",
|
|
@@ -4279,8 +4314,8 @@ function registerTools(server, client) {
|
|
|
4279
4314
|
return failure(err);
|
|
4280
4315
|
}
|
|
4281
4316
|
}
|
|
4282
|
-
);
|
|
4283
|
-
server.registerTool(
|
|
4317
|
+
));
|
|
4318
|
+
hide("get_cleared_status", server.registerTool(
|
|
4284
4319
|
"get_cleared_status",
|
|
4285
4320
|
{
|
|
4286
4321
|
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.",
|
|
@@ -4297,17 +4332,17 @@ function registerTools(server, client) {
|
|
|
4297
4332
|
return failure(err);
|
|
4298
4333
|
}
|
|
4299
4334
|
}
|
|
4300
|
-
);
|
|
4335
|
+
));
|
|
4301
4336
|
}
|
|
4302
4337
|
|
|
4303
4338
|
// src/version.ts
|
|
4304
|
-
var PKG_VERSION = "0.
|
|
4339
|
+
var PKG_VERSION = "0.9.0";
|
|
4305
4340
|
|
|
4306
4341
|
// src/server.ts
|
|
4307
4342
|
var SERVER_NAME = "tenkeybridge";
|
|
4308
|
-
function buildServer(client) {
|
|
4343
|
+
function buildServer(client, access) {
|
|
4309
4344
|
const server = new McpServer2({ name: SERVER_NAME, version: PKG_VERSION });
|
|
4310
|
-
registerTools(server, client);
|
|
4345
|
+
registerTools(server, client, access);
|
|
4311
4346
|
registerResources(server);
|
|
4312
4347
|
return server;
|
|
4313
4348
|
}
|
|
@@ -4334,7 +4369,8 @@ async function main() {
|
|
|
4334
4369
|
});
|
|
4335
4370
|
const _seamCheck = client.query.bind(client);
|
|
4336
4371
|
void _seamCheck;
|
|
4337
|
-
const
|
|
4372
|
+
const access = await client.access().catch(() => void 0);
|
|
4373
|
+
const server = buildServer(client, access);
|
|
4338
4374
|
await server.connect(new StdioServerTransport());
|
|
4339
4375
|
console.error(`tenkeybridge-mcp: serving company ${config.companyId}`);
|
|
4340
4376
|
}
|