@diy-accounting-uk/diya-submit 0.1.0 → 0.1.2
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/README.md +30 -9
- package/lib/accounts-tools.js +46 -2
- package/lib/auth.js +11 -1
- package/lib/batch-tools.js +19 -2
- package/lib/book-tools.js +47 -4
- package/lib/client-headers.js +263 -0
- package/lib/finance/bank-lines.js +10 -0
- package/lib/finance/book-from-workbook.js +10 -0
- package/lib/finance/mail-invoices.js +45 -7
- package/lib/finance/paypal-statement-lines.js +11 -1
- package/lib/finance/stripe-lines.js +20 -0
- package/lib/harness.js +58 -0
- package/lib/hosted-tools.js +82 -12
- package/lib/itsa-tools.js +173 -1
- package/lib/practice-tools.js +22 -12
- package/lib/server.js +348 -45
- package/lib/submit-tools.js +326 -71
- package/lib/vat-tools.js +10 -0
- package/lib/vendored/app/services/ct600Figures.js +1175 -0
- package/lib/vendored/app/services/microEntityAccounts.js +47 -197
- package/lib/vendored/app/services/microEntityAccountsFromResults.js +264 -0
- package/lib/vendored/app/services/smallCompanyAccounts.js +7 -240
- package/lib/vendored/app/services/smallCompanyAccountsFromResults.js +333 -0
- package/package.json +12 -7
- package/lib/vendored/app/lib/xmlDom.js +0 -73
- package/lib/vendored/app/services/accountsIxbrlCommon.js +0 -414
- package/lib/vendored/app/services/smallCompanyAccountsIxbrl.js +0 -426
package/lib/server.js
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
// SPDX-License-Identifier: LicenseRef-PolyForm-Internal-Use-1.0.0
|
|
2
2
|
// Copyright (C) 2006-2026 DIY Accounting Limited
|
|
3
3
|
|
|
4
|
+
// @capability MCP-01 Expose the submission MCP server and tools
|
|
5
|
+
// - **Use when:** a session needs the submission MCP's tool set, over stdio or one call across every practice client.
|
|
6
|
+
// - **Does:** createServer in mcp/lib/server.js builds an McpServer and registers every tool in its TOOLS table. mcp/bin/diya-submit-mcp.js connects that server to stdio, or runs one tool for every practice client with --all-clients. The session (createSession in mcp/lib/book-tools.js) holds the loaded book, the cloud book pointer and the HMRC grant id that request_hmrc_authorisation sets (MCP-21).
|
|
7
|
+
// - **Run:** `node mcp/bin/diya-submit-mcp.js`; `node mcp/bin/diya-submit-mcp.js --all-clients <tool> [--arg key=value ...]`; `npm --prefix mcp start`
|
|
8
|
+
// - **Entry:** `mcp/lib/server.js:createServer`; `mcp/bin/diya-submit-mcp.js`
|
|
9
|
+
// - **Files:** mcp/lib/server.js, mcp/bin/diya-submit-mcp.js, mcp/vitest.config.js
|
|
10
|
+
// - **Keywords:** mcp server, mcp tools, stdio, model context protocol, diya-submit-mcp, all-clients, tool registry
|
|
11
|
+
// - **Related:** MCP-02, MCP-09, MCP-21
|
|
12
|
+
// @end-capability
|
|
13
|
+
|
|
4
14
|
// server.js -- the submission MCP server, written once over the MCP SDK's
|
|
5
15
|
// transport abstraction so the stdio surface (bin/diya-submit-mcp.js) and
|
|
6
16
|
// the hosted streamable-HTTP surface register the same tools against the
|
|
@@ -13,25 +23,36 @@ import { fileURLToPath } from "node:url";
|
|
|
13
23
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
14
24
|
import { z } from "zod";
|
|
15
25
|
|
|
16
|
-
import { createSession, openBook, saveBook, SAVE_FORMATS } from "./book-tools.js";
|
|
26
|
+
import { createSession, listBooks, openBook, saveBook, SAVE_FORMATS } from "./book-tools.js";
|
|
17
27
|
import { signIn, signOut } from "./auth.js";
|
|
18
28
|
import { writeFinancePackage } from "./finance/package-writer.js";
|
|
19
|
-
import { deriveMicroEntityAccounts, deriveSmallCompanyAccounts } from "./accounts-tools.js";
|
|
29
|
+
import { deriveCompanyTaxReturn, deriveMicroEntityAccounts, deriveSmallCompanyAccounts } from "./accounts-tools.js";
|
|
20
30
|
import { deriveVatReturn } from "./vat-tools.js";
|
|
21
31
|
import { ITSA_TOOLS } from "./itsa-tools.js";
|
|
22
32
|
import { runForClients, RUN_FOR_CLIENTS_TOOLS } from "./batch-tools.js";
|
|
23
33
|
import { moveBookToClient, listClients, addClient, inviteClient, clientAuthorisationStatus } from "./practice-tools.js";
|
|
24
34
|
import {
|
|
25
35
|
listVatObligations,
|
|
36
|
+
listVatLiabilities,
|
|
37
|
+
listVatPayments,
|
|
38
|
+
listVatPenalties,
|
|
39
|
+
getVatReturn,
|
|
26
40
|
submitVatReturn,
|
|
27
41
|
getVatReceipt,
|
|
28
|
-
|
|
42
|
+
listVatReceipts,
|
|
43
|
+
renderMicroEntityAccounts,
|
|
29
44
|
submitMicroEntityAccounts,
|
|
30
|
-
|
|
45
|
+
renderSmallCompanyAccounts,
|
|
46
|
+
submitSmallCompanyAccounts,
|
|
47
|
+
pollSubmission,
|
|
48
|
+
SUBMISSION_KINDS,
|
|
31
49
|
getConfirmationStatementData,
|
|
32
|
-
|
|
50
|
+
renderConfirmationStatement,
|
|
33
51
|
submitConfirmationStatement,
|
|
34
|
-
|
|
52
|
+
requestCompaniesHouseCodes,
|
|
53
|
+
requestHmrcAuthorisation,
|
|
54
|
+
HMRC_SERVICES,
|
|
55
|
+
HMRC_ACCOUNTS,
|
|
35
56
|
} from "./submit-tools.js";
|
|
36
57
|
|
|
37
58
|
const PACKAGE_JSON = resolve(dirname(fileURLToPath(import.meta.url)), "..", "package.json");
|
|
@@ -51,7 +72,30 @@ const balanceSheetYearSchema = z.object({
|
|
|
51
72
|
capitalAndReserves: z.number(),
|
|
52
73
|
});
|
|
53
74
|
|
|
75
|
+
const registeredOfficeSchema = z
|
|
76
|
+
.object({
|
|
77
|
+
addressLine1: z.string(),
|
|
78
|
+
addressLine2: z.string().optional(),
|
|
79
|
+
addressLine3: z.string().optional(),
|
|
80
|
+
cityOrTown: z.string().optional(),
|
|
81
|
+
countyRegion: z.string().optional(),
|
|
82
|
+
postalCode: z.string().optional(),
|
|
83
|
+
country: z.string().optional(),
|
|
84
|
+
})
|
|
85
|
+
.optional()
|
|
86
|
+
.describe("The registered office as address parts; taken from the company's Companies House record when left out");
|
|
87
|
+
|
|
88
|
+
const accountantsReportSchema = z
|
|
89
|
+
.object({
|
|
90
|
+
accountantsName: z.string().describe("The accountancy firm's name"),
|
|
91
|
+
statement: z.string().describe("The statement of the scope of the accountants' report"),
|
|
92
|
+
})
|
|
93
|
+
.optional()
|
|
94
|
+
.describe("Adds the accountants' report page and files the accounts as exempt from audit with an accountants' report");
|
|
95
|
+
|
|
54
96
|
const accountsFilingInputSchema = {
|
|
97
|
+
registeredOffice: registeredOfficeSchema,
|
|
98
|
+
accountantsReport: accountantsReportSchema,
|
|
55
99
|
companyNumber: z.string().describe("The 8-character Companies House company number"),
|
|
56
100
|
companyName: z.string().describe("The registered company name"),
|
|
57
101
|
periodStart: z.string().describe("The accounting period's start date, YYYY-MM-DD"),
|
|
@@ -73,13 +117,109 @@ const accountsFilingInputSchema = {
|
|
|
73
117
|
.describe("Every micro-entity exemption statement, confirmed true by the user before filing"),
|
|
74
118
|
};
|
|
75
119
|
|
|
120
|
+
const smallCompanyBalanceSheetYearSchema = z.object({
|
|
121
|
+
fixedAssets: z.number(),
|
|
122
|
+
stocks: z.number(),
|
|
123
|
+
debtors: z.number(),
|
|
124
|
+
cashAtBank: z.number(),
|
|
125
|
+
tradeCreditors: z.number(),
|
|
126
|
+
corporationTax: z.number(),
|
|
127
|
+
otherCreditors: z.number(),
|
|
128
|
+
creditorsAfterOneYear: z.number(),
|
|
129
|
+
bankLoansOverdrafts: z.number().optional().describe("Whole pounds owed to a bank within one year; 0 when left out"),
|
|
130
|
+
taxationSocialSecurity: z
|
|
131
|
+
.number()
|
|
132
|
+
.optional()
|
|
133
|
+
.describe("Whole pounds of PAYE, National Insurance and VAT owed within one year; 0 when left out"),
|
|
134
|
+
accruals: z.number().optional().describe("Whole pounds of accruals and deferred income due within one year; 0 when left out"),
|
|
135
|
+
bankLoansAfterOneYear: z.number().optional().describe("The part of creditorsAfterOneYear owed to a bank; 0 when left out"),
|
|
136
|
+
calledUpShareCapital: z.number(),
|
|
137
|
+
profitAndLossAccount: z.number(),
|
|
138
|
+
capitalAndReserves: z.number(),
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
const smallCompanyProfitAndLossYearSchema = z.object({
|
|
142
|
+
turnover: z.number(),
|
|
143
|
+
costOfSales: z.number(),
|
|
144
|
+
grossProfit: z.number(),
|
|
145
|
+
administrativeExpenses: z.number(),
|
|
146
|
+
operatingProfit: z.number(),
|
|
147
|
+
interestReceivable: z.number(),
|
|
148
|
+
profitBeforeTax: z.number(),
|
|
149
|
+
tax: z.number(),
|
|
150
|
+
profit: z.number(),
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
const fixedAssetClassSchema = z.object({
|
|
154
|
+
costAtStart: z.number(),
|
|
155
|
+
additions: z.number(),
|
|
156
|
+
disposals: z.number(),
|
|
157
|
+
depreciationAtStart: z.number(),
|
|
158
|
+
depreciationCharge: z.number(),
|
|
159
|
+
depreciationOnDisposals: z.number(),
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
const smallCompanyFilingInputSchema = {
|
|
163
|
+
registeredOffice: registeredOfficeSchema,
|
|
164
|
+
accountantsReport: accountantsReportSchema,
|
|
165
|
+
companyNumber: z.string().describe("The 8-character Companies House company number"),
|
|
166
|
+
companyName: z.string().describe("The registered company name"),
|
|
167
|
+
periodStart: z.string().describe("The accounting period's start date, YYYY-MM-DD"),
|
|
168
|
+
periodEnd: z.string().describe("The accounting period's end date, YYYY-MM-DD"),
|
|
169
|
+
averageEmployees: z.number().describe("The average number of employees in the period"),
|
|
170
|
+
director: z
|
|
171
|
+
.object({ name: z.string(), dateApproved: z.string().describe("YYYY-MM-DD") })
|
|
172
|
+
.describe("The signing director and the date the accounts were approved"),
|
|
173
|
+
statementsAccepted: z
|
|
174
|
+
.object({
|
|
175
|
+
section477Exemption: z.boolean(),
|
|
176
|
+
membersNotRequiredAudit: z.boolean(),
|
|
177
|
+
directorsResponsibilities: z.boolean(),
|
|
178
|
+
smallCompaniesRegime: z.boolean(),
|
|
179
|
+
})
|
|
180
|
+
.describe("Every small-company statement, confirmed true by the user before filing"),
|
|
181
|
+
smallCompany: z
|
|
182
|
+
.object({
|
|
183
|
+
filleted: z.boolean().optional().describe("True to file the filleted copy, without the profit and loss account"),
|
|
184
|
+
principalActivity: z.string(),
|
|
185
|
+
accountingPolicies: z.string(),
|
|
186
|
+
taxPolicy: z.string().optional(),
|
|
187
|
+
currentIncomeTaxPolicy: z.string().optional().describe("How current tax is calculated"),
|
|
188
|
+
dividendPolicy: z.string().optional(),
|
|
189
|
+
goingConcernStatement: z.string().optional(),
|
|
190
|
+
revenueRecognitionPolicy: z.string().optional(),
|
|
191
|
+
tangibleFixedAssetsPolicy: z.string().optional(),
|
|
192
|
+
impairmentPolicy: z.string().optional(),
|
|
193
|
+
financialInstrumentsPolicy: z.string().optional(),
|
|
194
|
+
controllingParty: z
|
|
195
|
+
.object({ ultimate: z.boolean(), name: z.string().optional().describe("Required when the party is ultimate") })
|
|
196
|
+
.optional()
|
|
197
|
+
.describe("Without a name, states that the company has no ultimate controlling party"),
|
|
198
|
+
directors: z.array(z.string()).describe("Every director's name, at least one"),
|
|
199
|
+
balanceSheet: z.object({
|
|
200
|
+
currentYear: smallCompanyBalanceSheetYearSchema,
|
|
201
|
+
priorYear: smallCompanyBalanceSheetYearSchema.optional(),
|
|
202
|
+
}),
|
|
203
|
+
profitAndLoss: z.object({
|
|
204
|
+
currentYear: smallCompanyProfitAndLossYearSchema,
|
|
205
|
+
priorYear: smallCompanyProfitAndLossYearSchema.optional(),
|
|
206
|
+
}),
|
|
207
|
+
fixedAssetNote: z
|
|
208
|
+
.record(
|
|
209
|
+
z.enum(["landBuildings", "plantMachinery", "furnitureFittings", "computerEquipment", "motorVehicles"]),
|
|
210
|
+
fixedAssetClassSchema,
|
|
211
|
+
)
|
|
212
|
+
.optional(),
|
|
213
|
+
})
|
|
214
|
+
.describe("The figures and notes, as derive_small_company_accounts answers them plus principalActivity and accountingPolicies"),
|
|
215
|
+
};
|
|
216
|
+
|
|
76
217
|
const confirmationStatementDirectorSchema = z.object({
|
|
77
218
|
title: z.string().optional(),
|
|
78
219
|
forename: z.string(),
|
|
79
220
|
otherForenames: z.string().optional(),
|
|
80
221
|
surname: z.string(),
|
|
81
222
|
dob: z.string().describe("YYYY-MM-DD"),
|
|
82
|
-
personalCode: z.string().describe("The director's 11-character Companies House personal code"),
|
|
83
223
|
nameMismatchReason: z.string().optional().describe("Required when the director's register name differs from Companies House's own"),
|
|
84
224
|
});
|
|
85
225
|
|
|
@@ -151,6 +291,20 @@ function asToolError(err) {
|
|
|
151
291
|
* one calls: a test can drive the handlers directly against a session
|
|
152
292
|
* without a transport.
|
|
153
293
|
*/
|
|
294
|
+
function hmrcAccountSchema() {
|
|
295
|
+
return z.enum(HMRC_ACCOUNTS).optional().describe("Which HMRC environment to call; defaults to the session's HMRC authorisation's own");
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
function vatEnquirySchema() {
|
|
299
|
+
return {
|
|
300
|
+
vrn: z.string().describe("VAT registration number, 9 digits"),
|
|
301
|
+
from: z.string().optional().describe("From date, YYYY-MM-DD; HMRC's default range when omitted"),
|
|
302
|
+
to: z.string().optional().describe("To date, YYYY-MM-DD; HMRC's default range when omitted"),
|
|
303
|
+
hmrcAccount: hmrcAccountSchema(),
|
|
304
|
+
govTestScenario: z.string().optional().describe("HMRC sandbox test scenario"),
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
|
|
154
308
|
export const TOOLS = {
|
|
155
309
|
sign_in: {
|
|
156
310
|
description:
|
|
@@ -189,6 +343,15 @@ export const TOOLS = {
|
|
|
189
343
|
},
|
|
190
344
|
handler: openBook,
|
|
191
345
|
},
|
|
346
|
+
list_books: {
|
|
347
|
+
description:
|
|
348
|
+
"List the books saved in the DIYA cloud, most recently updated first, signed in as the session's credentials. Each " +
|
|
349
|
+
"row carries the bookId open_book takes. With clientId, lists that practice client's books instead of the practice's own.",
|
|
350
|
+
inputSchema: {
|
|
351
|
+
clientId: z.string().optional().describe("A practice client's id, to list that client's books instead of the practice's own"),
|
|
352
|
+
},
|
|
353
|
+
handler: listBooks,
|
|
354
|
+
},
|
|
192
355
|
save_book: {
|
|
193
356
|
description:
|
|
194
357
|
"Save the session's loaded book to the filesystem. Formats: diya-gl-dir (book.toml + lines.jsonl into a " +
|
|
@@ -263,35 +426,102 @@ export const TOOLS = {
|
|
|
263
426
|
inputSchema: {},
|
|
264
427
|
handler: deriveSmallCompanyAccounts,
|
|
265
428
|
},
|
|
429
|
+
derive_company_tax_return: {
|
|
430
|
+
description:
|
|
431
|
+
"The figures the Company Tax Return form takes, from the session's loaded Company book: the accounting period, the " +
|
|
432
|
+
"computation figures (depreciation, amortisation, entertaining, capital allowances, franked investment income, " +
|
|
433
|
+
"losses brought forward), the profit and loss account from the engine's published statements, and the book's own " +
|
|
434
|
+
"trading profit and Corporation Tax as a working sheet for a check. Refuses a book that is not a Company book, " +
|
|
435
|
+
"makes a trading loss or carries net non-trading loan relationship debits. With a path, also writes the answer as " +
|
|
436
|
+
'the JSON file the Company Tax Return page\'s "Fill from your books" card reads.',
|
|
437
|
+
inputSchema: {
|
|
438
|
+
path: z.string().optional().describe("Where to write the answer as JSON for the Company Tax Return page's import"),
|
|
439
|
+
},
|
|
440
|
+
handler: deriveCompanyTaxReturn,
|
|
441
|
+
},
|
|
442
|
+
request_hmrc_authorisation: {
|
|
443
|
+
description:
|
|
444
|
+
"Answers HMRC's sign-in link for this session, so the VAT tools can call HMRC without a token in the chat. " +
|
|
445
|
+
"Answers {url, expiresAt, scope, hmrcAccount}: show the user the url, wait for them to say HMRC access is " +
|
|
446
|
+
"granted, then call list_vat_obligations or submit_vat_return. The link works once, for ten minutes. DIY " +
|
|
447
|
+
"Accounting Submit keeps HMRC's tokens itself and renews the access token for the rest of the session. A " +
|
|
448
|
+
"second call replaces the session's authorisation. hmrcAccount synthetic is HMRC's sandbox. Over the deployed API.",
|
|
449
|
+
inputSchema: {
|
|
450
|
+
services: z
|
|
451
|
+
.array(z.enum(HMRC_SERVICES))
|
|
452
|
+
.optional()
|
|
453
|
+
.describe(
|
|
454
|
+
"The HMRC services to ask access for: vat (the default), itsa, and agent (the practice tools invite_client and client_authorisation_status)",
|
|
455
|
+
),
|
|
456
|
+
hmrcAccount: z.enum(HMRC_ACCOUNTS).optional().describe("Which HMRC environment: live (the default) or synthetic"),
|
|
457
|
+
},
|
|
458
|
+
handler: requestHmrcAuthorisation,
|
|
459
|
+
},
|
|
266
460
|
list_vat_obligations: {
|
|
267
461
|
description:
|
|
268
462
|
"The open and fulfilled VAT obligations HMRC holds for one VRN, or for one practice client's VRN when clientId " +
|
|
269
|
-
"is given instead of vrn, over the deployed API.
|
|
270
|
-
"
|
|
463
|
+
"is given instead of vrn, over the deployed API. Uses the session's HMRC authorisation: call " +
|
|
464
|
+
"request_hmrc_authorisation first if this tool says none is held.",
|
|
271
465
|
inputSchema: {
|
|
272
466
|
vrn: z.string().optional().describe("VAT registration number, 9 digits; required unless clientId is given"),
|
|
273
467
|
clientId: z.string().optional().describe("A practice client's id, to resolve vrn from the client row instead"),
|
|
274
|
-
hmrcAccessToken: z.string().describe("The user's HMRC OAuth access token"),
|
|
275
468
|
from: z.string().optional().describe("From date, YYYY-MM-DD; defaults to the start of the current calendar year"),
|
|
276
469
|
to: z.string().optional().describe("To date, YYYY-MM-DD; defaults to today"),
|
|
277
470
|
status: z.enum(["O", "F"]).optional().describe("O (Open) or F (Fulfilled); both when omitted"),
|
|
278
|
-
hmrcAccount: z
|
|
471
|
+
hmrcAccount: z
|
|
472
|
+
.enum(HMRC_ACCOUNTS)
|
|
473
|
+
.optional()
|
|
474
|
+
.describe("Which HMRC environment to call; defaults to the session's HMRC authorisation's own"),
|
|
279
475
|
govTestScenario: z.string().optional().describe("HMRC sandbox test scenario"),
|
|
280
476
|
},
|
|
281
477
|
handler: listVatObligations,
|
|
282
478
|
},
|
|
479
|
+
list_vat_liabilities: {
|
|
480
|
+
description:
|
|
481
|
+
"What HMRC says the business owes for VAT, by period, for one VRN over the deployed API. Uses the session's HMRC " +
|
|
482
|
+
"authorisation: call request_hmrc_authorisation first if this tool says none is held.",
|
|
483
|
+
inputSchema: vatEnquirySchema(),
|
|
484
|
+
handler: listVatLiabilities,
|
|
485
|
+
},
|
|
486
|
+
list_vat_payments: {
|
|
487
|
+
description:
|
|
488
|
+
"The VAT payments HMRC has received from the business, by date, for one VRN over the deployed API. Uses the " +
|
|
489
|
+
"session's HMRC authorisation: call request_hmrc_authorisation first if this tool says none is held.",
|
|
490
|
+
inputSchema: vatEnquirySchema(),
|
|
491
|
+
handler: listVatPayments,
|
|
492
|
+
},
|
|
493
|
+
list_vat_penalties: {
|
|
494
|
+
description:
|
|
495
|
+
"The VAT penalties and late-submission points HMRC holds for one VRN over the deployed API. Uses the session's " +
|
|
496
|
+
"HMRC authorisation: call request_hmrc_authorisation first if this tool says none is held.",
|
|
497
|
+
inputSchema: vatEnquirySchema(),
|
|
498
|
+
handler: listVatPenalties,
|
|
499
|
+
},
|
|
500
|
+
get_vat_return: {
|
|
501
|
+
description:
|
|
502
|
+
"One past VAT return as HMRC holds it, by its period key (the periodKey list_vat_obligations answers for a " +
|
|
503
|
+
"fulfilled obligation), over the deployed API. Use it to see what HMRC holds; to read Submit's stored copy of a " +
|
|
504
|
+
"return it filed, use get_vat_receipt. Uses the session's HMRC authorisation: call " +
|
|
505
|
+
"request_hmrc_authorisation first if this tool says none is held.",
|
|
506
|
+
inputSchema: {
|
|
507
|
+
vrn: z.string().describe("VAT registration number, 9 digits"),
|
|
508
|
+
periodKey: z.string().describe("The obligation's period key, for example 18A1"),
|
|
509
|
+
hmrcAccount: hmrcAccountSchema(),
|
|
510
|
+
govTestScenario: z.string().optional().describe("HMRC sandbox test scenario"),
|
|
511
|
+
},
|
|
512
|
+
handler: getVatReturn,
|
|
513
|
+
},
|
|
283
514
|
submit_vat_return: {
|
|
284
515
|
description:
|
|
285
516
|
"Files the nine VAT boxes the user has confirmed (derive_vat_return's hmrc fields) over the deployed API, for " +
|
|
286
517
|
"vatNumber or, when clientId is given instead, for that practice client's own VRN. Boxes 3 and 5 are HMRC's own " +
|
|
287
|
-
"totals and are not sent; the route derives them.
|
|
288
|
-
"
|
|
518
|
+
"totals and are not sent; the route derives them. Uses the session's HMRC authorisation: call " +
|
|
519
|
+
"request_hmrc_authorisation first if this tool says none is held.",
|
|
289
520
|
inputSchema: {
|
|
290
521
|
vatNumber: z.string().optional().describe("VAT registration number, 9 digits; required unless clientId is given"),
|
|
291
522
|
clientId: z.string().optional().describe("A practice client's id, to resolve vatNumber from the client row instead"),
|
|
292
523
|
periodStart: z.string().describe("The obligation's period start, YYYY-MM-DD"),
|
|
293
524
|
periodEnd: z.string().describe("The obligation's period end, YYYY-MM-DD"),
|
|
294
|
-
hmrcAccessToken: z.string().describe("The user's HMRC OAuth access token"),
|
|
295
525
|
vatDueSales: z.number().describe("Box 1"),
|
|
296
526
|
vatDueAcquisitions: z.number().describe("Box 2"),
|
|
297
527
|
vatReclaimedCurrPeriod: z.number().describe("Box 4"),
|
|
@@ -299,7 +529,10 @@ export const TOOLS = {
|
|
|
299
529
|
totalValuePurchasesExVAT: z.number().describe("Box 7"),
|
|
300
530
|
totalValueGoodsSuppliedExVAT: z.number().describe("Box 8"),
|
|
301
531
|
totalAcquisitionsExVAT: z.number().describe("Box 9"),
|
|
302
|
-
hmrcAccount: z
|
|
532
|
+
hmrcAccount: z
|
|
533
|
+
.enum(HMRC_ACCOUNTS)
|
|
534
|
+
.optional()
|
|
535
|
+
.describe("Which HMRC environment to call; defaults to the session's HMRC authorisation's own"),
|
|
303
536
|
govTestScenario: z.string().optional().describe("HMRC sandbox test scenario"),
|
|
304
537
|
runFraudPreventionHeaderValidation: z.boolean().optional(),
|
|
305
538
|
allowSyntheticObligations: z
|
|
@@ -311,7 +544,8 @@ export const TOOLS = {
|
|
|
311
544
|
},
|
|
312
545
|
get_vat_receipt: {
|
|
313
546
|
description:
|
|
314
|
-
"A stored HMRC VAT receipt by its file name, over the deployed API
|
|
547
|
+
"A stored HMRC VAT receipt by its file name, over the deployed API: Submit's own copy of what it filed. To read " +
|
|
548
|
+
"HMRC's copy of a return by period key, use get_vat_return. clientId, when given, narrows the fetch to " +
|
|
315
549
|
"one of the practice's clients but does not change which receipt is read.",
|
|
316
550
|
inputSchema: {
|
|
317
551
|
name: z.string().describe("The receipt file name, including .json (submit_vat_return answers receiptId without the suffix)"),
|
|
@@ -319,73 +553,142 @@ export const TOOLS = {
|
|
|
319
553
|
},
|
|
320
554
|
handler: getVatReceipt,
|
|
321
555
|
},
|
|
322
|
-
|
|
556
|
+
list_vat_receipts: {
|
|
557
|
+
description:
|
|
558
|
+
"The receipts Submit has stored for the signed-in account, the list its receipts page shows: each row carries the " +
|
|
559
|
+
"name get_vat_receipt takes. Use it to find a receipt this chat did not just file. clientId narrows the list to one of the " +
|
|
560
|
+
"practice's clients.",
|
|
561
|
+
inputSchema: {
|
|
562
|
+
clientId: z.string().optional().describe("A practice client's id, to list that client's receipts"),
|
|
563
|
+
},
|
|
564
|
+
handler: listVatReceipts,
|
|
565
|
+
},
|
|
566
|
+
render_micro_entity_accounts_sandbox: {
|
|
323
567
|
description:
|
|
324
568
|
"The rendered FRS 105 micro-entity iXBRL for confirmed figures (derive_micro_entity_accounts' answer), over the " +
|
|
325
569
|
"deployed API. Never reaches the Companies House XML Gateway. The route never resolves a company from a " +
|
|
326
570
|
"practice client's row, so this tool takes companyNumber only, not clientId.",
|
|
327
571
|
inputSchema: accountsFilingInputSchema,
|
|
328
|
-
handler:
|
|
572
|
+
handler: renderMicroEntityAccounts,
|
|
329
573
|
},
|
|
330
|
-
|
|
574
|
+
submit_micro_entity_accounts_sandbox: {
|
|
331
575
|
description:
|
|
332
576
|
"Files confirmed micro-entity accounts through the Companies House XML Gateway, over the deployed API, for " +
|
|
333
577
|
"companyNumber or, when clientId is given instead, for that practice client's own company number; returns the " +
|
|
334
|
-
"submission number.
|
|
578
|
+
"submission number. The company authentication code is not an argument: the user types it on the link " +
|
|
579
|
+
"request_companies_house_codes answers, and this call names that entry by codesEntryId. A single entry is used up by this " +
|
|
580
|
+
"call; a batch entry (clientIds) gives up only this clientId's codes, so run_for_clients can pass one codesEntryId for every client.",
|
|
335
581
|
inputSchema: {
|
|
336
582
|
...accountsFilingInputSchema,
|
|
337
583
|
companyNumber: accountsFilingInputSchema.companyNumber.optional().describe("Required unless clientId is given"),
|
|
338
584
|
clientId: z.string().optional().describe("A practice client's id, to resolve companyNumber from the client row instead"),
|
|
339
|
-
|
|
585
|
+
codesEntryId: z
|
|
586
|
+
.string()
|
|
587
|
+
.describe("The entryId request_companies_house_codes answered, once the user has typed the codes on its link"),
|
|
340
588
|
},
|
|
341
589
|
handler: submitMicroEntityAccounts,
|
|
342
590
|
},
|
|
343
|
-
|
|
344
|
-
description:
|
|
591
|
+
render_small_company_accounts_sandbox: {
|
|
592
|
+
description:
|
|
593
|
+
"The rendered FRS 102 section 1A small-company iXBRL for confirmed figures (derive_small_company_accounts' answer, " +
|
|
594
|
+
"with principalActivity and accountingPolicies added), over the deployed API. Never reaches the Companies House XML " +
|
|
595
|
+
"Gateway. The route never resolves a company from a practice client's row, so this tool takes companyNumber only, " +
|
|
596
|
+
"not clientId.",
|
|
597
|
+
inputSchema: smallCompanyFilingInputSchema,
|
|
598
|
+
handler: renderSmallCompanyAccounts,
|
|
599
|
+
},
|
|
600
|
+
submit_small_company_accounts_sandbox: {
|
|
601
|
+
description:
|
|
602
|
+
"Files confirmed small-company accounts through the Companies House XML Gateway, over the deployed API, for " +
|
|
603
|
+
"companyNumber or, when clientId is given instead, for that practice client's own company number; returns the " +
|
|
604
|
+
"submission number. The company authentication code is not an argument: the user types it on the link " +
|
|
605
|
+
"request_companies_house_codes answers (kind accounts), and this call names that entry by codesEntryId. A single entry " +
|
|
606
|
+
"is used up by this call; a batch entry (clientIds) gives up only this clientId's codes, so run_for_clients can pass " +
|
|
607
|
+
"one codesEntryId for every client. poll_submission with kind accounts reaches the outcome.",
|
|
345
608
|
inputSchema: {
|
|
346
|
-
|
|
609
|
+
...smallCompanyFilingInputSchema,
|
|
610
|
+
companyNumber: smallCompanyFilingInputSchema.companyNumber.optional().describe("Required unless clientId is given"),
|
|
611
|
+
clientId: z.string().optional().describe("A practice client's id, to resolve companyNumber from the client row instead"),
|
|
612
|
+
codesEntryId: z
|
|
613
|
+
.string()
|
|
614
|
+
.describe("The entryId request_companies_house_codes answered, once the user has typed the codes on its link"),
|
|
615
|
+
},
|
|
616
|
+
handler: submitSmallCompanyAccounts,
|
|
617
|
+
},
|
|
618
|
+
request_companies_house_codes: {
|
|
619
|
+
description:
|
|
620
|
+
"Answers a link where the user types the Companies House codes a filing needs, so the codes never appear in " +
|
|
621
|
+
"the chat. Answers {entryId, url, expiresAt}: show the user the url, wait for them to say they have saved the " +
|
|
622
|
+
"codes, then pass entryId as codesEntryId to the filing tool. The link works for ten minutes. A single entry is " +
|
|
623
|
+
"used up by one filing call; ask again for a second filing. To file for several practice clients through " +
|
|
624
|
+
"run_for_clients, give clientIds (kind accounts or confirmation-statement-data, no companyNumber): the page then asks " +
|
|
625
|
+
"for one company authentication code per client by name, and each client's filing call takes only its own client's codes, so " +
|
|
626
|
+
"the one entryId serves the whole batch. kind accounts is for submit_micro_entity_accounts_sandbox and submit_small_company_accounts_sandbox, " +
|
|
627
|
+
"confirmation-statement-data for get_confirmation_statement_data_sandbox, and confirmation-statement (with " +
|
|
628
|
+
"directors, in the order the filing lists them) for submit_confirmation_statement_sandbox. Over the deployed API.",
|
|
629
|
+
inputSchema: {
|
|
630
|
+
kind: z.enum(["accounts", "confirmation-statement", "confirmation-statement-data"]).describe("Which filing the codes are for"),
|
|
631
|
+
companyNumber: z.string().optional().describe("The 8-character Companies House company number; required unless clientIds is given"),
|
|
632
|
+
clientIds: z
|
|
633
|
+
.array(z.string())
|
|
634
|
+
.optional()
|
|
635
|
+
.describe("Practice client ids for a batch filing through run_for_clients: the page asks for one code per client"),
|
|
636
|
+
directors: z
|
|
637
|
+
.array(z.object({ forename: z.string(), surname: z.string() }))
|
|
638
|
+
.optional()
|
|
639
|
+
.describe("Confirmation statement only: the directors in filing order; the page asks for one personal code each"),
|
|
347
640
|
},
|
|
348
|
-
handler:
|
|
641
|
+
handler: requestCompaniesHouseCodes,
|
|
349
642
|
},
|
|
350
|
-
|
|
643
|
+
get_confirmation_statement_data_sandbox: {
|
|
351
644
|
description:
|
|
352
645
|
"The register data a confirmation statement form is built from -- MadeUpDate, NextDueDate, SIC codes, " +
|
|
353
646
|
"RegisteredEmailAddress, officers, PSCs, StatementOfCapital, Shareholdings, TradingOnMarket, DTR5Applies, the PSC " +
|
|
354
|
-
"exemption flags, and whether the payment period is paid -- over the deployed API.
|
|
355
|
-
"authentication code
|
|
647
|
+
"exemption flags, and whether the payment period is paid -- over the deployed API. The company " +
|
|
648
|
+
"authentication code is not an argument: the user types it on the link request_companies_house_codes " +
|
|
649
|
+
"(kind confirmation-statement-data) answers, and this call names that entry by codesEntryId, which it uses up.",
|
|
356
650
|
inputSchema: {
|
|
357
651
|
companyNumber: z.string().describe("The 8-character Companies House company number"),
|
|
358
|
-
|
|
652
|
+
codesEntryId: z
|
|
653
|
+
.string()
|
|
654
|
+
.describe("The entryId request_companies_house_codes answered, once the user has typed the codes on its link"),
|
|
359
655
|
madeUpDate: z.string().describe("The confirmation statement's made-up date, YYYY-MM-DD"),
|
|
360
656
|
companyType: z.string().optional().describe("The company type, when the gateway needs it to resolve the request"),
|
|
361
657
|
},
|
|
362
658
|
handler: getConfirmationStatementData,
|
|
363
659
|
},
|
|
364
|
-
|
|
660
|
+
render_confirmation_statement_sandbox: {
|
|
365
661
|
description:
|
|
366
662
|
"The rendered ConfirmationAndVerificationStatement body for confirmed answers, over the deployed API. Never " +
|
|
367
663
|
"reaches the Companies House XML Gateway; every director's personal code is masked in the rendered body before " +
|
|
368
664
|
"it leaves the route.",
|
|
369
665
|
inputSchema: confirmationStatementFilingInputSchema,
|
|
370
|
-
handler:
|
|
666
|
+
handler: renderConfirmationStatement,
|
|
371
667
|
},
|
|
372
|
-
|
|
668
|
+
submit_confirmation_statement_sandbox: {
|
|
373
669
|
description:
|
|
374
670
|
"Files a confirmed confirmation statement through the Companies House XML Gateway, over the deployed API; " +
|
|
375
|
-
"returns the submission number.
|
|
376
|
-
"
|
|
671
|
+
"returns the submission number. The company authentication code and every director's personal code are not " +
|
|
672
|
+
"arguments: the user types them on the link request_companies_house_codes (kind confirmation-statement, with " +
|
|
673
|
+
"the directors in the order given here) answers, and this call names that entry by codesEntryId, which it uses up.",
|
|
377
674
|
inputSchema: {
|
|
378
675
|
...confirmationStatementFilingInputSchema,
|
|
379
|
-
|
|
676
|
+
codesEntryId: z
|
|
677
|
+
.string()
|
|
678
|
+
.describe("The entryId request_companies_house_codes answered, once the user has typed the codes on its link"),
|
|
380
679
|
},
|
|
381
680
|
handler: submitConfirmationStatement,
|
|
382
681
|
},
|
|
383
|
-
|
|
384
|
-
description:
|
|
682
|
+
poll_submission: {
|
|
683
|
+
description:
|
|
684
|
+
"Accepted, rejected with reasons, or pending, for a submitted Companies House filing, over the deployed API. kind " +
|
|
685
|
+
"accounts is a micro-entity or small-company accounts filing (submit_micro_entity_accounts_sandbox, submit_small_company_accounts_sandbox); kind confirmation-statement is " +
|
|
686
|
+
"a confirmation statement (submit_confirmation_statement_sandbox).",
|
|
385
687
|
inputSchema: {
|
|
688
|
+
kind: z.enum(SUBMISSION_KINDS).describe("accounts or confirmation-statement"),
|
|
386
689
|
submissionNumber: z.string().describe("The 6-character submission number"),
|
|
387
690
|
},
|
|
388
|
-
handler:
|
|
691
|
+
handler: pollSubmission,
|
|
389
692
|
},
|
|
390
693
|
move_book_to_client: {
|
|
391
694
|
description:
|
|
@@ -421,13 +724,12 @@ export const TOOLS = {
|
|
|
421
724
|
invite_client: {
|
|
422
725
|
description:
|
|
423
726
|
"Sends an HMRC Agent Authorisation invitation for one client and one service, over the deployed API. The " +
|
|
424
|
-
"client's own VRN or NINO comes from the client row, not from this call.
|
|
425
|
-
"
|
|
727
|
+
"client's own VRN or NINO comes from the client row, not from this call. Uses the session's HMRC " +
|
|
728
|
+
"authorisation: call request_hmrc_authorisation with services agent first if this tool says none is held.",
|
|
426
729
|
inputSchema: {
|
|
427
730
|
clientId: z.string().describe("The client's id"),
|
|
428
731
|
service: z.enum(["MTD-VAT", "MTD-IT"]).describe("The HMRC service to request authorisation for"),
|
|
429
732
|
knownFact: z.string().describe("The VAT registration date (MTD-VAT) or the client's postcode (MTD-IT)"),
|
|
430
|
-
hmrcAccessToken: z.string().describe("The practice's own HMRC OAuth access token"),
|
|
431
733
|
arn: z
|
|
432
734
|
.string()
|
|
433
735
|
.optional()
|
|
@@ -438,12 +740,11 @@ export const TOOLS = {
|
|
|
438
740
|
client_authorisation_status: {
|
|
439
741
|
description:
|
|
440
742
|
"One client's current authorisation status for one HMRC service, over the deployed API: re-reads a pending " +
|
|
441
|
-
"invitation's own status, or HMRC's relationships endpoint when none is pending.
|
|
442
|
-
"
|
|
743
|
+
"invitation's own status, or HMRC's relationships endpoint when none is pending. Uses the session's HMRC " +
|
|
744
|
+
"authorisation: call request_hmrc_authorisation with services agent first if this tool says none is held.",
|
|
443
745
|
inputSchema: {
|
|
444
746
|
clientId: z.string().describe("The client's id"),
|
|
445
747
|
service: z.enum(["MTD-VAT", "MTD-IT"]).describe("The HMRC service to check"),
|
|
446
|
-
hmrcAccessToken: z.string().describe("The practice's own HMRC OAuth access token"),
|
|
447
748
|
},
|
|
448
749
|
handler: clientAuthorisationStatus,
|
|
449
750
|
},
|
|
@@ -452,7 +753,9 @@ export const TOOLS = {
|
|
|
452
753
|
"Runs one client-scoped tool once per client in the practice's own list (list_clients), passing each client's " +
|
|
453
754
|
"clientId in turn. Returns one row per client -- {clientId, displayName, ok, result or error} -- plus a summary " +
|
|
454
755
|
"count; one client's failure never stops the rest. tool is one of list_vat_obligations, submit_vat_return, " +
|
|
455
|
-
"get_vat_receipt,
|
|
756
|
+
"get_vat_receipt, submit_micro_entity_accounts_sandbox, submit_small_company_accounts_sandbox, open_book, save_book. For the two accounts tools, " +
|
|
757
|
+
"put in args a codesEntryId that request_companies_house_codes answered for these clients' clientIds; each client's call " +
|
|
758
|
+
"takes its own codes from it.",
|
|
456
759
|
inputSchema: {
|
|
457
760
|
tool: z.enum(RUN_FOR_CLIENTS_TOOLS).describe("The client-scoped tool to run for every client"),
|
|
458
761
|
args: z
|