Skip to main content
All Python modules · Import and compatibility guidance

Discovery operations

The facade also exposes inspect(), list_tools(cursor=None), list_resources(cursor=None), list_resource_templates(cursor=None), list_prompts(cursor=None), and get_prompt(name, arguments=None). Inspection and tool-catalogue listing are developer operations, not additional model tools.

Exports

MCPClient

A client connection to a stdio, SSE, or Streamable HTTP MCP server. Obtain this object from the owning Harnest API; its constructor includes runtime bindings. Fields (— means no declared default):

MCPClient.from_openapi

Connect to a local or remote spec through a runtime OpenAPI bridge. Reading and conversion happen when the MCP connection opens, never during authoring or compilation. Use a path relative to __file__ for specs bundled with an agent. Headers support ${VARIABLE}. client_options accepts the standard stdio policy options. Requires the optional harnest[openapi] runtime dependency.

MCPClient.stdio

Create an MCP client that starts and communicates with a subprocess.

MCPClient.streamable_http

Create an MCP client using the Streamable HTTP transport.

MCPClient.sse

Create an MCP client using the legacy HTTP/SSE transport.

MCPClient.connect

Open a developer-owned read client using the configured lifecycle and credentials.

MCPClient.required_permissions_for

Combine an optional client requirement with one remote-tool requirement.

MCPClient.to_adk_toolset

Use native transport while preserving portable expansion and failure rules.

MCPClient.to_langgraph_connection

Return a LangChain MCP adapter connection without opening it.

MCPClientContext

Privacy-safe identity supplied to an MCP client lifecycle.
Fields (— means no declared default):

MCPClientLifecycle

Customize one remote MCP connection’s HTTP client lifecycle. start and close run once for the compiled application. The synchronous create_http_client hook runs for every MCP session because ADK and LangGraph own and close those session-scoped HTTP clients.

MCPClientLifecycle.start

Initialize credential, certificate, or gateway support resources.

MCPClientLifecycle.create_http_client

Return a proxy-aware httpx.AsyncClient with safe diagnostics.

MCPClientLifecycle.close

Release application-level resources created by start.

MCPClientUnavailableError

Raised when an invocation cannot access a named managed MCP client.

MCPContext

Resolve managed MCP clients without exposing the client registry.

MCPContext.call

Return one named managed client for concise context access.

MCPContext.client

Return one named client or fail without enumerating capabilities.

MCPContextUnavailableError

Raised when managed MCP access has no active invocation binding.

MCPHTTPClientOptions

Adapter-provided inputs for one MCP HTTP client instance.
Fields (— means no declared default):

MCPLifecycleError

An MCP interceptor returned invalid or ambiguous control flow.

MCPLifecyclePipeline

Apply explicit portable interceptors around one managed MCP call.

MCPLifecyclePipeline.run

Run one call, allowing explicit short-circuit and safe recovery.

MCPResourceClient

Connection-bound read API; resource data never becomes system instructions.

MCPResourceClient.inspect

Discover capability metadata without reading resources or rendering prompts.

MCPResourceClient.list_tools

List one page of remote tool schemas under the configured tool policy.

MCPResourceClient.list_resources

Return one bounded page with the server’s opaque nextCursor unchanged.

MCPResourceClient.list_resource_templates

Discover parameterized resource URIs without fetching their contents.

MCPResourceClient.list_prompts

Discover prompt descriptions and declared arguments.

MCPResourceClient.read_resource

Read an explicitly selected URI through MCP, never through a local file API.

MCPResourceClient.get_prompt

Retrieve prompt messages as untrusted data for explicit caller use.

MCPResourceError

An MCP capability request failed without exposing connection credentials.

MCPResourceEvent

One retained resource value; handlers decide whether to invoke an agent or task.
Fields (— means no declared default):

MCPSubscription

Opt in to a URI, an async application handler, and explicit recovery policy.
Fields (— means no declared default):

MCPToolCallError

A provider-neutral failure from a discovered managed MCP tool.

MCPToolCallRequest

Opaque remote arguments that a before hook may explicitly replace.
Fields (— means no declared default):

MCPToolLifecycleContext

Privacy-safe identity for one governed remote-tool execution.
Fields (— means no declared default):

MCPToolLifecycleContext.next

Continue normally or pass a replacement to the next interceptor.

MCPToolLifecycleContext.finish

Return a final value without advancing to later execution.

MCPToolUnavailableError

Raised when a managed MCP client does not expose a requested tool.

ManagedMCPClient

Named MCP facade with no access to credentials or raw transports. Obtain this object from the owning Harnest API; its constructor includes runtime bindings. Fields (— means no declared default):

ManagedMCPClient.inspect

Discover bounded MCP catalogues through the invocation’s governed path.

ManagedMCPClient.list_resources

List one resource page without reading its contents.

ManagedMCPClient.list_tools

List remote tool metadata within this invocation’s permission scope.

ManagedMCPClient.list_resource_templates

List one page of parameterized resource URIs.

ManagedMCPClient.list_prompts

List prompt descriptions and arguments without rendering messages.

ManagedMCPClient.read_resource

Read an allowed MCP URI through the same audit and permission boundary.

ManagedMCPClient.get_prompt

Return prompt messages as data, never as higher-priority instructions.

ManagedMCPClient.call_tool

Dispatch one discovered tool through its governed shared path.