@frigear-nu/mcp 0.0.3 → 0.0.5
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/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { defineNuxtModule, createResolver, addServerImportsDir, addServerPlugin } from '@nuxt/kit';
|
|
2
|
+
import { inlineModuleRuntime } from '@frigear-nu/module-kit/utils';
|
|
2
3
|
export { addMcpDefinitions } from '../dist/runtime/utils/build.js';
|
|
3
4
|
|
|
4
5
|
const DEFAULT_INSTRUCTIONS = [
|
|
5
6
|
"You act as the signed-in user, limited to the scopes of the API token in use. You only see the tools that token and the user are allowed to use.",
|
|
6
7
|
'Personal data of other people (names, emails, form answers) is withheld unless the token carries the matching "*:pii" scope. Responses say when something was withheld; report that to the user instead of looking for another way to get it.',
|
|
8
|
+
'All monetary values, in tool inputs and outputs, are in whole currency units next to a currency code: 52.2 with "USD" means 52.20 US dollars, never cents. Currencies without decimals (JPY) are whole numbers.',
|
|
7
9
|
"Some settings are deliberately not available here, for example where form submissions are delivered, because changing them could be used to exfiltrate data. When a tool refuses for that reason, tell the user to make the change in the admin UI."
|
|
8
10
|
].join("\n");
|
|
9
11
|
const module$1 = defineNuxtModule({
|
|
@@ -27,6 +29,7 @@ const module$1 = defineNuxtModule({
|
|
|
27
29
|
instructions: host.mcp?.instructions ?? DEFAULT_INSTRUCTIONS
|
|
28
30
|
};
|
|
29
31
|
addServerImportsDir(resolver.resolve("./runtime/server/utils"));
|
|
32
|
+
inlineModuleRuntime(nuxt, resolver);
|
|
30
33
|
addServerPlugin(resolver.resolve("./runtime/server/plugins/mcp"));
|
|
31
34
|
}
|
|
32
35
|
});
|
|
@@ -2,3 +2,4 @@ export { addMcpDefinitions } from './build.js';
|
|
|
2
2
|
export type { McpDefinitionKind } from './build.js';
|
|
3
3
|
export { SCOPED_META_KEY, isPrincipalAllowed, pick, piiNotice, redactPii, scopeTags } from './access.js';
|
|
4
4
|
export type { RedactOptions, ScopedAccess } from './access.js';
|
|
5
|
+
export { MONEY_NOTICE, currencyDigits, fieldsFromCents, fromCents, toCents } from './money.js';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** Standing sentence for descriptions and `describe()` texts of money fields. */
|
|
2
|
+
export declare const MONEY_NOTICE = "Whole currency units, not cents: 52.2 means 52.20 of the currency (JPY has no decimals).";
|
|
3
|
+
/** The number of minor-unit digits of a currency (2 for EUR, 0 for JPY, 3 for KWD). */
|
|
4
|
+
export declare function currencyDigits(currency: string): number;
|
|
5
|
+
/** Minor units (cents) to the major-unit number agents see, e.g. `fromCents(5220, 'USD')` -> `52.2`. */
|
|
6
|
+
export declare function fromCents(amount: number, currency: string): number;
|
|
7
|
+
export declare function fromCents(amount: number | null | undefined, currency: string): number | null;
|
|
8
|
+
/** A major-unit number from an agent to whole minor units (cents), e.g. `toCents(52.2, 'USD')` -> `5220`. */
|
|
9
|
+
export declare function toCents(value: number, currency: string): number;
|
|
10
|
+
/** Returns a copy of `row` with its `fields` converted from minor to major units. */
|
|
11
|
+
export declare function fieldsFromCents<T extends Record<string, unknown>>(row: T, fields: Array<keyof T & string>, currency: string): T;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export const MONEY_NOTICE = "Whole currency units, not cents: 52.2 means 52.20 of the currency (JPY has no decimals).";
|
|
2
|
+
export function currencyDigits(currency) {
|
|
3
|
+
try {
|
|
4
|
+
return new Intl.NumberFormat("en", { style: "currency", currency: currency.toUpperCase() }).resolvedOptions().maximumFractionDigits ?? 2;
|
|
5
|
+
} catch {
|
|
6
|
+
return 2;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
export function fromCents(amount, currency) {
|
|
10
|
+
if (amount === null || amount === void 0) return null;
|
|
11
|
+
return Number((amount / 10 ** currencyDigits(currency)).toFixed(currencyDigits(currency)));
|
|
12
|
+
}
|
|
13
|
+
export function toCents(value, currency) {
|
|
14
|
+
if (!Number.isFinite(value)) throw new TypeError("Amount must be a finite number.");
|
|
15
|
+
return Math.round(value * 10 ** currencyDigits(currency));
|
|
16
|
+
}
|
|
17
|
+
export function fieldsFromCents(row, fields, currency) {
|
|
18
|
+
const out = { ...row };
|
|
19
|
+
for (const field of fields) {
|
|
20
|
+
const value = out[field];
|
|
21
|
+
if (typeof value === "number") out[field] = fromCents(value, currency);
|
|
22
|
+
}
|
|
23
|
+
return out;
|
|
24
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@frigear-nu/mcp",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"description": "Scoped, PII-safe MCP tools for the frigear ecosystem: modules contribute tools, resources and prompts that are only listed and callable within the scopes the caller holds.",
|
|
5
5
|
"homepage": "https://docs.frigear.dev/modules/mcp",
|
|
6
6
|
"repository": {
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
"playground"
|
|
31
31
|
],
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@frigear-nu/auth": "0.0.
|
|
34
|
-
"@frigear-nu/module-kit": "0.1
|
|
33
|
+
"@frigear-nu/auth": "0.0.5",
|
|
34
|
+
"@frigear-nu/module-kit": "1.0.1",
|
|
35
35
|
"@nuxt/kit": "^4.6.0",
|
|
36
36
|
"@nuxtjs/mcp-toolkit": "^0.24.1",
|
|
37
37
|
"agents": "^0.28.0",
|