@taxdao/fintax-mcp 0.2.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/README.md +220 -0
- package/dist/app/create-server.d.ts +18 -0
- package/dist/app/create-server.js +80 -0
- package/dist/app/create-server.js.map +1 -0
- package/dist/app/register-tools.d.ts +4 -0
- package/dist/app/register-tools.js +18 -0
- package/dist/app/register-tools.js.map +1 -0
- package/dist/audit/audit-context.d.ts +38 -0
- package/dist/audit/audit-context.js +167 -0
- package/dist/audit/audit-context.js.map +1 -0
- package/dist/audit/audit-sink.d.ts +20 -0
- package/dist/audit/audit-sink.js +6 -0
- package/dist/audit/audit-sink.js.map +1 -0
- package/dist/audit/file-audit-sink.d.ts +6 -0
- package/dist/audit/file-audit-sink.js +18 -0
- package/dist/audit/file-audit-sink.js.map +1 -0
- package/dist/auth/auth-session.d.ts +63 -0
- package/dist/auth/auth-session.js +226 -0
- package/dist/auth/auth-session.js.map +1 -0
- package/dist/auth/credentials.d.ts +6 -0
- package/dist/auth/credentials.js +12 -0
- package/dist/auth/credentials.js.map +1 -0
- package/dist/auth/org-token-provider.d.ts +15 -0
- package/dist/auth/org-token-provider.js +62 -0
- package/dist/auth/org-token-provider.js.map +1 -0
- package/dist/capabilities/capability.d.ts +100 -0
- package/dist/capabilities/capability.js +26 -0
- package/dist/capabilities/capability.js.map +1 -0
- package/dist/capabilities/create-capabilities.d.ts +2 -0
- package/dist/capabilities/create-capabilities.js +37 -0
- package/dist/capabilities/create-capabilities.js.map +1 -0
- package/dist/capabilities/define-capability.d.ts +39 -0
- package/dist/capabilities/define-capability.js +64 -0
- package/dist/capabilities/define-capability.js.map +1 -0
- package/dist/capabilities/definitions/accounting-balances.d.ts +4 -0
- package/dist/capabilities/definitions/accounting-balances.js +98 -0
- package/dist/capabilities/definitions/accounting-balances.js.map +1 -0
- package/dist/capabilities/definitions/accounting-context.d.ts +2 -0
- package/dist/capabilities/definitions/accounting-context.js +17 -0
- package/dist/capabilities/definitions/accounting-context.js.map +1 -0
- package/dist/capabilities/definitions/assets.d.ts +2 -0
- package/dist/capabilities/definitions/assets.js +367 -0
- package/dist/capabilities/definitions/assets.js.map +1 -0
- package/dist/capabilities/definitions/business-documents.d.ts +9 -0
- package/dist/capabilities/definitions/business-documents.js +386 -0
- package/dist/capabilities/definitions/business-documents.js.map +1 -0
- package/dist/capabilities/definitions/dashboard.d.ts +2 -0
- package/dist/capabilities/definitions/dashboard.js +153 -0
- package/dist/capabilities/definitions/dashboard.js.map +1 -0
- package/dist/capabilities/definitions/extended-operation-contracts.d.ts +597 -0
- package/dist/capabilities/definitions/extended-operation-contracts.js +1180 -0
- package/dist/capabilities/definitions/extended-operation-contracts.js.map +1 -0
- package/dist/capabilities/definitions/extended-operations.d.ts +2 -0
- package/dist/capabilities/definitions/extended-operations.js +699 -0
- package/dist/capabilities/definitions/extended-operations.js.map +1 -0
- package/dist/capabilities/definitions/financial-reports.d.ts +2 -0
- package/dist/capabilities/definitions/financial-reports.js +100 -0
- package/dist/capabilities/definitions/financial-reports.js.map +1 -0
- package/dist/capabilities/definitions/fnd-import.d.ts +34 -0
- package/dist/capabilities/definitions/fnd-import.js +282 -0
- package/dist/capabilities/definitions/fnd-import.js.map +1 -0
- package/dist/capabilities/definitions/fund-accounts.d.ts +2 -0
- package/dist/capabilities/definitions/fund-accounts.js +188 -0
- package/dist/capabilities/definitions/fund-accounts.js.map +1 -0
- package/dist/capabilities/definitions/fund-balances.d.ts +2 -0
- package/dist/capabilities/definitions/fund-balances.js +84 -0
- package/dist/capabilities/definitions/fund-balances.js.map +1 -0
- package/dist/capabilities/definitions/journals.d.ts +10 -0
- package/dist/capabilities/definitions/journals.js +224 -0
- package/dist/capabilities/definitions/journals.js.map +1 -0
- package/dist/capabilities/definitions/master-data.d.ts +2 -0
- package/dist/capabilities/definitions/master-data.js +451 -0
- package/dist/capabilities/definitions/master-data.js.map +1 -0
- package/dist/capabilities/definitions/pnl.d.ts +2 -0
- package/dist/capabilities/definitions/pnl.js +139 -0
- package/dist/capabilities/definitions/pnl.js.map +1 -0
- package/dist/capabilities/definitions/reference-data.d.ts +2 -0
- package/dist/capabilities/definitions/reference-data.js +169 -0
- package/dist/capabilities/definitions/reference-data.js.map +1 -0
- package/dist/capabilities/definitions/transaction-drafts.d.ts +2 -0
- package/dist/capabilities/definitions/transaction-drafts.js +157 -0
- package/dist/capabilities/definitions/transaction-drafts.js.map +1 -0
- package/dist/capabilities/definitions/transactions.d.ts +168 -0
- package/dist/capabilities/definitions/transactions.js +79 -0
- package/dist/capabilities/definitions/transactions.js.map +1 -0
- package/dist/capabilities/executor.d.ts +19 -0
- package/dist/capabilities/executor.js +134 -0
- package/dist/capabilities/executor.js.map +1 -0
- package/dist/capabilities/registry.d.ts +7 -0
- package/dist/capabilities/registry.js +51 -0
- package/dist/capabilities/registry.js.map +1 -0
- package/dist/clients/base-client.d.ts +5 -0
- package/dist/clients/base-client.js +13 -0
- package/dist/clients/base-client.js.map +1 -0
- package/dist/clients/http-client.d.ts +29 -0
- package/dist/clients/http-client.js +167 -0
- package/dist/clients/http-client.js.map +1 -0
- package/dist/clients/suite-client.d.ts +5 -0
- package/dist/clients/suite-client.js +5 -0
- package/dist/clients/suite-client.js.map +1 -0
- package/dist/concurrency/lock-manager.d.ts +4 -0
- package/dist/concurrency/lock-manager.js +23 -0
- package/dist/concurrency/lock-manager.js.map +1 -0
- package/dist/config/load-config.d.ts +2 -0
- package/dist/config/load-config.js +18 -0
- package/dist/config/load-config.js.map +1 -0
- package/dist/config/schema.d.ts +24 -0
- package/dist/config/schema.js +85 -0
- package/dist/config/schema.js.map +1 -0
- package/dist/errors/fintax-error.d.ts +24 -0
- package/dist/errors/fintax-error.js +21 -0
- package/dist/errors/fintax-error.js.map +1 -0
- package/dist/errors/normalize-error.d.ts +3 -0
- package/dist/errors/normalize-error.js +67 -0
- package/dist/errors/normalize-error.js.map +1 -0
- package/dist/files/artifact-store.d.ts +17 -0
- package/dist/files/artifact-store.js +74 -0
- package/dist/files/artifact-store.js.map +1 -0
- package/dist/files/input-policy.d.ts +28 -0
- package/dist/files/input-policy.js +109 -0
- package/dist/files/input-policy.js.map +1 -0
- package/dist/files/roots-provider.d.ts +14 -0
- package/dist/files/roots-provider.js +47 -0
- package/dist/files/roots-provider.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +49 -0
- package/dist/index.js.map +1 -0
- package/dist/logging/logger.d.ts +3 -0
- package/dist/logging/logger.js +13 -0
- package/dist/logging/logger.js.map +1 -0
- package/dist/policies/idempotency.d.ts +32 -0
- package/dist/policies/idempotency.js +155 -0
- package/dist/policies/idempotency.js.map +1 -0
- package/dist/policies/job-reference.d.ts +16 -0
- package/dist/policies/job-reference.js +62 -0
- package/dist/policies/job-reference.js.map +1 -0
- package/dist/policies/operation-plan.d.ts +27 -0
- package/dist/policies/operation-plan.js +99 -0
- package/dist/policies/operation-plan.js.map +1 -0
- package/dist/policies/redaction.d.ts +2 -0
- package/dist/policies/redaction.js +29 -0
- package/dist/policies/redaction.js.map +1 -0
- package/dist/policies/retry.d.ts +8 -0
- package/dist/policies/retry.js +19 -0
- package/dist/policies/retry.js.map +1 -0
- package/dist/responses/tool-response.d.ts +4 -0
- package/dist/responses/tool-response.js +24 -0
- package/dist/responses/tool-response.js.map +1 -0
- package/dist/schemas/common.d.ts +226 -0
- package/dist/schemas/common.js +133 -0
- package/dist/schemas/common.js.map +1 -0
- package/dist/schemas/domains/accounting-balances.d.ts +497 -0
- package/dist/schemas/domains/accounting-balances.js +226 -0
- package/dist/schemas/domains/accounting-balances.js.map +1 -0
- package/dist/schemas/domains/accounting-context.d.ts +118 -0
- package/dist/schemas/domains/accounting-context.js +54 -0
- package/dist/schemas/domains/accounting-context.js.map +1 -0
- package/dist/schemas/domains/assets.d.ts +2508 -0
- package/dist/schemas/domains/assets.js +960 -0
- package/dist/schemas/domains/assets.js.map +1 -0
- package/dist/schemas/domains/business-documents.d.ts +4406 -0
- package/dist/schemas/domains/business-documents.js +1153 -0
- package/dist/schemas/domains/business-documents.js.map +1 -0
- package/dist/schemas/domains/configuration.d.ts +518 -0
- package/dist/schemas/domains/configuration.js +504 -0
- package/dist/schemas/domains/configuration.js.map +1 -0
- package/dist/schemas/domains/dashboard.d.ts +339 -0
- package/dist/schemas/domains/dashboard.js +211 -0
- package/dist/schemas/domains/dashboard.js.map +1 -0
- package/dist/schemas/domains/extended-operation-results.d.ts +1588 -0
- package/dist/schemas/domains/extended-operation-results.js +275 -0
- package/dist/schemas/domains/extended-operation-results.js.map +1 -0
- package/dist/schemas/domains/extended-operations.d.ts +1061 -0
- package/dist/schemas/domains/extended-operations.js +567 -0
- package/dist/schemas/domains/extended-operations.js.map +1 -0
- package/dist/schemas/domains/extended-query-results.d.ts +1688 -0
- package/dist/schemas/domains/extended-query-results.js +337 -0
- package/dist/schemas/domains/extended-query-results.js.map +1 -0
- package/dist/schemas/domains/financial-reports.d.ts +540 -0
- package/dist/schemas/domains/financial-reports.js +206 -0
- package/dist/schemas/domains/financial-reports.js.map +1 -0
- package/dist/schemas/domains/fnd-import.d.ts +912 -0
- package/dist/schemas/domains/fnd-import.js +396 -0
- package/dist/schemas/domains/fnd-import.js.map +1 -0
- package/dist/schemas/domains/fund-accounts.d.ts +1092 -0
- package/dist/schemas/domains/fund-accounts.js +410 -0
- package/dist/schemas/domains/fund-accounts.js.map +1 -0
- package/dist/schemas/domains/fund-balances.d.ts +476 -0
- package/dist/schemas/domains/fund-balances.js +233 -0
- package/dist/schemas/domains/fund-balances.js.map +1 -0
- package/dist/schemas/domains/journals.d.ts +1619 -0
- package/dist/schemas/domains/journals.js +615 -0
- package/dist/schemas/domains/journals.js.map +1 -0
- package/dist/schemas/domains/master-data.d.ts +2010 -0
- package/dist/schemas/domains/master-data.js +799 -0
- package/dist/schemas/domains/master-data.js.map +1 -0
- package/dist/schemas/domains/pnl.d.ts +837 -0
- package/dist/schemas/domains/pnl.js +469 -0
- package/dist/schemas/domains/pnl.js.map +1 -0
- package/dist/schemas/domains/reference-data.d.ts +227 -0
- package/dist/schemas/domains/reference-data.js +144 -0
- package/dist/schemas/domains/reference-data.js.map +1 -0
- package/dist/schemas/domains/transaction-drafts.d.ts +903 -0
- package/dist/schemas/domains/transaction-drafts.js +242 -0
- package/dist/schemas/domains/transaction-drafts.js.map +1 -0
- package/dist/schemas/domains/transactions.d.ts +910 -0
- package/dist/schemas/domains/transactions.js +266 -0
- package/dist/schemas/domains/transactions.js.map +1 -0
- package/dist/schemas/primitives.d.ts +6 -0
- package/dist/schemas/primitives.js +11 -0
- package/dist/schemas/primitives.js.map +1 -0
- package/dist/schemas/public-input.d.ts +3 -0
- package/dist/schemas/public-input.js +524 -0
- package/dist/schemas/public-input.js.map +1 -0
- package/dist/tools/core-edit/idempotent-write.d.ts +23 -0
- package/dist/tools/core-edit/idempotent-write.js +58 -0
- package/dist/tools/core-edit/idempotent-write.js.map +1 -0
- package/dist/tools/core-edit/save-asset.d.ts +5 -0
- package/dist/tools/core-edit/save-asset.js +334 -0
- package/dist/tools/core-edit/save-asset.js.map +1 -0
- package/dist/tools/core-edit/save-business-document-draft.d.ts +2 -0
- package/dist/tools/core-edit/save-business-document-draft.js +128 -0
- package/dist/tools/core-edit/save-business-document-draft.js.map +1 -0
- package/dist/tools/core-edit/save-fund-account.d.ts +2 -0
- package/dist/tools/core-edit/save-fund-account.js +138 -0
- package/dist/tools/core-edit/save-fund-account.js.map +1 -0
- package/dist/tools/core-edit/save-journal-draft.d.ts +2 -0
- package/dist/tools/core-edit/save-journal-draft.js +122 -0
- package/dist/tools/core-edit/save-journal-draft.js.map +1 -0
- package/dist/tools/core-edit/save-master-data.d.ts +2 -0
- package/dist/tools/core-edit/save-master-data.js +153 -0
- package/dist/tools/core-edit/save-master-data.js.map +1 -0
- package/dist/tools/core-edit/save-transaction-draft.d.ts +2 -0
- package/dist/tools/core-edit/save-transaction-draft.js +128 -0
- package/dist/tools/core-edit/save-transaction-draft.js.map +1 -0
- package/dist/tools/core-read/export-business-documents.d.ts +2 -0
- package/dist/tools/core-read/export-business-documents.js +67 -0
- package/dist/tools/core-read/export-business-documents.js.map +1 -0
- package/dist/tools/core-read/export-journals.d.ts +2 -0
- package/dist/tools/core-read/export-journals.js +56 -0
- package/dist/tools/core-read/export-journals.js.map +1 -0
- package/dist/tools/core-read/export-transactions.d.ts +2 -0
- package/dist/tools/core-read/export-transactions.js +67 -0
- package/dist/tools/core-read/export-transactions.js.map +1 -0
- package/dist/tools/core-read/query-accounting-balances.d.ts +2 -0
- package/dist/tools/core-read/query-accounting-balances.js +135 -0
- package/dist/tools/core-read/query-accounting-balances.js.map +1 -0
- package/dist/tools/core-read/query-accounting-context.d.ts +2 -0
- package/dist/tools/core-read/query-accounting-context.js +76 -0
- package/dist/tools/core-read/query-accounting-context.js.map +1 -0
- package/dist/tools/core-read/query-assets.d.ts +2 -0
- package/dist/tools/core-read/query-assets.js +425 -0
- package/dist/tools/core-read/query-assets.js.map +1 -0
- package/dist/tools/core-read/query-business-documents.d.ts +9 -0
- package/dist/tools/core-read/query-business-documents.js +620 -0
- package/dist/tools/core-read/query-business-documents.js.map +1 -0
- package/dist/tools/core-read/query-dashboard.d.ts +2 -0
- package/dist/tools/core-read/query-dashboard.js +144 -0
- package/dist/tools/core-read/query-dashboard.js.map +1 -0
- package/dist/tools/core-read/query-financial-reports.d.ts +2 -0
- package/dist/tools/core-read/query-financial-reports.js +171 -0
- package/dist/tools/core-read/query-financial-reports.js.map +1 -0
- package/dist/tools/core-read/query-fund-accounts.d.ts +2 -0
- package/dist/tools/core-read/query-fund-accounts.js +140 -0
- package/dist/tools/core-read/query-fund-accounts.js.map +1 -0
- package/dist/tools/core-read/query-fund-balances.d.ts +2 -0
- package/dist/tools/core-read/query-fund-balances.js +150 -0
- package/dist/tools/core-read/query-fund-balances.js.map +1 -0
- package/dist/tools/core-read/query-journals.d.ts +2 -0
- package/dist/tools/core-read/query-journals.js +277 -0
- package/dist/tools/core-read/query-journals.js.map +1 -0
- package/dist/tools/core-read/query-master-data.d.ts +2 -0
- package/dist/tools/core-read/query-master-data.js +363 -0
- package/dist/tools/core-read/query-master-data.js.map +1 -0
- package/dist/tools/core-read/query-pnl.d.ts +2 -0
- package/dist/tools/core-read/query-pnl.js +244 -0
- package/dist/tools/core-read/query-pnl.js.map +1 -0
- package/dist/tools/core-read/query-reference-data.d.ts +2 -0
- package/dist/tools/core-read/query-reference-data.js +293 -0
- package/dist/tools/core-read/query-reference-data.js.map +1 -0
- package/dist/tools/core-read/query-transactions.d.ts +2 -0
- package/dist/tools/core-read/query-transactions.js +58 -0
- package/dist/tools/core-read/query-transactions.js.map +1 -0
- package/dist/tools/create-tools.d.ts +3 -0
- package/dist/tools/create-tools.js +88 -0
- package/dist/tools/create-tools.js.map +1 -0
- package/dist/tools/extended/asset-operation-tools.d.ts +9 -0
- package/dist/tools/extended/asset-operation-tools.js +419 -0
- package/dist/tools/extended/asset-operation-tools.js.map +1 -0
- package/dist/tools/extended/automation-tools.d.ts +7 -0
- package/dist/tools/extended/automation-tools.js +333 -0
- package/dist/tools/extended/automation-tools.js.map +1 -0
- package/dist/tools/extended/configuration-tools.d.ts +14 -0
- package/dist/tools/extended/configuration-tools.js +871 -0
- package/dist/tools/extended/configuration-tools.js.map +1 -0
- package/dist/tools/extended/period-end-tools.d.ts +11 -0
- package/dist/tools/extended/period-end-tools.js +480 -0
- package/dist/tools/extended/period-end-tools.js.map +1 -0
- package/dist/tools/extended/query-output.d.ts +2589 -0
- package/dist/tools/extended/query-output.js +610 -0
- package/dist/tools/extended/query-output.js.map +1 -0
- package/dist/tools/extended/tool-support.d.ts +56 -0
- package/dist/tools/extended/tool-support.js +198 -0
- package/dist/tools/extended/tool-support.js.map +1 -0
- package/dist/tools/extended/workflow-tools.d.ts +10 -0
- package/dist/tools/extended/workflow-tools.js +678 -0
- package/dist/tools/extended/workflow-tools.js.map +1 -0
- package/dist/tools/fnd-import/execute-import.d.ts +2 -0
- package/dist/tools/fnd-import/execute-import.js +201 -0
- package/dist/tools/fnd-import/execute-import.js.map +1 -0
- package/dist/tools/fnd-import/get-import-template.d.ts +2 -0
- package/dist/tools/fnd-import/get-import-template.js +66 -0
- package/dist/tools/fnd-import/get-import-template.js.map +1 -0
- package/dist/tools/fnd-import/get-job-status.d.ts +8 -0
- package/dist/tools/fnd-import/get-job-status.js +201 -0
- package/dist/tools/fnd-import/get-job-status.js.map +1 -0
- package/dist/tools/fnd-import/prepare-import.d.ts +31 -0
- package/dist/tools/fnd-import/prepare-import.js +214 -0
- package/dist/tools/fnd-import/prepare-import.js.map +1 -0
- package/dist/tools/fnd-import/public-import-result.d.ts +18 -0
- package/dist/tools/fnd-import/public-import-result.js +35 -0
- package/dist/tools/fnd-import/public-import-result.js.map +1 -0
- package/dist/tools/tool-definition.d.ts +45 -0
- package/dist/tools/tool-definition.js +11 -0
- package/dist/tools/tool-definition.js.map +1 -0
- package/dist/tools/tool-handler.d.ts +27 -0
- package/dist/tools/tool-handler.js +196 -0
- package/dist/tools/tool-handler.js.map +1 -0
- package/dist/tools/transaction-item.d.ts +225 -0
- package/dist/tools/transaction-item.js +109 -0
- package/dist/tools/transaction-item.js.map +1 -0
- package/dist/transport/draining-transport.d.ts +14 -0
- package/dist/transport/draining-transport.js +36 -0
- package/dist/transport/draining-transport.js.map +1 -0
- package/dist/transport/stdio.d.ts +2 -0
- package/dist/transport/stdio.js +5 -0
- package/dist/transport/stdio.js.map +1 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.js +3 -0
- package/dist/version.js.map +1 -0
- package/package.json +49 -0
package/README.md
ADDED
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
# FinTax MCP
|
|
2
|
+
|
|
3
|
+
FinTax MCP is a local Model Context Protocol server for FinTax accounting and finance workflows. It uses the official TypeScript MCP SDK and exposes a stdio transport: the MCP host starts the process, sends JSON-RPC on stdin, and reads JSON-RPC from stdout.
|
|
4
|
+
|
|
5
|
+
## Install for an MCP client
|
|
6
|
+
|
|
7
|
+
FinTax MCP is installed as a local stdio process. The published npm package is
|
|
8
|
+
the standard installation method; the MCP client starts its `fintax-mcp`
|
|
9
|
+
command through `npx`.
|
|
10
|
+
|
|
11
|
+
### npm or npx package
|
|
12
|
+
|
|
13
|
+
Run the published package without cloning the source repository:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npx --yes --package @taxdao/fintax-mcp@0.2.0 fintax-mcp
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Use `@taxdao/fintax-mcp` without a version when the client should follow the
|
|
20
|
+
latest published release. For a private registry, configure npm authentication
|
|
21
|
+
and the registry in the client environment before starting the command.
|
|
22
|
+
|
|
23
|
+
### Prebuilt TGZ package
|
|
24
|
+
|
|
25
|
+
For a fixed local archive, place the `.tgz` file on the client machine and
|
|
26
|
+
pass its absolute path to `npx`. The package does not need to be unpacked or
|
|
27
|
+
compiled:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
npx --yes --package /path/to/fintax-mcp-0.2.0.tgz fintax-mcp
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Inject the gateway URL and dedicated MCP credentials through the client's
|
|
34
|
+
protected environment configuration. The project does not load `.env` files
|
|
35
|
+
automatically:
|
|
36
|
+
|
|
37
|
+
```text
|
|
38
|
+
FINTAX_API_URL=https://your-fintax-gateway.example
|
|
39
|
+
FINTAX_USERNAME=your-mcp-service-account
|
|
40
|
+
FINTAX_PASSWORD=your-secret
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
For Codex, add this to `~/.codex/config.toml`:
|
|
44
|
+
|
|
45
|
+
```toml
|
|
46
|
+
[mcp_servers.fintax]
|
|
47
|
+
command = "npx"
|
|
48
|
+
args = ["--yes", "--package", "@taxdao/fintax-mcp@0.2.0", "fintax-mcp"]
|
|
49
|
+
env_vars = ["FINTAX_API_URL", "FINTAX_USERNAME", "FINTAX_PASSWORD", "FINTAX_TOOL_PACKS"]
|
|
50
|
+
startup_timeout_sec = 10
|
|
51
|
+
tool_timeout_sec = 60
|
|
52
|
+
default_tools_approval_mode = "writes"
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
For MCP clients that use the JSON `mcpServers` format, the environment can be
|
|
56
|
+
declared directly in the client configuration:
|
|
57
|
+
|
|
58
|
+
```json
|
|
59
|
+
{
|
|
60
|
+
"mcpServers": {
|
|
61
|
+
"fintax": {
|
|
62
|
+
"command": "npx",
|
|
63
|
+
"args": ["--yes", "--package", "@taxdao/fintax-mcp@0.2.0", "fintax-mcp"],
|
|
64
|
+
"env": {
|
|
65
|
+
"FINTAX_API_URL": "https://your-fintax-gateway.example",
|
|
66
|
+
"FINTAX_USERNAME": "your-mcp-service-account",
|
|
67
|
+
"FINTAX_PASSWORD": "your-secret",
|
|
68
|
+
"FINTAX_TOOL_PACKS": "core-read,fnd-import,core-edit,workflow,period-end,asset-ops,automation,configuration"
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
To use a TGZ in either configuration, replace the package specifier with the
|
|
76
|
+
absolute archive path, for example
|
|
77
|
+
`/path/to/fintax-mcp-0.2.0.tgz`. Keep configuration files containing
|
|
78
|
+
credentials protected by the host account.
|
|
79
|
+
|
|
80
|
+
Any MCP client that launches stdio commands can use the same `npx` command.
|
|
81
|
+
Restart the client, then verify the server with `codex mcp list` or the
|
|
82
|
+
client's MCP tools view. The default directory exposes 77 Tools; login is
|
|
83
|
+
deferred until the first protected business call.
|
|
84
|
+
|
|
85
|
+
## Features
|
|
86
|
+
|
|
87
|
+
- Read-only queries and exports for accounting, transactions, journals, documents, assets, balances, reports, master data, and profit and loss.
|
|
88
|
+
- FND account-transaction import with template, validation, confirmation, and job-status steps. The initial import type is `fund.account`.
|
|
89
|
+
- Draft writes for transactions, fund accounts, master data, journals, business documents, and assets.
|
|
90
|
+
- Explicit prepare/preview and execute pairs for state-changing workflows.
|
|
91
|
+
- Structured success results with `trace_id`, `warnings`, and `source_refs`.
|
|
92
|
+
- Normalized public errors without credentials, stack traces, or raw upstream error text.
|
|
93
|
+
- Static Tool registration at startup. `tools/list` does not require login; authentication starts only for a protected business call.
|
|
94
|
+
|
|
95
|
+
## Architecture
|
|
96
|
+
|
|
97
|
+
```text
|
|
98
|
+
MCP host
|
|
99
|
+
| JSON-RPC over stdin/stdout
|
|
100
|
+
v
|
|
101
|
+
MCP SDK registration
|
|
102
|
+
v
|
|
103
|
+
ToolDefinition and public Schema
|
|
104
|
+
v
|
|
105
|
+
FinTaxToolHandler
|
|
106
|
+
| validation, auth, organization scope, files, plans,
|
|
107
|
+
| idempotency, output validation, errors, and audit
|
|
108
|
+
v
|
|
109
|
+
Capability registry and operation adapter
|
|
110
|
+
v
|
|
111
|
+
Base/Suite HTTP client
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## Tool directory
|
|
115
|
+
|
|
116
|
+
The default startup directory contains 77 Tools across eight fixed packs:
|
|
117
|
+
|
|
118
|
+
| Pack | Count | Scope |
|
|
119
|
+
| --------------- | ----: | ---------------------------------------------------------------------- |
|
|
120
|
+
| `core-read` | 24 | Queries, exports, reference data, and `get_job_status` |
|
|
121
|
+
| `fnd-import` | 3 | Account-import template, validation, and execution |
|
|
122
|
+
| `core-edit` | 9 | Transaction, account, master-data, journal, document, and asset drafts |
|
|
123
|
+
| `workflow` | 8 | Submission, posting, offset candidates, preview, and execution |
|
|
124
|
+
| `period-end` | 9 | Period status, revaluation, close, reconciliation, and reverse close |
|
|
125
|
+
| `asset-ops` | 7 | Depreciation, cost adjustment, impairment, and retirement |
|
|
126
|
+
| `automation` | 5 | Accounting events and accounting-flow execution |
|
|
127
|
+
| `configuration` | 12 | Mapping, rules, allocations, P&L, and generator configuration |
|
|
128
|
+
|
|
129
|
+
Enabled Tools are listed by `tools/list`. The following operations are not exposed: generic `call_api`, dynamic OpenAPI Tools, database access, arbitrary code execution, unsupported import types, hard delete, reversal, unplanned depreciation, `collectAndPost`, and `sync_fund_account`.
|
|
130
|
+
|
|
131
|
+
## Requirements
|
|
132
|
+
|
|
133
|
+
- Node.js 24 LTS (`>=24 <27`)
|
|
134
|
+
- npm and npx supplied with Node.js
|
|
135
|
+
- pnpm 11 or newer for source builds and tests
|
|
136
|
+
- A FinTax gateway that routes authentication, system, and business APIs
|
|
137
|
+
- A FinTax MCP service account with the required capabilities
|
|
138
|
+
|
|
139
|
+
## Configuration
|
|
140
|
+
|
|
141
|
+
Copy `.env.example` as a variable reference only. The service does not read it
|
|
142
|
+
by itself. MCP hosts can pass variables directly through their configuration:
|
|
143
|
+
use `env` in JSON-based clients and `env_vars` in Codex to forward values from
|
|
144
|
+
the host environment.
|
|
145
|
+
|
|
146
|
+
| Variable | Default | Purpose |
|
|
147
|
+
| ---------------------------- | --------------------------- | --------------------------------------------------------------- |
|
|
148
|
+
| `FINTAX_API_URL` | required | Unified FinTax gateway URL |
|
|
149
|
+
| `FINTAX_USERNAME` | required for business calls | Dedicated MCP account |
|
|
150
|
+
| `FINTAX_PASSWORD` | required for business calls | MCP account secret |
|
|
151
|
+
| `FINTAX_DEFAULT_ORG_ID` | empty | Reserved; never replaces explicit write context |
|
|
152
|
+
| `FINTAX_TOOL_PACKS` | all eight packs | Comma-separated fixed startup directory |
|
|
153
|
+
| `FINTAX_ALLOWED_IMPORT_DIRS` | empty | Absolute directories allowed for `local_path` imports |
|
|
154
|
+
| `FINTAX_ARTIFACT_DIR` | `./var/artifacts` | Temporary templates and export artifacts |
|
|
155
|
+
| `FINTAX_AUDIT_DIR` | `./var/audit` | Structured JSONL audit records |
|
|
156
|
+
| `FINTAX_LOG_LEVEL` | `info` | `fatal`, `error`, `warn`, `info`, `debug`, `trace`, or `silent` |
|
|
157
|
+
| `FINTAX_REQUEST_TIMEOUT_MS` | `10000` | Per-request upstream timeout |
|
|
158
|
+
| `FINTAX_SHUTDOWN_TIMEOUT_MS` | `5000` | Bounded shutdown timeout |
|
|
159
|
+
| `FINTAX_MAX_FILE_BYTES` | `26214400` | Maximum import file size |
|
|
160
|
+
|
|
161
|
+
`FINTAX_TOOL_PACKS` is parsed once at startup. Unknown packs, an empty list, or unmet dependencies make startup fail. Tool discovery remains stable for the process lifetime. Missing API credentials do not prevent `initialize` or `tools/list`; a protected call returns structured `AUTH_REQUIRED`.
|
|
162
|
+
|
|
163
|
+
`FINTAX_ARTIFACT_DIR` and `FINTAX_AUDIT_DIR` use paths relative to the MCP
|
|
164
|
+
process working directory unless absolute paths are configured. Set absolute
|
|
165
|
+
paths when artifacts or audit records must remain in stable locations. A
|
|
166
|
+
`cwd` setting is not required for `.tgz` installation.
|
|
167
|
+
|
|
168
|
+
Declare MCP roots when sending a local import path; without roots, arbitrary
|
|
169
|
+
`local_path` inputs are rejected.
|
|
170
|
+
|
|
171
|
+
## Safe call patterns
|
|
172
|
+
|
|
173
|
+
1. Call `query_accounting_context` first when a Tool needs an organization or ledger. Use only IDs returned by that Tool.
|
|
174
|
+
2. Every multi-organization write must include `context.org_id`. Every draft write requires a caller-generated UUID `idempotency_key`.
|
|
175
|
+
3. Read the current object and `version` before an update.
|
|
176
|
+
4. For prepare/preview and execute pairs, show the impact summary and obtain explicit confirmation before execution.
|
|
177
|
+
5. Never retry POST, import confirmation, posting, close, or other state-changing calls automatically. On timeout, follow the read-only recovery Tool.
|
|
178
|
+
6. Amounts are decimal strings. Do not send JSON floating-point values for financial amounts.
|
|
179
|
+
|
|
180
|
+
## Import flow
|
|
181
|
+
|
|
182
|
+
The initial import flow supports only `import_type=fund.account`:
|
|
183
|
+
|
|
184
|
+
```text
|
|
185
|
+
get_import_template
|
|
186
|
+
|
|
|
187
|
+
prepare_import -> validation, operation plan, confirmation token
|
|
188
|
+
|
|
|
189
|
+
explicit user confirmation
|
|
190
|
+
|
|
|
191
|
+
execute_import -> job_id
|
|
192
|
+
|
|
|
193
|
+
get_job_status -> progress and terminal result
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
`prepare_import` creates an upstream validation batch but does not import business data. A confirmation token is short-lived and single-use. If execution times out, query the job reference and do not retry with a new idempotency key.
|
|
197
|
+
|
|
198
|
+
## Runtime behavior
|
|
199
|
+
|
|
200
|
+
- stdout contains only MCP JSON-RPC; logs go to stderr and audit records go to the configured audit directory.
|
|
201
|
+
- Local files must pass realpath, server allowlist, regular-file, type, size, and MCP-root checks.
|
|
202
|
+
- POST operations are not automatically retried; read-only GET retries are bounded.
|
|
203
|
+
- Confirmation tokens and operation plans are opaque, short-lived, single-use handles and are excluded from logs, audit, errors, and execution results.
|
|
204
|
+
- Public errors never include passwords, cookies, access tokens, stack traces, raw upstream responses, or complete financial line items.
|
|
205
|
+
|
|
206
|
+
## Diagnostics
|
|
207
|
+
|
|
208
|
+
```bash
|
|
209
|
+
pnpm build
|
|
210
|
+
pnpm dlx @modelcontextprotocol/inspector@2.2.0 \
|
|
211
|
+
--cli node dist/index.js \
|
|
212
|
+
--method tools/list \
|
|
213
|
+
--format json
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
```bash
|
|
217
|
+
FINTAX_RUN_INTEGRATION=1 pnpm test:integration
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
The integration suite discovers organization and ledger IDs through `query_accounting_context`, runs read-only checks and exports, and does not execute imports.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import type { Logger } from 'pino';
|
|
3
|
+
import type { AuditSink } from '../audit/audit-sink.js';
|
|
4
|
+
import type { CapabilityDefinition } from '../capabilities/capability.js';
|
|
5
|
+
import type { RuntimeConfig } from '../config/schema.js';
|
|
6
|
+
export interface Application {
|
|
7
|
+
readonly server: McpServer;
|
|
8
|
+
close(): Promise<void>;
|
|
9
|
+
}
|
|
10
|
+
export interface ApplicationOptions {
|
|
11
|
+
readonly config?: RuntimeConfig;
|
|
12
|
+
readonly fetch?: typeof fetch;
|
|
13
|
+
readonly auditSink?: AuditSink;
|
|
14
|
+
readonly logger?: Logger;
|
|
15
|
+
readonly capabilities?: readonly CapabilityDefinition[];
|
|
16
|
+
}
|
|
17
|
+
export declare function createApplication(options?: ApplicationOptions): Application;
|
|
18
|
+
export declare function createServer(options?: ApplicationOptions): McpServer;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import { FileAuditSink } from '../audit/file-audit-sink.js';
|
|
3
|
+
import { CapabilityExecutor } from '../capabilities/executor.js';
|
|
4
|
+
import { createCapabilities } from '../capabilities/create-capabilities.js';
|
|
5
|
+
import { CapabilityRegistry } from '../capabilities/registry.js';
|
|
6
|
+
import { loadConfig } from '../config/load-config.js';
|
|
7
|
+
import { LockManager } from '../concurrency/lock-manager.js';
|
|
8
|
+
import { ArtifactStore } from '../files/artifact-store.js';
|
|
9
|
+
import { InputFilePolicy } from '../files/input-policy.js';
|
|
10
|
+
import { McpRootsProvider } from '../files/roots-provider.js';
|
|
11
|
+
import { createLogger } from '../logging/logger.js';
|
|
12
|
+
import { OperationPlanManager } from '../policies/operation-plan.js';
|
|
13
|
+
import { IdempotencyManager } from '../policies/idempotency.js';
|
|
14
|
+
import { createTools } from '../tools/create-tools.js';
|
|
15
|
+
import { FinTaxToolHandler } from '../tools/tool-handler.js';
|
|
16
|
+
import { DrainingTransport } from '../transport/draining-transport.js';
|
|
17
|
+
import { SERVER_NAME, SERVER_VERSION } from '../version.js';
|
|
18
|
+
import { registerTools } from './register-tools.js';
|
|
19
|
+
class ApplicationMcpServer extends McpServer {
|
|
20
|
+
#transport;
|
|
21
|
+
async connect(transport) {
|
|
22
|
+
const drainingTransport = new DrainingTransport(transport);
|
|
23
|
+
this.#transport = drainingTransport;
|
|
24
|
+
try {
|
|
25
|
+
await super.connect(drainingTransport);
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
this.#transport = undefined;
|
|
29
|
+
throw error;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
drainTransport() {
|
|
33
|
+
return this.#transport?.drain() ?? Promise.resolve();
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
export function createApplication(options = {}) {
|
|
37
|
+
const config = options.config ?? loadConfig();
|
|
38
|
+
const server = new ApplicationMcpServer({
|
|
39
|
+
name: SERVER_NAME,
|
|
40
|
+
version: SERVER_VERSION,
|
|
41
|
+
});
|
|
42
|
+
const locks = new LockManager();
|
|
43
|
+
const artifacts = new ArtifactStore(config.FINTAX_ARTIFACT_DIR);
|
|
44
|
+
const capabilities = new CapabilityExecutor({
|
|
45
|
+
config,
|
|
46
|
+
registry: new CapabilityRegistry(options.capabilities ?? createCapabilities()),
|
|
47
|
+
locks,
|
|
48
|
+
...(options.fetch === undefined ? {} : { fetch: options.fetch }),
|
|
49
|
+
});
|
|
50
|
+
const handler = new FinTaxToolHandler({
|
|
51
|
+
capabilities,
|
|
52
|
+
files: new InputFilePolicy({
|
|
53
|
+
allowedDirectories: config.FINTAX_ALLOWED_IMPORT_DIRS,
|
|
54
|
+
maxBytes: config.FINTAX_MAX_FILE_BYTES,
|
|
55
|
+
roots: new McpRootsProvider(server),
|
|
56
|
+
artifacts,
|
|
57
|
+
}),
|
|
58
|
+
artifacts,
|
|
59
|
+
plans: new OperationPlanManager(locks),
|
|
60
|
+
idempotency: new IdempotencyManager(locks),
|
|
61
|
+
locks,
|
|
62
|
+
audit: options.auditSink ?? new FileAuditSink(config.FINTAX_AUDIT_DIR),
|
|
63
|
+
logger: options.logger ?? createLogger(config),
|
|
64
|
+
});
|
|
65
|
+
registerTools(server, createTools(config.FINTAX_TOOL_PACKS), handler);
|
|
66
|
+
return {
|
|
67
|
+
server,
|
|
68
|
+
async close() {
|
|
69
|
+
handler.stopAccepting();
|
|
70
|
+
await handler.drain();
|
|
71
|
+
await server.drainTransport();
|
|
72
|
+
await server.close();
|
|
73
|
+
await handler.close();
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
export function createServer(options = {}) {
|
|
78
|
+
return createApplication(options).server;
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=create-server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-server.js","sourceRoot":"","sources":["../../src/app/create-server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAIpE,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAE5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAEjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AAC5E,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAEtD,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AACvE,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,MAAM,oBAAqB,SAAQ,SAAS;IAC1C,UAAU,CAAgC;IAEjC,KAAK,CAAC,OAAO,CAAC,SAAoB;QACzC,MAAM,iBAAiB,GAAG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tC,KAAK,EAAE,IAAI,gBAAgB,CAAC,MAAM,CAAC;YACnC,SAAS;SACV,CAAC;QACF,SAAS;QACT,KAAK,EAAE,IAAI,oBAAoB,CAAC,KAAK,CAAC;QACtC,WAAW,EAAE,IAAI,kBAAkB,CAAC,KAAK,CAAC;QAC1C,KAAK;QACL,KAAK,EAAE,OAAO,CAAC,SAAS,IAAI,IAAI,aAAa,CAAC,MAAM,CAAC,gBAAgB,CAAC;QACtE,MAAM,EAAE,OAAO,CAAC,MAAM,IAAI,YAAY,CAAC,MAAM,CAAC;KAC/C,CAAC,CAAC;IAEH,aAAa,CAAC,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC,iBAAiB,CAAC,EAAE,OAAO,CAAC,CAAC;IACtE,OAAO;QACL,MAAM;QACN,KAAK,CAAC,KAAK;YACT,OAAO,CAAC,aAAa,EAAE,CAAC;YACxB,MAAM,OAAO,CAAC,KAAK,EAAE,CAAC;YACtB,MAAM,MAAM,CAAC,cAAc,EAAE,CAAC;YAC9B,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;YACrB,MAAM,OAAO,CAAC,KAAK,EAAE,CAAC;QACxB,CAAC;KACF,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,UAA8B,EAAE;IAC3D,OAAO,iBAAiB,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC;AAC3C,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import type { ToolDefinition } from '../tools/tool-definition.js';
|
|
3
|
+
import type { FinTaxToolHandler } from '../tools/tool-handler.js';
|
|
4
|
+
export declare function registerTools(server: McpServer, definitions: readonly ToolDefinition[], handler: FinTaxToolHandler): void;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { createSdkInputSchema } from '../schemas/public-input.js';
|
|
2
|
+
export function registerTools(server, definitions, handler) {
|
|
3
|
+
const names = new Set();
|
|
4
|
+
for (const definition of definitions) {
|
|
5
|
+
if (names.has(definition.name)) {
|
|
6
|
+
throw new Error(`Duplicate MCP tool name: ${definition.name}`);
|
|
7
|
+
}
|
|
8
|
+
names.add(definition.name);
|
|
9
|
+
server.registerTool(definition.name, {
|
|
10
|
+
title: definition.title,
|
|
11
|
+
description: `${definition.description} Risk level: ${definition.risk}. Deployment pack: ${definition.exposurePack}.`,
|
|
12
|
+
inputSchema: createSdkInputSchema(definition.inputSchema, definition.publicInputSchema),
|
|
13
|
+
outputSchema: definition.outputSchema,
|
|
14
|
+
annotations: definition.annotations,
|
|
15
|
+
}, (params) => handler.invoke(definition, params));
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=register-tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"register-tools.js","sourceRoot":"","sources":["../../src/app/register-tools.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAIlE,MAAM,UAAU,aAAa,CAC3B,MAAiB,EACjB,WAAsC,EACtC,OAA0B;IAE1B,MAAM,KAAK,GAAG,IAAI,GAAG,EAAU,CAAC;IAEhC,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE,CAAC;QACrC,IAAI,KAAK,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;YAC/B,MAAM,IAAI,KAAK,CAAC,4BAA4B,UAAU,CAAC,IAAI,EAAE,CAAC,CAAC;QACjE,CAAC;QACD,KAAK,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QAE3B,MAAM,CAAC,YAAY,CACjB,UAAU,CAAC,IAAI,EACf;YACE,KAAK,EAAE,UAAU,CAAC,KAAK;YACvB,WAAW,EAAE,GAAG,UAAU,CAAC,WAAW,gBAAgB,UAAU,CAAC,IAAI,sBAAsB,UAAU,CAAC,YAAY,GAAG;YACrH,WAAW,EAAE,oBAAoB,CAC/B,UAAU,CAAC,WAAW,EACtB,UAAU,CAAC,iBAAiB,CAC7B;YACD,YAAY,EAAE,UAAU,CAAC,YAAY;YACrC,WAAW,EAAE,UAAU,CAAC,WAAW;SACpC,EACD,CAAC,MAAM,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,CAC/C,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { AuthIdentity } from '../auth/auth-session.js';
|
|
2
|
+
import type { HttpMethod, ServiceName } from '../capabilities/capability.js';
|
|
3
|
+
export interface AuditSummary {
|
|
4
|
+
readonly digest: string;
|
|
5
|
+
readonly fields: readonly string[];
|
|
6
|
+
}
|
|
7
|
+
export interface AuditActor {
|
|
8
|
+
readonly userId?: string;
|
|
9
|
+
readonly tenantId?: string;
|
|
10
|
+
readonly orgId?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface UpstreamAuditCall {
|
|
13
|
+
readonly service: ServiceName;
|
|
14
|
+
readonly operation: string;
|
|
15
|
+
readonly method: HttpMethod;
|
|
16
|
+
readonly outcome: 'succeeded' | 'failed';
|
|
17
|
+
readonly statusCodes: readonly number[];
|
|
18
|
+
}
|
|
19
|
+
export interface AuditSnapshot {
|
|
20
|
+
readonly actor?: AuditActor;
|
|
21
|
+
readonly targetObjectIds?: Readonly<Record<string, readonly string[]>>;
|
|
22
|
+
readonly filterSummary?: AuditSummary;
|
|
23
|
+
readonly fileChecksums?: readonly string[];
|
|
24
|
+
readonly operationPlanSummary?: string;
|
|
25
|
+
readonly idempotencyKeySummary?: string;
|
|
26
|
+
readonly idempotencyOutcome?: 'started' | 'replayed' | 'failed';
|
|
27
|
+
readonly upstreamCalls?: readonly UpstreamAuditCall[];
|
|
28
|
+
}
|
|
29
|
+
export declare class AuditContext {
|
|
30
|
+
#private;
|
|
31
|
+
captureInput(input: unknown): void;
|
|
32
|
+
captureIdentity(identity: AuthIdentity): void;
|
|
33
|
+
captureTargetObjectId(field: string, value: string): void;
|
|
34
|
+
captureFileChecksum(checksum: string): void;
|
|
35
|
+
captureIdempotencyOutcome(outcome: NonNullable<AuditSnapshot['idempotencyOutcome']>): void;
|
|
36
|
+
recordUpstreamCall(call: UpstreamAuditCall): void;
|
|
37
|
+
snapshot(): AuditSnapshot;
|
|
38
|
+
}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { hashOperationValue } from '../policies/operation-plan.js';
|
|
2
|
+
const SECRET_FIELDS = new Set([
|
|
3
|
+
'confirmation_token',
|
|
4
|
+
'idempotency_key',
|
|
5
|
+
'operation_plan_id',
|
|
6
|
+
]);
|
|
7
|
+
const REFERENCE_FIELDS = new Set(['file_ref']);
|
|
8
|
+
const OMITTED_FIELDS = new Set(['file_content', 'lines', 'raw_file']);
|
|
9
|
+
const NON_TARGET_IDS = new Set(['org_id', 'tenant_id', 'user_id']);
|
|
10
|
+
function digest(namespace, value) {
|
|
11
|
+
return hashOperationValue({ namespace, value });
|
|
12
|
+
}
|
|
13
|
+
function isTargetIdField(key) {
|
|
14
|
+
return (!NON_TARGET_IDS.has(key) &&
|
|
15
|
+
(key === 'id' || key.endsWith('_id') || key.endsWith('_ids')));
|
|
16
|
+
}
|
|
17
|
+
function summarizeInput(input) {
|
|
18
|
+
const fields = new Set();
|
|
19
|
+
const targetObjectIds = new Map();
|
|
20
|
+
const visit = (value, path) => {
|
|
21
|
+
if (Array.isArray(value)) {
|
|
22
|
+
return value.map((entry, index) => visit(entry, [...path, String(index)]));
|
|
23
|
+
}
|
|
24
|
+
if (value === null || typeof value !== 'object') {
|
|
25
|
+
if (path.length > 0)
|
|
26
|
+
fields.add(path.join('.'));
|
|
27
|
+
return value;
|
|
28
|
+
}
|
|
29
|
+
return Object.fromEntries(Object.entries(value).map(([key, entry]) => {
|
|
30
|
+
const nextPath = [...path, key];
|
|
31
|
+
if (SECRET_FIELDS.has(key)) {
|
|
32
|
+
fields.add(nextPath.join('.'));
|
|
33
|
+
return [key, '[REDACTED]'];
|
|
34
|
+
}
|
|
35
|
+
if (REFERENCE_FIELDS.has(key)) {
|
|
36
|
+
fields.add(nextPath.join('.'));
|
|
37
|
+
const kind = entry !== null &&
|
|
38
|
+
typeof entry === 'object' &&
|
|
39
|
+
'kind' in entry &&
|
|
40
|
+
typeof entry.kind === 'string'
|
|
41
|
+
? entry.kind
|
|
42
|
+
: 'unknown';
|
|
43
|
+
return [key, { kind, value: '[REFERENCE]' }];
|
|
44
|
+
}
|
|
45
|
+
if (OMITTED_FIELDS.has(key)) {
|
|
46
|
+
fields.add(nextPath.join('.'));
|
|
47
|
+
return [key, '[OMITTED]'];
|
|
48
|
+
}
|
|
49
|
+
if (isTargetIdField(key)) {
|
|
50
|
+
const values = Array.isArray(entry) ? entry : [entry];
|
|
51
|
+
const ids = targetObjectIds.get(key) ?? new Set();
|
|
52
|
+
for (const candidate of values) {
|
|
53
|
+
if (typeof candidate === 'string')
|
|
54
|
+
ids.add(candidate);
|
|
55
|
+
}
|
|
56
|
+
if (ids.size > 0)
|
|
57
|
+
targetObjectIds.set(key, ids);
|
|
58
|
+
}
|
|
59
|
+
return [key, visit(entry, nextPath)];
|
|
60
|
+
}));
|
|
61
|
+
};
|
|
62
|
+
const summarized = visit(input, []);
|
|
63
|
+
return {
|
|
64
|
+
value: summarized,
|
|
65
|
+
fields: [...fields].sort(),
|
|
66
|
+
targetObjectIds: new Map([...targetObjectIds].map(([key, values]) => [key, [...values].sort()])),
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
export class AuditContext {
|
|
70
|
+
#actor;
|
|
71
|
+
#filterSummary;
|
|
72
|
+
#operationPlanSummary;
|
|
73
|
+
#idempotencyKeySummary;
|
|
74
|
+
#idempotencyOutcome;
|
|
75
|
+
#targetObjectIds = new Map();
|
|
76
|
+
#fileChecksums = new Set();
|
|
77
|
+
#upstreamCalls = [];
|
|
78
|
+
captureInput(input) {
|
|
79
|
+
const summarized = summarizeInput(input);
|
|
80
|
+
this.#filterSummary = {
|
|
81
|
+
digest: digest('tool-input', summarized.value),
|
|
82
|
+
fields: summarized.fields,
|
|
83
|
+
};
|
|
84
|
+
for (const [field, values] of summarized.targetObjectIds) {
|
|
85
|
+
for (const value of values)
|
|
86
|
+
this.captureTargetObjectId(field, value);
|
|
87
|
+
}
|
|
88
|
+
if (input === null || typeof input !== 'object')
|
|
89
|
+
return;
|
|
90
|
+
if ('operation_plan_id' in input &&
|
|
91
|
+
typeof input.operation_plan_id === 'string') {
|
|
92
|
+
this.#operationPlanSummary = digest('operation-plan', input.operation_plan_id);
|
|
93
|
+
}
|
|
94
|
+
if ('idempotency_key' in input &&
|
|
95
|
+
typeof input.idempotency_key === 'string') {
|
|
96
|
+
this.#idempotencyKeySummary = digest('idempotency-key', input.idempotency_key);
|
|
97
|
+
}
|
|
98
|
+
if ('context' in input &&
|
|
99
|
+
input.context !== null &&
|
|
100
|
+
typeof input.context === 'object' &&
|
|
101
|
+
'org_id' in input.context &&
|
|
102
|
+
typeof input.context.org_id === 'string') {
|
|
103
|
+
this.#actor = {
|
|
104
|
+
...(this.#actor?.userId === undefined
|
|
105
|
+
? {}
|
|
106
|
+
: { userId: this.#actor.userId }),
|
|
107
|
+
...(this.#actor?.tenantId === undefined
|
|
108
|
+
? {}
|
|
109
|
+
: { tenantId: this.#actor.tenantId }),
|
|
110
|
+
orgId: digest('actor-org', input.context.org_id),
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
captureIdentity(identity) {
|
|
115
|
+
this.#actor = {
|
|
116
|
+
userId: digest('actor-user', identity.userId),
|
|
117
|
+
tenantId: digest('actor-tenant', identity.tenantId),
|
|
118
|
+
...(identity.orgId === undefined
|
|
119
|
+
? this.#actor?.orgId === undefined
|
|
120
|
+
? {}
|
|
121
|
+
: { orgId: this.#actor.orgId }
|
|
122
|
+
: { orgId: digest('actor-org', identity.orgId) }),
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
captureTargetObjectId(field, value) {
|
|
126
|
+
const values = this.#targetObjectIds.get(field) ?? new Set();
|
|
127
|
+
values.add(value);
|
|
128
|
+
this.#targetObjectIds.set(field, values);
|
|
129
|
+
}
|
|
130
|
+
captureFileChecksum(checksum) {
|
|
131
|
+
this.#fileChecksums.add(checksum);
|
|
132
|
+
}
|
|
133
|
+
captureIdempotencyOutcome(outcome) {
|
|
134
|
+
this.#idempotencyOutcome = outcome;
|
|
135
|
+
}
|
|
136
|
+
recordUpstreamCall(call) {
|
|
137
|
+
this.#upstreamCalls.push(call);
|
|
138
|
+
}
|
|
139
|
+
snapshot() {
|
|
140
|
+
const targetObjectIds = Object.fromEntries([...this.#targetObjectIds]
|
|
141
|
+
.sort(([left], [right]) => left.localeCompare(right))
|
|
142
|
+
.map(([field, values]) => [field, [...values].sort()]));
|
|
143
|
+
return {
|
|
144
|
+
...(this.#actor === undefined ? {} : { actor: this.#actor }),
|
|
145
|
+
...(Object.keys(targetObjectIds).length === 0 ? {} : { targetObjectIds }),
|
|
146
|
+
...(this.#filterSummary === undefined
|
|
147
|
+
? {}
|
|
148
|
+
: { filterSummary: this.#filterSummary }),
|
|
149
|
+
...(this.#fileChecksums.size === 0
|
|
150
|
+
? {}
|
|
151
|
+
: { fileChecksums: [...this.#fileChecksums].sort() }),
|
|
152
|
+
...(this.#operationPlanSummary === undefined
|
|
153
|
+
? {}
|
|
154
|
+
: { operationPlanSummary: this.#operationPlanSummary }),
|
|
155
|
+
...(this.#idempotencyKeySummary === undefined
|
|
156
|
+
? {}
|
|
157
|
+
: { idempotencyKeySummary: this.#idempotencyKeySummary }),
|
|
158
|
+
...(this.#idempotencyOutcome === undefined
|
|
159
|
+
? {}
|
|
160
|
+
: { idempotencyOutcome: this.#idempotencyOutcome }),
|
|
161
|
+
...(this.#upstreamCalls.length === 0
|
|
162
|
+
? {}
|
|
163
|
+
: { upstreamCalls: [...this.#upstreamCalls] }),
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
//# sour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AI,CAAC,cAAc,EAAE,CAAC;YAC3C,GAAG,CAAC,IAAI,CAAC,cAAc,CAAC,IAAI,KAAK,CAAC;gBAChC,CAAC,CAAC,EAAE;gBACJ,CAAC,CAAC,EAAE,aAAa,EAAE,CAAC,GAAG,IAAI,CAAC,cAAc,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC;YACvD,GAAG,CAAC,IAAI,CAAC,qBAAqB,KAAK,SAAS;gBAC1C,CAAC,CAAC,EAAE;gBACJ,CAAC,CAAC,EAAE,oBAAoB,EAAE,IAAI,CAAC,qBAAqB,EAAE,CAAC;YACzD,GAAG,CAAC,IAAI,CAAC,sBAAsB,KAAK,SAAS;gBAC3C,CAAC,CAAC,EAAE;gBACJ,CAAC,CAAC,EAAE,qBAAqB,EAAE,IAAI,CAAC,sBAAsB,EAAE,CAAC;YAC3D,GAAG,CAAC,IAAI,CAAC,mBAAmB,KAAK,SAAS;gBACxC,CAAC,CAAC,EAAE;gBACJ,CAAC,CAAC,EAAE,kBAAkB,EAAE,IAAI,CAAC,mBAAmB,EAAE,CAAC;YACrD,GAAG,CAAC,IAAI,CAAC,cAAc,CAAC,MAAM,KAAK,CAAC;gBAClC,CAAC,CAAC,EAAE;gBACJ,CAAC,CAAC,EAAE,aAAa,EAAE,CAAC,GAAG,IAAI,CAAC,cAAc,CAAC,EAAE,CAAC;SACjD,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { RiskLevel } from '../tools/tool-definition.js';
|
|
2
|
+
import type { AuditSnapshot } from './audit-context.js';
|
|
3
|
+
export interface AuditRecord extends AuditSnapshot {
|
|
4
|
+
readonly traceId: string;
|
|
5
|
+
readonly tool: string;
|
|
6
|
+
readonly version: string;
|
|
7
|
+
readonly risk: RiskLevel;
|
|
8
|
+
readonly capabilityIds: readonly string[];
|
|
9
|
+
readonly startedAt: string;
|
|
10
|
+
readonly finishedAt: string;
|
|
11
|
+
readonly durationMs: number;
|
|
12
|
+
readonly status: 'succeeded' | 'failed';
|
|
13
|
+
readonly errorCode?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface AuditSink {
|
|
16
|
+
write(record: AuditRecord): Promise<void>;
|
|
17
|
+
}
|
|
18
|
+
export declare class NullAuditSink implements AuditSink {
|
|
19
|
+
write(): Promise<void>;
|
|
20
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audit-sink.js","sourceRoot":"","sources":["../../src/audit/audit-sink.ts"],"names":[],"mappings":"AAoBA,MAAM,OAAO,aAAa;IACxB,KAAK;QACH,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC;CACF"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { appendFile, mkdir } from 'node:fs/promises';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
export class FileAuditSink {
|
|
4
|
+
#directory;
|
|
5
|
+
constructor(directory) {
|
|
6
|
+
this.#directory = path.resolve(directory);
|
|
7
|
+
}
|
|
8
|
+
async write(record) {
|
|
9
|
+
await mkdir(this.#directory, { recursive: true, mode: 0o700 });
|
|
10
|
+
const date = record.startedAt.slice(0, 10);
|
|
11
|
+
const file = path.join(this.#directory, `${date}.jsonl`);
|
|
12
|
+
await appendFile(file, `${JSON.stringify(record)}\n`, {
|
|
13
|
+
encoding: 'utf8',
|
|
14
|
+
mode: 0o600,
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=file-audit-sink.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-audit-sink.js","sourceRoot":"","sources":["../../src/audit/file-audit-sink.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,IAAI,MAAM,WAAW,CAAC;AAI7B,MAAM,OAAO,aAAa;IACf,UAAU,CAAS;IAE5B,YAAY,SAAiB;QAC3B,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAC5C,CAAC;IAED,KAAK,CAAC,KAAK,CAAC,MAAmB;QAC7B,MAAM,KAAK,CAAC,IAAI,CAAC,UAAU,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;QAC/D,MAAM,IAAI,GAAG,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QAC3C,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,GAAG,IAAI,QAAQ,CAAC,CAAC;QACzD,MAAM,UAAU,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,EAAE;YACpD,QAAQ,EAAE,MAAM;YAChB,IAAI,EAAE,KAAK;SACZ,CAAC,CAAC;IACL,CAAC;CACF"}
|