ZCP Python SDK API Reference
The Python distribution name is zero-context-protocol-sdk. The import path remains import zcp.
import zcpThis document lists the primary exported APIs and how they are grouped. For usage patterns, prefer the guides. Use this file when you already know the concept and need the symbol name.
Server Construction
Primary server-facing exports:
FastZCPZCPServerSessioncreate_asgi_appZCPASGIApprun_mcp_stdio_serverrun_mcp_stdio_server_sync
Registration APIs On FastZCP
Registration methods:
FastZCP.tool(...)FastZCP.resource(...)FastZCP.resource_template(...)FastZCP.prompt(...)FastZCP.completion(ref)FastZCP.task(kind)
These methods define the public object model exposed through the runtime.
Client And Session APIs
Primary client-facing exports:
ZCPClientSessionZCPSessionGroupMCPGatewayClientMCPGatewayServer
Important ZCPClientSession methods:
initialize(capabilities=None)initialized()ping()list_tools(cursor=None, profile=None, groups=None, exclude_groups=None, stages=None)call_tool(name, arguments, meta=None, task=None)call_tool_as_task(name, arguments, ttl=60000, poll_interval=None, meta=None)list_resources(cursor=None)list_resource_templates(cursor=None)read_resource(uri, arguments=None)subscribe_resource(uri)unsubscribe_resource(uri)list_prompts(cursor=None)get_prompt(name, arguments=None)complete(ref, argument, value=None, context=None, context_arguments=None, method="completion/complete")set_logging_level(level)list_roots()create_message(messages, **kwargs)elicit(kind, prompt, **kwargs)create_task(kind, input, task=None)list_tasks(cursor=None)get_task(task_id)get_task_result(task_id)cancel_task(task_id)
ZCPSessionGroup helpers:
list_tools(**kwargs)list_resources()list_prompts()
Tool exposure and native profiles:
ToolExposureConfigSemanticWorkflowProfile
The most important built-in native profile is semantic-workflow. It is used with list_tools(profile="semantic-workflow") and returns only tools tagged with _meta.groups that include workflow when such tools exist.
For the dedicated conceptual page, see Semantic Workflow Profile.
Runtime And Schema Types
Selected exported runtime types:
ToolDefinitionToolRegistryPromptDescriptorPromptArgumentResourceDescriptorResourceTemplateTaskDescriptorTaskExecutionContextSessionStateHandleStoreRuntimeExecutorCanonicalValidatorValidationFailure
Request and result models:
CompletionRequestCompletionResultSamplingRequestSamplingResultElicitationRequestElicitationResultInitializeParamsInitializeResult
Protocol and schema helpers:
CallRequestCallResultCallErrorHandleRefRegistryViewOpenAIStrictSchemaCompilerencode_tool_outputdecode_tool_output
Transport Helpers
Transport server helpers:
stdio_serversse_serverstreamable_http_serverwebsocket_server
Transport client helpers:
stdio_clientsse_clientstreamable_http_clientwebsocket_client
These helpers are especially useful for tests and local orchestration code.
Profiles And Adapters
Exports for model/runtime adapter flows:
AgentLoopMCPProfileOpenAIAdapterOpenAIResponsesAdapterTurnResultcompile_openai_toolsformat_callformat_registryformat_resultrun_responses_turnstream_responses_turnsubmit_tool_results
Auth And Capability Types
Auth-related exports:
AuthContextAuthProfileOAuthConfigOAuthProviderOAuthClientAuthorizationCodeAccessTokenRefreshTokenInMemoryOAuthProviderSQLiteOAuthProviderBearerAuthConfig
Capability-related exports:
CapabilitiesPROTOCOL_VERSIONProgressToken
Server Configuration Types
Configuration exports:
ZCPServerConfigHTTPConfigSSEConfigStreamableHTTPConfigWebSocketConfigRateLimitConfig
These determine transport routes, auth behavior, replay behavior, websocket availability, and coarse request limits.
Notes
- MCP compatibility is exposed on top of the same runtime core.
- Native ZCP remains the optimization path for token-sensitive workloads.
- Use
server_guide.mdandclient_guide.mdfor workflow-level explanation.