@alfe.ai/xero-mcp 0.3.16 → 0.3.18
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 +32 -7
- package/dist/server.cjs +856 -0
- package/dist/server.d.cts +108 -0
- package/dist/server.d.ts +108 -1
- package/dist/server.js +811 -330
- package/package.json +11 -8
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
2
|
+
import { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
|
|
3
|
+
|
|
4
|
+
//#region src/boundary.d.ts
|
|
5
|
+
|
|
6
|
+
interface ChildToolDescriptor {
|
|
7
|
+
name: string;
|
|
8
|
+
title?: string;
|
|
9
|
+
description?: string;
|
|
10
|
+
inputSchema: unknown;
|
|
11
|
+
outputSchema?: unknown;
|
|
12
|
+
annotations?: {
|
|
13
|
+
title?: string;
|
|
14
|
+
readOnlyHint?: boolean;
|
|
15
|
+
destructiveHint?: boolean;
|
|
16
|
+
idempotentHint?: boolean;
|
|
17
|
+
openWorldHint?: boolean;
|
|
18
|
+
};
|
|
19
|
+
execution?: {
|
|
20
|
+
taskSupport?: "optional" | "required" | "forbidden";
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
interface ProxiedTool {
|
|
24
|
+
name: string;
|
|
25
|
+
title?: string;
|
|
26
|
+
description?: string;
|
|
27
|
+
inputSchema: Record<string, JsonValue>;
|
|
28
|
+
outputSchema?: Record<string, JsonValue>;
|
|
29
|
+
annotations?: ChildToolDescriptor["annotations"];
|
|
30
|
+
execution?: ChildToolDescriptor["execution"];
|
|
31
|
+
}
|
|
32
|
+
type XeroTenantVerification = "verified" | "ambiguous" | "mismatch";
|
|
33
|
+
type JsonPrimitive = null | boolean | number | string;
|
|
34
|
+
type JsonValue = JsonPrimitive | JsonValue[] | {
|
|
35
|
+
[key: string]: JsonValue;
|
|
36
|
+
};
|
|
37
|
+
//#endregion
|
|
38
|
+
//#region src/server.d.ts
|
|
39
|
+
declare const SERVER_VERSION: string;
|
|
40
|
+
declare const CHILD_VERSION: string;
|
|
41
|
+
declare const CHILD_BIN_PATH: string;
|
|
42
|
+
declare const CHILD_PACKAGE_ROOT: string;
|
|
43
|
+
interface XeroApiClient {
|
|
44
|
+
getXeroAccounts(): Promise<unknown>;
|
|
45
|
+
refreshXeroAccountToken(accountIdentifier: string): Promise<unknown>;
|
|
46
|
+
}
|
|
47
|
+
interface XeroChildClient {
|
|
48
|
+
listTools(): Promise<{
|
|
49
|
+
tools: ChildToolDescriptor[];
|
|
50
|
+
}>;
|
|
51
|
+
callTool(request: {
|
|
52
|
+
name: string;
|
|
53
|
+
arguments?: Record<string, unknown>;
|
|
54
|
+
}): Promise<unknown>;
|
|
55
|
+
close(): Promise<void>;
|
|
56
|
+
}
|
|
57
|
+
interface XeroProxyOptions {
|
|
58
|
+
spawnChild?: (accessToken: string, signal: AbortSignal) => Promise<XeroChildClient>;
|
|
59
|
+
verifyTenantAccess?: (accessToken: string, xeroTenantId: string, signal: AbortSignal) => Promise<XeroTenantVerification>;
|
|
60
|
+
scheduleRefresh?: boolean;
|
|
61
|
+
}
|
|
62
|
+
interface ToolCallRequest {
|
|
63
|
+
params: {
|
|
64
|
+
name: string;
|
|
65
|
+
arguments?: Record<string, unknown>;
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
declare class XeroRuntime {
|
|
69
|
+
private readonly apiClient;
|
|
70
|
+
private readonly tenants;
|
|
71
|
+
private readonly claimedTenantIds;
|
|
72
|
+
private readonly allAccountsSnapshot;
|
|
73
|
+
private readonly catalogToolNames;
|
|
74
|
+
private readonly inFlightRefreshByTenant;
|
|
75
|
+
private cachedTools;
|
|
76
|
+
private refreshTimer;
|
|
77
|
+
private closePromise;
|
|
78
|
+
private closed;
|
|
79
|
+
private readonly spawnChild;
|
|
80
|
+
private readonly verifyTenant;
|
|
81
|
+
private readonly shouldScheduleRefresh;
|
|
82
|
+
constructor(apiClient: XeroApiClient, options?: XeroProxyOptions);
|
|
83
|
+
initialize(): Promise<void>;
|
|
84
|
+
listTools(): ProxiedTool[];
|
|
85
|
+
handleToolCall(request: ToolCallRequest): Promise<CallToolResult>;
|
|
86
|
+
close(): Promise<void>;
|
|
87
|
+
private loadAccounts;
|
|
88
|
+
private discoverChildCatalog;
|
|
89
|
+
private resolveTenant;
|
|
90
|
+
private callChild;
|
|
91
|
+
private refreshTenant;
|
|
92
|
+
private refreshTenantInner;
|
|
93
|
+
private scheduleRefresh;
|
|
94
|
+
private runScheduledRefresh;
|
|
95
|
+
}
|
|
96
|
+
declare function createProxyServer(apiClient: XeroApiClient, options?: XeroProxyOptions): Promise<{
|
|
97
|
+
server: Server;
|
|
98
|
+
runtime: XeroRuntime;
|
|
99
|
+
}>;
|
|
100
|
+
interface RunningXeroProxy {
|
|
101
|
+
server: Server;
|
|
102
|
+
runtime: XeroRuntime;
|
|
103
|
+
close(): Promise<void>;
|
|
104
|
+
}
|
|
105
|
+
declare function startServer(apiClient?: XeroApiClient, options?: XeroProxyOptions): Promise<RunningXeroProxy>;
|
|
106
|
+
declare function isProcessEntrypoint(argvPath: string | undefined, metaUrl: string): boolean;
|
|
107
|
+
//#endregion
|
|
108
|
+
export { CHILD_BIN_PATH, CHILD_PACKAGE_ROOT, CHILD_VERSION, RunningXeroProxy, SERVER_VERSION, XeroApiClient, XeroChildClient, XeroProxyOptions, XeroRuntime, createProxyServer, isProcessEntrypoint, startServer };
|
package/dist/server.d.ts
CHANGED
|
@@ -1 +1,108 @@
|
|
|
1
|
-
|
|
1
|
+
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
2
|
+
import { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
|
|
3
|
+
|
|
4
|
+
//#region src/boundary.d.ts
|
|
5
|
+
|
|
6
|
+
interface ChildToolDescriptor {
|
|
7
|
+
name: string;
|
|
8
|
+
title?: string;
|
|
9
|
+
description?: string;
|
|
10
|
+
inputSchema: unknown;
|
|
11
|
+
outputSchema?: unknown;
|
|
12
|
+
annotations?: {
|
|
13
|
+
title?: string;
|
|
14
|
+
readOnlyHint?: boolean;
|
|
15
|
+
destructiveHint?: boolean;
|
|
16
|
+
idempotentHint?: boolean;
|
|
17
|
+
openWorldHint?: boolean;
|
|
18
|
+
};
|
|
19
|
+
execution?: {
|
|
20
|
+
taskSupport?: "optional" | "required" | "forbidden";
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
interface ProxiedTool {
|
|
24
|
+
name: string;
|
|
25
|
+
title?: string;
|
|
26
|
+
description?: string;
|
|
27
|
+
inputSchema: Record<string, JsonValue>;
|
|
28
|
+
outputSchema?: Record<string, JsonValue>;
|
|
29
|
+
annotations?: ChildToolDescriptor["annotations"];
|
|
30
|
+
execution?: ChildToolDescriptor["execution"];
|
|
31
|
+
}
|
|
32
|
+
type XeroTenantVerification = "verified" | "ambiguous" | "mismatch";
|
|
33
|
+
type JsonPrimitive = null | boolean | number | string;
|
|
34
|
+
type JsonValue = JsonPrimitive | JsonValue[] | {
|
|
35
|
+
[key: string]: JsonValue;
|
|
36
|
+
};
|
|
37
|
+
//#endregion
|
|
38
|
+
//#region src/server.d.ts
|
|
39
|
+
declare const SERVER_VERSION: string;
|
|
40
|
+
declare const CHILD_VERSION: string;
|
|
41
|
+
declare const CHILD_BIN_PATH: string;
|
|
42
|
+
declare const CHILD_PACKAGE_ROOT: string;
|
|
43
|
+
interface XeroApiClient {
|
|
44
|
+
getXeroAccounts(): Promise<unknown>;
|
|
45
|
+
refreshXeroAccountToken(accountIdentifier: string): Promise<unknown>;
|
|
46
|
+
}
|
|
47
|
+
interface XeroChildClient {
|
|
48
|
+
listTools(): Promise<{
|
|
49
|
+
tools: ChildToolDescriptor[];
|
|
50
|
+
}>;
|
|
51
|
+
callTool(request: {
|
|
52
|
+
name: string;
|
|
53
|
+
arguments?: Record<string, unknown>;
|
|
54
|
+
}): Promise<unknown>;
|
|
55
|
+
close(): Promise<void>;
|
|
56
|
+
}
|
|
57
|
+
interface XeroProxyOptions {
|
|
58
|
+
spawnChild?: (accessToken: string, signal: AbortSignal) => Promise<XeroChildClient>;
|
|
59
|
+
verifyTenantAccess?: (accessToken: string, xeroTenantId: string, signal: AbortSignal) => Promise<XeroTenantVerification>;
|
|
60
|
+
scheduleRefresh?: boolean;
|
|
61
|
+
}
|
|
62
|
+
interface ToolCallRequest {
|
|
63
|
+
params: {
|
|
64
|
+
name: string;
|
|
65
|
+
arguments?: Record<string, unknown>;
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
declare class XeroRuntime {
|
|
69
|
+
private readonly apiClient;
|
|
70
|
+
private readonly tenants;
|
|
71
|
+
private readonly claimedTenantIds;
|
|
72
|
+
private readonly allAccountsSnapshot;
|
|
73
|
+
private readonly catalogToolNames;
|
|
74
|
+
private readonly inFlightRefreshByTenant;
|
|
75
|
+
private cachedTools;
|
|
76
|
+
private refreshTimer;
|
|
77
|
+
private closePromise;
|
|
78
|
+
private closed;
|
|
79
|
+
private readonly spawnChild;
|
|
80
|
+
private readonly verifyTenant;
|
|
81
|
+
private readonly shouldScheduleRefresh;
|
|
82
|
+
constructor(apiClient: XeroApiClient, options?: XeroProxyOptions);
|
|
83
|
+
initialize(): Promise<void>;
|
|
84
|
+
listTools(): ProxiedTool[];
|
|
85
|
+
handleToolCall(request: ToolCallRequest): Promise<CallToolResult>;
|
|
86
|
+
close(): Promise<void>;
|
|
87
|
+
private loadAccounts;
|
|
88
|
+
private discoverChildCatalog;
|
|
89
|
+
private resolveTenant;
|
|
90
|
+
private callChild;
|
|
91
|
+
private refreshTenant;
|
|
92
|
+
private refreshTenantInner;
|
|
93
|
+
private scheduleRefresh;
|
|
94
|
+
private runScheduledRefresh;
|
|
95
|
+
}
|
|
96
|
+
declare function createProxyServer(apiClient: XeroApiClient, options?: XeroProxyOptions): Promise<{
|
|
97
|
+
server: Server;
|
|
98
|
+
runtime: XeroRuntime;
|
|
99
|
+
}>;
|
|
100
|
+
interface RunningXeroProxy {
|
|
101
|
+
server: Server;
|
|
102
|
+
runtime: XeroRuntime;
|
|
103
|
+
close(): Promise<void>;
|
|
104
|
+
}
|
|
105
|
+
declare function startServer(apiClient?: XeroApiClient, options?: XeroProxyOptions): Promise<RunningXeroProxy>;
|
|
106
|
+
declare function isProcessEntrypoint(argvPath: string | undefined, metaUrl: string): boolean;
|
|
107
|
+
//#endregion
|
|
108
|
+
export { CHILD_BIN_PATH, CHILD_PACKAGE_ROOT, CHILD_VERSION, RunningXeroProxy, SERVER_VERSION, XeroApiClient, XeroChildClient, XeroProxyOptions, XeroRuntime, createProxyServer, isProcessEntrypoint, startServer };
|