UNPKG

@ekwo-ai/mcp

Version:

MCP server for Ekwo OS: let an AI agent work on the books, under the user's own row level security.

68 lines • 3.39 kB
/** * Where the server gets its connection, and what it refuses. * * Two modes, and the order matters. **PostgREST with the user's own session** * is the recommended one: `SUPABASE_URL` and `SUPABASE_ANON_KEY` with either a * password or an access token, and row level security decides everything from * there. **A direct Postgres connection** is the fallback for a self-hosted * installation; it demands `EKWO_ACT_AS_USER_ID` precisely because a database * connection is nobody, and a server acting as nobody would be acting as the * owner. * * The one thing this file exists to refuse is a `service_role` key. It would * work — that is the problem. Every policy in the schema would be bypassed, * and an agent that can read every company of an installation is not the * thing anybody asked for. It is refused wherever it can arrive, and there are * two doors, not one: `SUPABASE_ANON_KEY` is the obvious paste, and * `EKWO_ACCESS_TOKEN` is the quiet one — it goes into the `Authorization` * header, which is what PostgREST reads for the role, so a service_role key * put there overrides a perfectly good anon key sitting next to it. */ import { isServiceRoleKey } from '@ekwo-ai/core'; import { type AgentSession, type Backend, type SessionPosting } from './backend.js'; import { type ToolLoading } from './tools/loading.js'; export interface Config { mode: 'postgrest' | 'sql'; supabaseUrl?: string; anonKey?: string; email?: string; password?: string; accessToken?: string; dbUrl?: string; actAsUserId?: string; /** The mark every transaction carries: this session's choice, and its name. */ agent: AgentSession; } export declare const ENV: { readonly dbUrl: "EKWO_DB_URL"; readonly actAsUserId: "EKWO_ACT_AS_USER_ID"; readonly einvoiceDirectory: "EKWO_EINVOICE_DIRECTORY"; readonly agentPosting: "EKWO_AGENT_POSTING"; readonly tools: "EKWO_MCP_TOOLS"; readonly supabaseUrl: "SUPABASE_URL"; readonly anonKey: "SUPABASE_ANON_KEY"; readonly email: "EKWO_EMAIL"; readonly password: "EKWO_PASSWORD"; readonly accessToken: "EKWO_ACCESS_TOKEN"; }; export { isServiceRoleKey }; /** * The session's choice of how it posts, from `EKWO_AGENT_POSTING` — which * `--autopilot` and `--review` set. Unset, each company's `agent_posting` * decides. A value that is neither is refused rather than read as one. */ export declare function sessionPostingFrom(env: NodeJS.ProcessEnv): SessionPosting | undefined; /** * How the session's tools are offered, from `EKWO_MCP_TOOLS`: `all` at the * handshake, or `on_demand` — a first session's tools, and `search_tools` and * `load_tools` for the rest. Unset, all. A value that is neither is refused * rather than read as one. */ export declare function toolLoadingFrom(env: NodeJS.ProcessEnv): ToolLoading | undefined; /** `--autopilot` or `--review` among the arguments of the server, at most one of them. */ export declare function sessionPostingFlag(argv: readonly string[]): SessionPosting | undefined; /** Reads the environment, and says what is missing rather than failing later. */ export declare function readConfig(env?: NodeJS.ProcessEnv): Config; /** Opens the backend the configuration describes. The caller closes it. */ export declare function openBackend(config: Config): Promise<Backend>; //# sourceMappingURL=config.d.ts.map