#MCP tool connections

    stdio.connect and streamhttp.connect prefer the stateless MCP 2026-07-28 revision. They send server/discover, select the supported revision, and attach protocol version, client identity, and an empty client-capabilities object to every subsequent request's params._meta. Modern connections do not send initialize or notifications/initialized and do not acquire MCP sessions.

    The terminology follows the specification: modern means 2026-07-28 and later, legacy means revisions using the initialization handshake. Only 2026-07-28 is implemented on the modern path; unknown revisions are rejected.

    #Compatibility

    For stdio, a non-modern discovery error or a probe timeout selects the existing legacy handshake. The probe uses at most one second and at most one quarter of the connection deadline. For HTTP, a legacy discovery error or an HTTP 400/404/405 without a recognized modern error selects the legacy path. Authentication failures, network failures, malformed discovery successes, and recognized modern protocol errors do not trigger a downgrade.

    Legacy peers continue to use 2025-11-25, 2025-06-18, 2025-03-26, or 2024-11-05, including the existing HTTP session header and teardown behavior. The deprecated HTTP+SSE transport with a separate GET endpoint is not implemented.

    #HTTP metadata and cancellation

    Modern HTTP requests mirror version, method, and tool name into their required headers. A direct first tool call automatically lists tools (including all pages) if the caller has not done so, to obtain the parameter header schemas. x-mcp-header annotations are validated when listing tools; invalid definitions are excluded. Annotated primitive arguments are mirrored into Mcp-Param-* headers, including nested properties. Unicode, control characters, surrounding whitespace, and literal Base64 sentinels use the prescribed encoding. Configured headers cannot override these protocol-owned fields.

    Cancelling an outstanding modern stdio call sends notifications/cancelled. Cancellation of an already dispatched request is retained separately from the bounded outbound queue and sent when the writer can resume. A cancelled request that has not reached the transport is discarded without executing it. Cancelling an HTTP call closes only that request's exchange; other calls remain usable. Independent server-to-client JSON-RPC requests are ignored on modern transports, which never answer them with JSON-RPC responses.

    #Supported surface

    The client exposes discovery, paginated tool listing, and tool calls. It does not advertise sampling, elicitation, roots, or subscription capabilities. input_required and unknown result types surface as protocol errors instead of becoming empty successful tool output. Automatic MRTR continuation is not implemented. Missing resultType is accepted as complete, as required for backward compatibility.

    Tool results reach scripts through mcp/host as text plus image file paths. Text content is passed through; PNG, JPEG, GIF, and WebP image content (at most 20 MiB, MIME type matching the bytes) is written into the host's image directory and returned as paths for scripts to inspect with the image tool. Other image formats, audio, and resource links are replaced by short text placeholders.

    The desktop host serves modern discovery and tools alongside legacy clients on the same endpoint. It validates metadata and mirrored headers independently on each request, accepts direct tool calls without prior discovery, and returns resultType: "complete" and server identity on modern results. The existing bearer grant determines the OpenSeek conversation; self-reported client metadata does not grant authority.

    #OAuth for HTTP servers

    A skill's mcp.json can declare a public OAuth client instead of a static Authorization header or headersHelper:

    { "mcpServers": { "github": { "url": "https://api.githubcopilot.com/mcp/", "oauth": { "grantType": "device_code", "clientId": "Ov23liDY0j2riv3dZtVY", "deviceAuthorizationEndpoint": "https://github.com/login/device/code", "tokenEndpoint": "https://github.com/login/oauth/access_token", "scopes": "repo read:org" } } } }

    This is the Device Authorization Grant. The bundled GitHub skill uses the OpenSeek OAuth App. Desktop displays the provider's URL and user code, and the host polls at the provider's interval.

    For a server that supports public client registration and S256 PKCE, use the Authorization Code Grant in the skill's mcp.json:

    { "mcpServers": { "example": { "url": "https://mcp.example.com/mcp", "oauth": { "grantType": "authorization_code", "issuer": "https://mcp.example.com" } } } }

    Copy the skill directory into ~/.openseek/skills/ (or the library set by OPENSEEK_GLOBAL_SKILLS_DIR), then connect the server in Desktop Settings → MCP.

    For authorization_code, the MCP URL and discovered OAuth endpoints must belong to the configured HTTPS issuer. OpenSeek reads protected resource and issuer metadata, registers and reuses a public client, and verifies the provider's redirect on a loopback listener with a temporary port. The browser must run on the same computer as the host. The host exchanges the code directly with the provider.

    Desktop Settings → MCP lists MCP configurations in bundled and globally installed skills. Globally installed skills override bundled skills of the same name. Connect opens the provider's page. Workspace-only skills and standalone MCP configurations are outside this settings list. An explicit MCP config overrides a same-named skill server.

    Credentials and public client registrations are stored under ~/.openseek/oauth (OPENSEEK_OAUTH_DIR overrides this). Files are atomically replaced with mode 0600 on POSIX and the directory is created with mode 0700. The settings UI receives status only. The engine refreshes browser grants before expiry and serializes refreshes across processes so each rotated token is saved before the next refresh. Device grants require reconnect after expiry. The next tool search or call reloads changed credentials and resets the connection. Disconnect deletes the local credential. Provider-side revocation is separate.

    OAuth configuration cannot be combined with an Authorization header or headersHelper. Environment placeholders expand as in other MCP fields.

    McpError

    pub suberror McpError {
    Protocol(String)
    }

    An MCP-layer failure: the server sent a response that could not be read as the expected MCP shape. A JSON-RPC error reply surfaces separately as @jsonrpc.ResponseError.

    CallToolResult

    pub struct CallToolResult {
    content : Array[ContentBlock]
    structured_content :
    Json
    ?
    is_error : Bool
    } derive(Eq,
    Debug
    )

    The result of a tools/call: its content blocks, any structured output, and whether the server flagged the call as a tool-level error (distinct from a JSON-RPC error). Since 2025-06-18 a server may return the real result in structuredContent and leave content empty (or a generic status), so the structured value is kept rather than dropped.

    CallToolResult::render

    Render the result for the model in content order: text blocks verbatim, images the shared validator accepts as attached images, and every other block (including a rejected image) as a compact placeholder in the text. Text parts are joined by newlines. Structured output stays in structured_content. The caller applies any size budget and metadata footer. Empty content yields "" and no images.

    CallToolResult::render_text

    fn CallToolResult::render_text(self : CallToolResult) -> String

    The text part of render, for callers that read a result as text.

    ContentBlock

    pub enum ContentBlock {
    Text(String)
    Image(mime_type~ : String, data~ : String)
    Resource(uri~ : String, text~ : String?)
    Other(kind~ : String)
    } derive(Eq,
    Debug
    )

    One block of a tools/call result's content array. Text and image blocks keep their payload; other blocks are kept as compact descriptors — audio bytes are noted, not forwarded.

    InitializeResult

    pub struct InitializeResult {
    protocol_version : String
    server_name : String?
    server_version : String?
    instructions : String?
    } derive(Eq,
    Debug
    )

    What discovery or legacy initialization reported: the selected protocol version and identity. server_name/server_version are absent when the server omits serverInfo.

    McpClient

    type McpClient

    An MCP client bound to a connected @jsonrpc.Client.

    McpClient::McpClient

    fn McpClient::McpClient(rpc :
    Client
    , list_before_call? : Bool) -> McpClient

    Wrap a connected JSON-RPC client. Its message pump must already be running (spawned by the transport/connect layer) so replies are routed. HTTP transports enable list_before_call to obtain header annotations before the first modern tool call, even when the caller has not listed tools.

    McpClient::call_tool

    async fn McpClient::call_tool(self : McpClient, name~ : String, arguments~ :
    Json
    ) -> CallToolResult

    Invoke a tool by its server-side name. A JSON-RPC error reply (e.g. unknown tool, invalid params) raises @jsonrpc.ResponseError; a tool-level failure comes back as a normal result with is_error = true.

    McpClient::close

    fn McpClient::close(self : McpClient) -> Unit

    Close the underlying JSON-RPC client and its transport. Idempotent.

    McpClient::discover

    async fn McpClient::discover(self : McpClient, client_name~ : String, client_version~ : String) -> InitializeResult

    Probe a peer using stateless discovery. Transport owners decide whether an error or timeout warrants legacy initialization; malformed successes never do. Once discovered, every tool request carries this client's metadata.

    McpClient::initialize

    async fn McpClient::initialize(self : McpClient, client_name~ : String, client_version~ : String) -> InitializeResult

    Run the MCP handshake: send initialize with our client identity, then the notifications/initialized notification once the server has answered. Returns the server's negotiated protocol version and identity. Raises on transport failure (@jsonrpc.ResponseError) or a malformed result (McpError).

    McpClient::is_closed

    fn McpClient::is_closed(self : McpClient) -> Bool

    Whether the connection has ended — the server exited or hung up, the transport failed, or it was closed locally. A closed client never answers.

    McpClient::list_tools

    async fn McpClient::list_tools(self : McpClient) -> Array[McpTool]

    List every tool the server offers, following nextCursor pagination until the server stops returning one. Raises on transport failure or a malformed result.

    McpClient::set_close_handler

    fn McpClient::set_close_handler(self : McpClient, handler : () -> Unit) -> Unit

    Install the handler run once when the connection ends, for any reason. It runs synchronously on whichever task closed the client, so it must not block.

    McpTool

    pub struct McpTool {
    name : String
    description : String
    input_schema :
    Json

    output_schema :
    Json
    ?
    } derive(Eq,
    Debug
    )

    A tool advertised by an MCP server via tools/list.

    RenderedResult

    pub struct RenderedResult {
    text : String
    images : Array[
    Image
    ]
    }

    A tools/call result as the model receives it: its text and the images attached alongside it.