@struktoai/mirage-core
Version:
A Unified Virtual Filesystem For AI Agents
89 lines • 3.62 kB
TypeScript
import type { OAuthClientInformationMixed, OAuthClientMetadata, OAuthClientProvider, OAuthTokens } from '@modelcontextprotocol/client';
import { Client } from '@modelcontextprotocol/client';
import type { JsonObject } from '../../types.ts';
import { ApiError } from '../api/errors.ts';
import type { NotionConfig } from './config.ts';
export interface NotionTransport {
callTool(name: string, args: Record<string, unknown>): Promise<Record<string, unknown>>;
}
export declare class NotionMCPError extends Error {
readonly code: string | null;
readonly raw: unknown;
constructor(message: string, opts?: {
code?: string | null;
raw?: unknown;
});
}
export interface MCPNotionTransportOptions {
authProvider: OAuthClientProvider;
serverUrl?: string;
}
export declare class MCPNotionTransport implements NotionTransport {
protected client: Client | null;
private connectPromise;
private readonly authProvider;
private readonly serverUrl;
constructor(opts: MCPNotionTransportOptions);
private ensureConnected;
callTool(name: string, args: Record<string, unknown>): Promise<Record<string, unknown>>;
}
export interface MemoryOAuthClientProviderOptions {
clientMetadata: OAuthClientMetadata;
redirect: (url: URL) => void | Promise<void>;
redirectUrl?: string | URL;
}
/**
* An `OAuthClientProvider` that holds the client registration, tokens and
* PKCE verifier in memory, for an `MCPNotionTransport` whose session ends
* with the page.
*/
export declare class MemoryOAuthClientProvider implements OAuthClientProvider {
private readonly opts;
private _clientInformation;
private _tokens;
private _codeVerifier;
constructor(opts: MemoryOAuthClientProviderOptions);
get redirectUrl(): string | URL | undefined;
get clientMetadata(): OAuthClientMetadata;
clientInformation(): OAuthClientInformationMixed | undefined;
saveClientInformation(info: OAuthClientInformationMixed): void;
tokens(): OAuthTokens | undefined;
saveTokens(tokens: OAuthTokens): void;
redirectToAuthorization(authorizationUrl: URL): void | Promise<void>;
saveCodeVerifier(codeVerifier: string): void;
codeVerifier(): string;
clearTokens(): void;
}
export declare class NotionAPIError extends ApiError {
readonly code: string | null;
constructor(message: string, status?: number | null, code?: string | null);
}
/** Refuse a list response Notion marked incomplete. */
export declare function completePage(page: JsonObject): JsonObject;
export interface RestCall {
method: 'GET' | 'POST' | 'PATCH' | 'PUT' | 'DELETE';
path: string;
query?: Record<string, unknown>;
/**
* Any JSON value, not only an object: `ntn api` sends whatever `--data`
* or the pipe carried, verbatim, with no client-side object check.
*/
body?: unknown;
/**
* Per-request headers, which `ntn api` collects from its `Header:Value`
* inputs. Applied last so a caller can override a default, which is what the
* real CLI does (probed on the wire against ntn 0.21.9).
*/
headers?: Record<string, string>;
}
export declare class HttpNotionTransport implements NotionTransport {
protected readonly fetch: typeof fetch;
private readonly apiKey;
private readonly baseUrl;
private readonly apiVersion;
private readonly timeout;
constructor(opts: NotionConfig);
request(call: RestCall): Promise<Record<string, unknown>>;
callTool(name: string, args: Record<string, unknown>): Promise<Record<string, unknown>>;
}
//# sourceMappingURL=client.d.ts.map