API
Server Types
MCPServerConfigMCPServerMCPRequestContextMCPHTTPServerMCPServerToolMCPServerPromptMCPServerResource
Server Functions
register_tool!register_prompt!register_resource!register_resource_template!serve_mcp_httpstop_mcp_serverbase_urlset_request_hook!set_cancellation_handler!set_logging_handler!set_completion_handler!log_message!enqueue_server_event!broadcast_server_event!notify_resource_updated!
Trim-safe Static Server
These specialized names are not exported. Use them through the ModelContextProtocol namespace. See the static server guide for a complete example and the support limits.
ModelContextProtocol.StaticMCPServerModelContextProtocol.StaticMCPToolModelContextProtocol.StaticMCPToolResultModelContextProtocol.StaticMCPResourceModelContextProtocol.StaticMCPRequestContextModelContextProtocol.static_ui_tool_metaModelContextProtocol.static_ui_extensionsModelContextProtocol.handle_static_jsonrpc_requestModelContextProtocol.handle_static_stream_requestModelContextProtocol.handle_static_session_delete
MCP Events
These APIs are namespaced. See MCP Events for security hooks, persistence, delivery receipts, and protocol limits.
ModelContextProtocol.enable_events!ModelContextProtocol.register_event!ModelContextProtocol.emit_event!ModelContextProtocol.InMemoryEventSubscriptionStoreModelContextProtocol.FileEventSubscriptionStoreModelContextProtocol.MCPEventSubscriptionStoreModelContextProtocol.list_eventsModelContextProtocol.subscribe_eventModelContextProtocol.unsubscribe_eventModelContextProtocol.event_webhook_secretModelContextProtocol.verify_event_webhook
MCP Apps (SEP-1865)
Helpers for serving interactive HTML widgets that hosts render inline. See MCP-App-playbook.md for the full guide.
MCP_APPS_EXTENSION_IDMCP_APP_HTML_MIME_TYPEMCP_APPS_UI_PROTOCOL_VERSIONMCPUIResourceui_extension_capabilityadd_ui_extension_capability!ModelContextProtocol.supports_mcp_apps_uiui_tool_metaui_resource_metaui_resource_contentsembedded_ui_resourceui_tool_contentregister_ui_resource!mcp_app_htmlMCP_APP_BOOTSTRAP_JS
Client Types
MCPDiscoveryMCPTransportDescriptorMCPClientConfigMCPClientMCPAuthenticationRequiredMCPAuthenticationChallenge
Client Functions
ModelContextProtocol.prepare_stdio_clientdiscover_serverprepare_manual_clientattach_token!initialize_client!list_toolscall_toollist_promptsget_promptlist_resourcesread_resourcelist_resource_templatessubscribe_resourceunsubscribe_resourcecompletion_completeset_log_level!pingopen_event_streamregister_request_handler!clear_request_handlers!start_event_listener!stop_event_listener!terminate_session!
Owned stdio clients
ModelContextProtocol.prepare_stdio_client — Function
ModelContextProtocol.prepare_stdio_client(command::Cmd; config=MCPClientConfig(),
stderr=Base.stderr, capabilities=Dict(), client_info=default_client_info(),
max_message_bytes=16*1024*1024, max_pending_messages=128)Launch and own a local MCP server process. Use initialize_client! and the ordinary client call APIs, then close(client) or terminate_session!. The do-block form closes the client even when its body throws. Register handlers and finish initialization before making concurrent calls.
Protocol selection is explicit: 2025-11-25 uses initialization and permits server requests; 2026-07-28 uses discovery and per-request metadata. HTTP headers, OAuth, HTTP event streams, and modern subscriptions are unsupported. There is no automatic protocol fallback, process restart, or request replay. Custom HTTP adapters and verbose HTTP logging are rejected.
config.timeout.readtimeout (seconds, positive and finite) bounds transport waits, including queued writes; per-call timeout_ms overrides it. The HTTP connecttimeout setting has no effect on process startup. Other timeout keys are rejected. A response timeout sends cancellation; a write timeout breaks the connection because a partial frame cannot be retried safely.
The byte limit applies to each incoming and outgoing message. The pending limit separately bounds calls, queued writes, queued notifications, and active server-request handlers. Callback overflow or invalid server output breaks the connection. Notifications run in order; legacy request handlers run in separate tasks and may overlap each other and notifications. A handler's nested call can receive another server request before it completes. Closing discards callbacks that have not started. User callbacks must cooperate with shutdown; see close(::MCPClient).
The child's stderr is redirected directly to a filename, IOStream, terminal, pipe, or devnull, separately from protocol stdout. In-memory and custom IO destinations are unsupported. Caller-provided IO remains caller-owned.
Base.close — Method
close(client::MCPClient; timeout=5.0)For an owned stdio client, stop accepting calls, close stdin, then terminate and, if necessary, kill the child. Fail pending calls and wait for owned IO and callback tasks. timeout bounds this wait; unfinished cleanup is retained and a later close may finish it. The caller owns any custom stderr destination.
Julia cannot safely interrupt arbitrary user callback code. If a callback remains blocked after process/IO shutdown, throw MCPError(:callback_timeout); release the callback and close again. A callback that calls close waits for process and IO shutdown but not for user callback tasks, preventing callbacks that close concurrently from waiting on each other. A later external close waits for any unfinished callbacks. Queued callbacks are discarded. HTTP clients delegate to terminate_session!.
MCP 2026-07-28
The modern low-level helpers stay under the package namespace to keep the export surface small. See the MCP 2026-07-28 guide.
MCPInputRequiredModelContextProtocol.PROTOCOL_VERSION_2026_07_28ModelContextProtocol.discover_server_info!ModelContextProtocol.is_input_requiredModelContextProtocol.input_responsesModelContextProtocol.request_stateModelContextProtocol.send_progress!ModelContextProtocol.send_log!ModelContextProtocol.listen_subscriptions!ModelContextProtocol.close_subscription_listeners!