import { StdioServerHandle } from '@modelcontextprotocol/server/stdio'; import { McpServer } from '@modelcontextprotocol/server'; /** * stderr-only logger. stdout is the JSON-RPC frame channel for a stdio MCP * server — a single stray line on stdout corrupts the protocol stream. */ type LogLevel = "silent" | "error" | "info" | "debug"; /** Runtime options resolved from CLI flags (see src/cli.ts). */ interface McpServerOptions { /** Repository root to analyze. Defaults to process.cwd() at the CLI layer. */ projectRoot: string; /** Explicit tsconfig.json path; otherwise discovered by the engine. */ tsconfig?: string; /** * Explicit `playwright.config.*` path. Skips discovery entirely, including * the sibling-config probe: the named file is the config, or there is none. */ playwrightConfig?: string; /** Restrict scanning to these directories (repeatable --src-dir flag). */ srcDirs?: string[]; /** Test-id attribute override (--attribute flag beats playwright.config). */ attribute?: string; /** Cap on files parsed. */ maxFiles?: number; /** * Count a test id written on a component tag as rendered, for repositories * whose components forward props as a rule (`--assume-forwarded`). * * This is the server default. `map_coverage` and `get_testid_tree` may override * it per call so a client can compare both interpretations without restarting. */ assumeForwarded?: boolean; } /** * Checks the paths a server was started with, before any analysis runs. * * Every one of these mistakes is silent at runtime: a mistyped `--project-root` * analyses an empty directory, a mistyped `--src-dir` narrows the scope to * nothing, and a mistyped `--playwright-config` used to fall back to discovery * and answer with a different file's attribute. A long-lived stdio server then * serves that wrong answer to every call for the rest of the session, so the * cheapest possible fix is to refuse to start. * * Deliberately free of any `src/analysis` import: this runs on the CLI's startup * path, where pulling in ts-morph to stat four paths would be the slowest thing * the process does. */ declare function validateServerOptions(options: McpServerOptions): string[]; /** * Builds the MCP server. The ts-morph workspace is created lazily on the * first tool call so the stdio handshake stays fast. */ declare function createMcpServer(options: McpServerOptions): McpServer; interface RunMcpServerOptions extends McpServerOptions { logLevel?: LogLevel; } /** * Starts the MCP server over stdio. Used by the `playwright-page-object mcp` * CLI subcommand; exported so the server can also be mounted programmatically. */ declare function runMcpServer(options: RunMcpServerOptions): StdioServerHandle; export { createMcpServer, runMcpServer, validateServerOptions }; export type { McpServerOptions, RunMcpServerOptions };