modality-ai 0.5.0 → 0.5.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.
@@ -3,3 +3,4 @@ export { ModalityClient } from "./ModalityClient";
3
3
  export { setupStdioToHttpTools, createStdioClient, } from "./setupStdioToHttpTools";
4
4
  export type { ModalityClientInstance } from "./ModalityClient";
5
5
  export type { StdioClientOptions } from "./setupStdioToHttpTools";
6
+ export { CLIBrowserOAuthProvider, urlStorageKey, } from "./mcp-oauth-provider";
@@ -0,0 +1,102 @@
1
+ import type { OAuthClientProvider, OAuthDiscoveryState } from "@modelcontextprotocol/sdk/client/auth.js";
2
+ import type { OAuthClientInformationMixed, OAuthClientMetadata, OAuthTokens } from "@modelcontextprotocol/sdk/shared/auth.js";
3
+ interface CLIBrowserOAuthProviderOptions {
4
+ /** Display name registered with the OAuth server. Default: "mcp-cli" */
5
+ clientName?: string;
6
+ /**
7
+ * Pre-registered OAuth client ID.
8
+ * When provided, skips dynamic client registration (RFC 7591) entirely.
9
+ */
10
+ clientId?: string;
11
+ /**
12
+ * Port for the local callback server.
13
+ * 0 (default) picks a random available port.
14
+ * Use a fixed port when registering an OAuth app manually so the redirect
15
+ * URI stays stable across runs (e.g. callbackPort: 9876).
16
+ */
17
+ callbackPort?: number;
18
+ /**
19
+ * Skip opening the system browser automatically.
20
+ * When true the authorization URL is printed but not launched.
21
+ * Useful for headless / CI environments.
22
+ */
23
+ noOpen?: boolean;
24
+ /**
25
+ * Key used to namespace the persisted OAuth cache for this server.
26
+ * Defaults to a short hash of the server URL so each MCP server gets its
27
+ * own cache entry and re-runs skip dynamic registration entirely.
28
+ *
29
+ * Pass an explicit string (e.g. "figma") for a human-readable cache name.
30
+ * Pass null to disable persistence entirely.
31
+ */
32
+ storageKey?: string | null;
33
+ }
34
+ /**
35
+ * OAuthClientProvider for CLI tools.
36
+ *
37
+ * Implements the MCP SDK OAuthClientProvider interface for browser-based
38
+ * Authorization Code + PKCE flows. Designed to be passed directly to
39
+ * StreamableHTTPClientTransport as `authProvider`.
40
+ *
41
+ * Persists clientInfo + tokens to disk so re-runs skip dynamic registration
42
+ * and the browser prompt (until the token expires).
43
+ *
44
+ * Usage:
45
+ * const provider = new CLIBrowserOAuthProvider({ clientName: "my-cli", storageKey: "figma" });
46
+ * const transport = new StreamableHTTPClientTransport(url, { authProvider: provider });
47
+ * const client = new Client(...);
48
+ *
49
+ * try {
50
+ * await client.connect(transport);
51
+ * } catch (err) {
52
+ * if (err instanceof UnauthorizedError) {
53
+ * const code = await provider.waitForCode();
54
+ * await transport.finishAuth(code);
55
+ * await client.connect(transport); // retry with token now in provider
56
+ * }
57
+ * }
58
+ *
59
+ * provider.stop();
60
+ */
61
+ export declare class CLIBrowserOAuthProvider implements OAuthClientProvider {
62
+ private readonly _clientName;
63
+ private readonly _noOpen;
64
+ private readonly _cachePath;
65
+ private _port;
66
+ private _server;
67
+ private _resolveCode?;
68
+ private _rejectCode?;
69
+ private _pendingCode;
70
+ private _codeVerifier?;
71
+ private _clientInfo?;
72
+ private _tokens?;
73
+ private _discoveryState?;
74
+ constructor(options?: CLIBrowserOAuthProviderOptions);
75
+ get redirectUrl(): string;
76
+ get clientMetadata(): OAuthClientMetadata;
77
+ clientInformation(): OAuthClientInformationMixed | undefined;
78
+ saveClientInformation(info: OAuthClientInformationMixed): void;
79
+ tokens(): OAuthTokens | undefined;
80
+ saveTokens(tokens: OAuthTokens): void;
81
+ saveDiscoveryState(state: OAuthDiscoveryState): void;
82
+ discoveryState(): OAuthDiscoveryState | undefined;
83
+ saveCodeVerifier(verifier: string): void;
84
+ codeVerifier(): string;
85
+ redirectToAuthorization(authorizationUrl: URL): Promise<void>;
86
+ /**
87
+ * Resolves with the authorization code once the browser redirect completes.
88
+ */
89
+ waitForCode(): Promise<string>;
90
+ /** Discovery state captured before registration — available even when registration fails. */
91
+ getDiscoveryState(): OAuthDiscoveryState | undefined;
92
+ /** Remove all persisted state for this server (forces re-registration + re-auth on next run). */
93
+ clearCache(): void;
94
+ /** Stop the local callback HTTP server. Call once auth is complete. */
95
+ stop(): void;
96
+ private _loadCache;
97
+ private _persistCache;
98
+ private _handleCallback;
99
+ }
100
+ /** Short stable hash of a string — used to derive a cache file name from a URL. */
101
+ export declare function urlStorageKey(url: string): string;
102
+ export {};
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.5.0",
2
+ "version": "0.5.2",
3
3
  "name": "modality-ai",
4
4
  "repository": {
5
5
  "type": "git",
@@ -11,18 +11,18 @@
11
11
  "author": "Hill <hill@kimo.com>",
12
12
  "license": "ISC",
13
13
  "peerDependencies": {
14
- "@modelcontextprotocol/sdk": "^1.25.1",
15
- "modality-mcp-kit": "^1.0.0"
14
+ "@modelcontextprotocol/sdk": "^1.28.0",
15
+ "modality-mcp-kit": "^1.5.0"
16
16
  },
17
17
  "dependencies": {
18
- "@ai-sdk/google": "^3.0.18",
19
- "ai": "^6.0.64",
18
+ "@ai-sdk/google": "^3.0.53",
19
+ "ai": "^6.0.141",
20
20
  "ollama-ai-provider": "^1.2.0"
21
21
  },
22
22
  "devDependencies": {
23
- "@types/bun": "^1.3.8",
23
+ "@types/bun": "^1.3.11",
24
24
  "modality-bun-kit": "^0.0.2",
25
- "typescript": "^5.9.3"
25
+ "typescript": "^6.0.2"
26
26
  },
27
27
  "exports": {
28
28
  "types": "./dist/types/index.d.ts",
@@ -35,7 +35,7 @@
35
35
  "scripts": {
36
36
  "build:clean": "find ./dist -name '*.*' | xargs rm -rf",
37
37
  "build:types": "bun tsc -p ./",
38
- "build:src": "bun build src/index.ts --outdir dist --external @modelcontextprotocol/sdk",
38
+ "build:src": "bun build src/index.ts --outdir dist --target node --external @modelcontextprotocol/sdk",
39
39
  "build": "bun run build:clean && bun run build:types && bun run build:src",
40
40
  "dev": "bunx concurrently 'bun --watch tsc -p ./' 'bun build:src -- --watch --sourcemap=inline'",
41
41
  "test": "npm run build && bun test",