@fitchmultz/pi-mcp-adapter 5.0.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/CHANGELOG.md +750 -0
- package/LICENSE +21 -0
- package/OAUTH.md +462 -0
- package/README.md +820 -0
- package/abort.ts +34 -0
- package/agent-dir.ts +24 -0
- package/app-bridge.bundle.js +67 -0
- package/banner.png +0 -0
- package/checkpoint.ts +55 -0
- package/cli.js +222 -0
- package/commands.ts +619 -0
- package/config.ts +1204 -0
- package/consent-manager.ts +25 -0
- package/direct-tools.ts +408 -0
- package/dist/abort.d.ts +2 -0
- package/dist/abort.js +35 -0
- package/dist/agent-dir.d.ts +3 -0
- package/dist/agent-dir.js +21 -0
- package/dist/app-bridge.bundle.js +67 -0
- package/dist/checkpoint.d.ts +18 -0
- package/dist/checkpoint.js +53 -0
- package/dist/commands.d.ts +20 -0
- package/dist/commands.js +521 -0
- package/dist/config.d.ts +109 -0
- package/dist/config.js +1013 -0
- package/dist/consent-manager.d.ts +8 -0
- package/dist/consent-manager.js +21 -0
- package/dist/direct-tools.d.ts +10 -0
- package/dist/direct-tools.js +350 -0
- package/dist/docs/client-metadata.json +14 -0
- package/dist/elicitation-handler.d.ts +17 -0
- package/dist/elicitation-handler.js +308 -0
- package/dist/error-signal.d.ts +15 -0
- package/dist/error-signal.js +21 -0
- package/dist/glimpse-ui.d.ts +9 -0
- package/dist/glimpse-ui.js +75 -0
- package/dist/host-html-template.d.ts +15 -0
- package/dist/host-html-template.js +429 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +840 -0
- package/dist/init.d.ts +25 -0
- package/dist/init.js +562 -0
- package/dist/legacy-migration.d.ts +18 -0
- package/dist/legacy-migration.js +45 -0
- package/dist/lifecycle.d.ts +40 -0
- package/dist/lifecycle.js +167 -0
- package/dist/logger.d.ts +38 -0
- package/dist/logger.js +102 -0
- package/dist/mcp-auth-flow.d.ts +113 -0
- package/dist/mcp-auth-flow.js +834 -0
- package/dist/mcp-auth.d.ts +127 -0
- package/dist/mcp-auth.js +658 -0
- package/dist/mcp-callback-server.d.ts +56 -0
- package/dist/mcp-callback-server.js +371 -0
- package/dist/mcp-code.d.ts +51 -0
- package/dist/mcp-code.js +366 -0
- package/dist/mcp-keyring-helper.cjs +89 -0
- package/dist/mcp-oauth-provider.d.ts +154 -0
- package/dist/mcp-oauth-provider.js +672 -0
- package/dist/mcp-output-guard.d.ts +59 -0
- package/dist/mcp-output-guard.js +332 -0
- package/dist/mcp-panel.d.ts +66 -0
- package/dist/mcp-panel.js +889 -0
- package/dist/mcp-script-worker.mjs +128 -0
- package/dist/mcp-setup-panel.d.ts +84 -0
- package/dist/mcp-setup-panel.js +561 -0
- package/dist/mcp-status.d.ts +11 -0
- package/dist/mcp-status.js +96 -0
- package/dist/mcp-trace.d.ts +95 -0
- package/dist/mcp-trace.js +233 -0
- package/dist/metadata-cache.d.ts +18 -0
- package/dist/metadata-cache.js +277 -0
- package/dist/npx-resolver.d.ts +6 -0
- package/dist/npx-resolver.js +448 -0
- package/dist/onboarding-state.d.ts +11 -0
- package/dist/onboarding-state.js +47 -0
- package/dist/panel-keys.d.ts +16 -0
- package/dist/panel-keys.js +15 -0
- package/dist/prompts.d.ts +56 -0
- package/dist/prompts.js +284 -0
- package/dist/proxy-modes.d.ts +38 -0
- package/dist/proxy-modes.js +1235 -0
- package/dist/resource-tools.d.ts +1 -0
- package/dist/resource-tools.js +14 -0
- package/dist/runtime-owner.d.ts +18 -0
- package/dist/runtime-owner.js +117 -0
- package/dist/sampling-handler.d.ts +15 -0
- package/dist/sampling-handler.js +211 -0
- package/dist/search-ranking.d.ts +20 -0
- package/dist/search-ranking.js +180 -0
- package/dist/server-manager.d.ts +114 -0
- package/dist/server-manager.js +1175 -0
- package/dist/session-recovery.d.ts +31 -0
- package/dist/session-recovery.js +310 -0
- package/dist/state.d.ts +63 -0
- package/dist/state.js +1 -0
- package/dist/tool-approval.d.ts +10 -0
- package/dist/tool-approval.js +42 -0
- package/dist/tool-metadata.d.ts +9 -0
- package/dist/tool-metadata.js +193 -0
- package/dist/tool-registrar.d.ts +10 -0
- package/dist/tool-registrar.js +64 -0
- package/dist/tool-result-renderer.d.ts +45 -0
- package/dist/tool-result-renderer.js +224 -0
- package/dist/ts-shape.d.ts +2 -0
- package/dist/ts-shape.js +147 -0
- package/dist/types.d.ts +516 -0
- package/dist/types.js +168 -0
- package/dist/ui-resource-handler.d.ts +17 -0
- package/dist/ui-resource-handler.js +209 -0
- package/dist/ui-server.d.ts +51 -0
- package/dist/ui-server.js +669 -0
- package/dist/ui-session.d.ts +39 -0
- package/dist/ui-session.js +463 -0
- package/dist/ui-stream-types.d.ts +104 -0
- package/dist/ui-stream-types.js +58 -0
- package/dist/ui-tool-visibility.d.ts +4 -0
- package/dist/ui-tool-visibility.js +26 -0
- package/dist/unix-socket-transport.d.ts +15 -0
- package/dist/unix-socket-transport.js +84 -0
- package/dist/utils.d.ts +30 -0
- package/dist/utils.js +276 -0
- package/docs/client-metadata.json +14 -0
- package/elicitation-handler.ts +349 -0
- package/error-signal.ts +21 -0
- package/glimpse-ui.ts +80 -0
- package/host-html-template.ts +456 -0
- package/index.ts +900 -0
- package/init.ts +627 -0
- package/legacy-migration.ts +47 -0
- package/lifecycle.ts +165 -0
- package/logger.ts +127 -0
- package/mcp-auth-flow.ts +975 -0
- package/mcp-auth.ts +793 -0
- package/mcp-callback-server.ts +450 -0
- package/mcp-code.ts +386 -0
- package/mcp-keyring-helper.cjs +89 -0
- package/mcp-oauth-provider.ts +774 -0
- package/mcp-output-guard.ts +412 -0
- package/mcp-panel.ts +978 -0
- package/mcp-script-worker.mjs +128 -0
- package/mcp-setup-panel.ts +666 -0
- package/mcp-status.ts +109 -0
- package/mcp-trace.ts +295 -0
- package/metadata-cache.ts +333 -0
- package/npx-resolver.ts +488 -0
- package/onboarding-state.ts +58 -0
- package/package.json +182 -0
- package/panel-keys.ts +37 -0
- package/prompts.ts +337 -0
- package/proxy-modes.ts +1361 -0
- package/resource-tools.ts +17 -0
- package/runtime-owner.ts +123 -0
- package/sampling-handler.ts +273 -0
- package/scripts/build.mjs +131 -0
- package/scripts/prepare.mjs +102 -0
- package/search-ranking.ts +196 -0
- package/server-manager.ts +1320 -0
- package/session-recovery.ts +316 -0
- package/skills/mcp-scripting/SKILL.md +38 -0
- package/state.ts +64 -0
- package/tool-approval.ts +78 -0
- package/tool-metadata.ts +235 -0
- package/tool-registrar.ts +69 -0
- package/tool-result-renderer.ts +286 -0
- package/ts-shape.ts +145 -0
- package/tsconfig.build.json +13 -0
- package/tsconfig.json +16 -0
- package/types.ts +810 -0
- package/ui-resource-handler.ts +249 -0
- package/ui-server.ts +808 -0
- package/ui-session.ts +568 -0
- package/ui-stream-types.ts +89 -0
- package/ui-tool-visibility.ts +25 -0
- package/unix-socket-transport.ts +85 -0
- package/utils.ts +309 -0
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Auth Storage Module
|
|
3
|
+
*
|
|
4
|
+
* Handles secure storage of OAuth credentials, tokens, client information,
|
|
5
|
+
* and legacy PKCE state for MCP servers.
|
|
6
|
+
*
|
|
7
|
+
* Persistent OAuth entries are stored in the operating system credential store.
|
|
8
|
+
* Legacy plaintext entries are imported from $FITCH_MCP_OAUTH_DIR/sha256-<server-hash>/tokens.json
|
|
9
|
+
* when set, otherwise <Pi agent dir>/fitch-mcp-adapter/mcp-oauth/sha256-<server-hash>/tokens.json,
|
|
10
|
+
* then the plaintext file is removed.
|
|
11
|
+
*/
|
|
12
|
+
/** OAuth token storage format */
|
|
13
|
+
export interface StoredTokens {
|
|
14
|
+
accessToken: string;
|
|
15
|
+
refreshToken?: string;
|
|
16
|
+
expiresAt?: number;
|
|
17
|
+
scope?: string;
|
|
18
|
+
/** SEP-2352 authorization-server issuer binding */
|
|
19
|
+
issuer?: string;
|
|
20
|
+
}
|
|
21
|
+
/** OAuth client information from dynamic or static registration */
|
|
22
|
+
export interface StoredClientInfo {
|
|
23
|
+
clientId: string;
|
|
24
|
+
clientSecret?: string;
|
|
25
|
+
clientIdIssuedAt?: number;
|
|
26
|
+
clientSecretExpiresAt?: number;
|
|
27
|
+
redirectUris?: string[];
|
|
28
|
+
/** Positively identified native CIMD registration; permits loopback port changes. */
|
|
29
|
+
registrationType?: "cimd";
|
|
30
|
+
/** SEP-2352 authorization-server issuer binding */
|
|
31
|
+
issuer?: string;
|
|
32
|
+
/**
|
|
33
|
+
* True when this entry is a secretless SEP-2352 issuer stub persisted for a
|
|
34
|
+
* config-pre-registered client (written by the config-clientId path of
|
|
35
|
+
* saveClientInformation). Such a stub is only usable when paired with the
|
|
36
|
+
* config that supplies the client secret; it must never be served as
|
|
37
|
+
* standalone client information.
|
|
38
|
+
*/
|
|
39
|
+
configPreRegistered?: boolean;
|
|
40
|
+
}
|
|
41
|
+
/** Complete auth entry for a server */
|
|
42
|
+
export interface AuthEntry {
|
|
43
|
+
tokens?: StoredTokens;
|
|
44
|
+
clientInfo?: StoredClientInfo;
|
|
45
|
+
codeVerifier?: string;
|
|
46
|
+
oauthState?: string;
|
|
47
|
+
serverUrl?: string;
|
|
48
|
+
}
|
|
49
|
+
export interface AuthStorageOptions {
|
|
50
|
+
/** Legacy plaintext import directory. Persistent secrets no longer use this as their store. */
|
|
51
|
+
baseDir?: string;
|
|
52
|
+
}
|
|
53
|
+
export declare class OAuthCredentialStoreError extends Error {
|
|
54
|
+
readonly operation: 'read' | 'write' | 'remove';
|
|
55
|
+
readonly code = "OAUTH_CREDENTIAL_STORE_UNAVAILABLE";
|
|
56
|
+
constructor(message: string, operation: 'read' | 'write' | 'remove', cause: unknown);
|
|
57
|
+
}
|
|
58
|
+
export type OAuthCredentialStatus = {
|
|
59
|
+
status: 'present';
|
|
60
|
+
entry: AuthEntry;
|
|
61
|
+
} | {
|
|
62
|
+
status: 'absent';
|
|
63
|
+
} | {
|
|
64
|
+
status: 'unavailable';
|
|
65
|
+
message: string;
|
|
66
|
+
};
|
|
67
|
+
export declare function formatOAuthCredentialStoreUnavailable(error: OAuthCredentialStoreError): string;
|
|
68
|
+
export declare function getAuthStorageOptions(oauthDir: unknown, cwd?: string): AuthStorageOptions;
|
|
69
|
+
export declare function getAuthBaseDir(options?: AuthStorageOptions): string;
|
|
70
|
+
/**
|
|
71
|
+
* Get the legacy plaintext tokens file path for a server.
|
|
72
|
+
*/
|
|
73
|
+
export declare function getAuthEntryFilePath(serverName: string, options?: AuthStorageOptions): string;
|
|
74
|
+
/** Explicit copy-only upgrade. Normal reads and logout never access the old service. */
|
|
75
|
+
export declare function migrateLegacyAuthEntry(serverName: string, legacyDirectory?: string): 'copied' | 'existing' | 'absent';
|
|
76
|
+
/**
|
|
77
|
+
* Get auth entry for a server.
|
|
78
|
+
*/
|
|
79
|
+
export declare function getAuthEntry(serverName: string, options?: AuthStorageOptions): AuthEntry | undefined;
|
|
80
|
+
/**
|
|
81
|
+
* Get auth entry and validate it's for the correct URL.
|
|
82
|
+
* Returns undefined if URL has changed (credentials are invalid).
|
|
83
|
+
*/
|
|
84
|
+
export declare function getAuthForUrl(serverName: string, serverUrl: string, options?: AuthStorageOptions): AuthEntry | undefined;
|
|
85
|
+
/**
|
|
86
|
+
* Inspect credentials for status-only UI paths without treating an unavailable
|
|
87
|
+
* secure store as missing credentials. Authentication operations continue to
|
|
88
|
+
* use getAuthForUrl() directly and therefore remain fail-closed.
|
|
89
|
+
*/
|
|
90
|
+
export declare function inspectAuthForUrl(serverName: string, serverUrl: string, options?: AuthStorageOptions): OAuthCredentialStatus;
|
|
91
|
+
/**
|
|
92
|
+
* Save auth entry for a server.
|
|
93
|
+
*/
|
|
94
|
+
export declare function saveAuthEntry(serverName: string, entry: AuthEntry, serverUrl?: string, options?: AuthStorageOptions): void;
|
|
95
|
+
export declare function removeAuthEntry(serverName: string, options?: AuthStorageOptions): void;
|
|
96
|
+
/**
|
|
97
|
+
* Update tokens for a server.
|
|
98
|
+
*/
|
|
99
|
+
export declare function updateTokens(serverName: string, tokens: StoredTokens, serverUrl?: string, options?: AuthStorageOptions): void;
|
|
100
|
+
/**
|
|
101
|
+
* Update client info for a server.
|
|
102
|
+
*/
|
|
103
|
+
export declare function updateClientInfo(serverName: string, clientInfo: StoredClientInfo, serverUrl?: string, options?: AuthStorageOptions): void;
|
|
104
|
+
/**
|
|
105
|
+
* Clear code verifier for a server.
|
|
106
|
+
*/
|
|
107
|
+
export declare function clearCodeVerifier(serverName: string, options?: AuthStorageOptions): void;
|
|
108
|
+
/**
|
|
109
|
+
* Get OAuth state for a server.
|
|
110
|
+
*/
|
|
111
|
+
export declare function getOAuthState(serverName: string, options?: AuthStorageOptions): string | undefined;
|
|
112
|
+
/**
|
|
113
|
+
* Clear OAuth state for a server.
|
|
114
|
+
*/
|
|
115
|
+
export declare function clearOAuthState(serverName: string, options?: AuthStorageOptions): void;
|
|
116
|
+
/**
|
|
117
|
+
* Clear all credentials for a server.
|
|
118
|
+
*/
|
|
119
|
+
export declare function clearAllCredentials(serverName: string, options?: AuthStorageOptions): void;
|
|
120
|
+
/**
|
|
121
|
+
* Clear only client info for a server.
|
|
122
|
+
*/
|
|
123
|
+
export declare function clearClientInfo(serverName: string, options?: AuthStorageOptions): void;
|
|
124
|
+
/**
|
|
125
|
+
* Clear only tokens for a server.
|
|
126
|
+
*/
|
|
127
|
+
export declare function clearTokens(serverName: string, options?: AuthStorageOptions): void;
|