opencode-mcp
Version:
MCP server for OpenCode coding workflows, durable async jobs, project resources, and explicit user input
68 lines (67 loc) • 2.82 kB
TypeScript
import { OpencodeClient as NativeClient } from "@opencode-ai/sdk";
import { type RequestOptions } from "./async.js";
export type { RequestOptions } from "./async.js";
export interface OpenCodeClientOptions {
baseUrl: string;
username?: string;
password?: string;
/** Static bearer token (`OPENCODE_SERVER_TOKEN`). */
token?: string;
/** OpenChamber UI password (`OPENCODE_OPENCHAMBER_PASSWORD`). */
openchamberPassword?: string;
/** OpenChamber origin (`OPENCODE_OPENCHAMBER_URL`). */
openchamberUrl?: string;
/** Overrides the per-process OpenChamber dedupe scope (`OPENCODE_OPENCHAMBER_CLIENT_ID`). */
clientId?: string;
autoServe?: boolean;
}
export declare class OpenCodeError extends Error {
readonly status: number;
readonly method: string;
readonly path: string;
readonly body: string;
constructor(message: string, status: number, method: string, path: string, body: string);
get isTransient(): boolean;
get isNotFound(): boolean;
get isAuth(): boolean;
}
/** The server may have accepted a write whose response was lost. */
export declare class OpenCodeSubmissionError extends Error {
readonly method: string;
readonly path: string;
readonly submissionOutcome: "unknown";
constructor(method: string, path: string, cause: unknown);
}
export declare class OpenCodeClient {
api: NativeClient;
private baseUrl;
private autoServe;
private reconnectAttempts;
private username?;
private password?;
private auth;
constructor(options: OpenCodeClientOptions);
/**
* Rebuild the SDK client against the current `baseUrl` + auth state. Used
* by the constructor and by the reconnect path when `ensureServer()`
* surfaces a different URL than the one we were aiming at.
*/
private buildSdkClient;
getBaseUrl(): string;
/** Current `Authorization` header value; signs in to OpenChamber when configured. */
getAuthorization(): Promise<string | undefined>;
private request;
get<T = unknown>(path: string, query?: Record<string, string>, directory?: string, options?: RequestOptions): Promise<T>;
post<T = unknown>(path: string, body?: unknown, opts?: RequestOptions & {
directory?: string;
}): Promise<T>;
patch<T = unknown>(path: string, body?: unknown, directory?: string, options?: RequestOptions): Promise<T>;
put<T = unknown>(path: string, body?: unknown, directory?: string, options?: RequestOptions): Promise<T>;
delete<T = unknown>(path: string, query?: Record<string, string>, directory?: string, options?: RequestOptions): Promise<T>;
subscribeSSE(path: string, opts?: RequestOptions & {
directory?: string;
}): AsyncGenerator<{
event: string;
data: string;
}, void, undefined>;
}