@dudousxd/nestjs-telescope
Version:
Laravel Telescope-style observability console for NestJS — core: watchers, recorder, correlation, SQLite store, headless API.
54 lines • 2.3 kB
TypeScript
import { PulseService } from '../pulse/pulse.service.js';
import type { StorageProvider } from '../storage/storage-provider.js';
import type { TelescopeModuleOptions } from './telescope.options.js';
import { TelescopeService } from './telescope.service.js';
interface JsonRpcRequest {
jsonrpc?: string;
id?: string | number | null;
method?: string;
params?: {
protocolVersion?: string;
name?: string;
arguments?: Record<string, unknown>;
};
}
/**
* MCP (Model Context Protocol) server — stateless JSON-RPC over streamable HTTP —
* so coding agents (Claude Code, Cursor, …) can debug straight from the captured
* data: "why is POST /checkout slow?" → the agent pulls the batch waterfall with
* every query. Hand-rolled JSON-RPC (no SDK dependency), backed by the same
* storage / pulse / diagnosis APIs as the dashboard.
*
* Auth is a Bearer token (`mcp: { token }`); without one the endpoint is allowed
* only when `NODE_ENV !== 'production'`. Carries NO `@UseGuards(TelescopeGuard)`:
* the cookie-session dashboard gate doesn't apply to a header-only agent client,
* so this controller enforces its own Bearer check. NestJS has no CSRF guard by
* default, so there is nothing CSRF-like to bypass.
*/
export declare class TelescopeMcpController {
private readonly storage;
private readonly service;
private readonly pulse;
private readonly options;
constructor(storage: StorageProvider, service: TelescopeService, pulse: PulseService, options: TelescopeModuleOptions);
getStream(): never;
deleteSession(): {
ok: true;
};
rpc(request: unknown, body: JsonRpcRequest): Promise<unknown>;
/**
* Bearer-token gate. With a configured token, the request MUST carry a matching
* `Authorization: Bearer <token>` header. Without a token, allow only when
* `NODE_ENV !== 'production'` (mirroring the default-open-in-dev dashboard
* authorizer); a tokenless config in production is refused.
*/
private isAuthorized;
/** The configured Bearer token, or `null` when `mcp` is `true`/disabled. */
private configuredToken;
private handle;
private respond;
private fail;
private callTool;
}
export {};
//# sourceMappingURL=telescope-mcp.controller.d.ts.map