const PROTOCOL_VERSION
pub const PROTOCOL_VERSION = "2025-03-26"Purpose
Constant PROTOCOL_VERSION, defining protocol or algorithm parameters.
#github.com/xulang-org/packages/mcpExternal package `mcp #github.com/xulang-org/packages/mcp`, provided by github.com/xulang-org/packages.
github.com/xulang-org/packages · 1.17.2 · Install and use
const PROTOCOL_VERSIONpub const PROTOCOL_VERSION = "2025-03-26"Constant PROTOCOL_VERSION, defining protocol or algorithm parameters.
struct ToolAnnotationspub struct ToolAnnotations {
pub title string
pub read_only_hint bool
pub destructive_hint bool
pub idempotent_hint bool
pub open_world_hint bool
pub has_annotations bool
}Structure encapsulating title, read_only_hint, destructive_hint, idempotent_hint, open_world_hint.
title stringread_only_hint booldestructive_hint boolidempotent_hint boolopen_world_hint boolhas_annotations boolempty_tool_annotationspub fn empty_tool_annotations() ToolAnnotationsEmpty tool annotations.
No arguments are required.
ToolAnnotations — a value of this type
struct ToolInfopub struct ToolInfo {
pub name string
pub description string
pub input_schema_json string
pub annotations ToolAnnotations
}Structure encapsulating name, description, input_schema_json, annotations.
name stringdescription stringinput_schema_json stringannotations ToolAnnotationsstruct ResourceInfopub struct ResourceInfo {
pub uri string
pub name string
pub description string
pub mime_type string
}Structure encapsulating uri, name, description, mime_type.
uri stringname stringdescription stringmime_type stringstruct ResourceTemplateInfopub struct ResourceTemplateInfo {
pub uri_template string
pub name string
pub description string
pub mime_type string
}Structure encapsulating uri_template, name, description, mime_type.
uri_template stringname stringdescription stringmime_type stringstruct PromptInfopub struct PromptInfo {
pub name string
pub description string
pub arguments_json string
}Structure encapsulating name, description, arguments_json.
name stringdescription stringarguments_json stringstruct ContentItempub struct ContentItem {
pub kind string
pub text string
}Structure encapsulating kind, text.
kind stringtext stringstruct ToolResultpub struct ToolResult {
pub content []ContentItem
pub is_error bool
}Structure encapsulating content, is_error.
content []ContentItemis_error booltext_resultpub fn text_result(text string) ToolResultText result.
text stringToolResult — a value of this type
error_resultpub fn error_result(text string) ToolResultError result.
text stringToolResult — a value of this type
struct Serverpub struct Server {
pub name string
pub version string
pub log_level string
}Structure encapsulating name, version, log_level.
name stringversion stringlog_level stringnew_serverpub fn new_server(name string, version string) ServerConstruct server.
name stringversion stringServer — a value of this type
($&Server) add_toolpub fn (s $&Server) add_tool(name string, description string, input_schema_json string, handler fn(&string) ToolResult)Operation on $&Server: add tool.
s $&ServerServer instance used by this call (exclusive borrow).name stringdescription stringinput_schema_json stringhandler fn(&string) ToolResultThis call does not return a value.
($&Server) add_tool_annotatedpub fn (s $&Server) add_tool_annotated(name string, description string, input_schema_json string, annotations ToolAnnotations, handler fn(&string) ToolResult)Operation on $&Server: add tool annotated.
s $&ServerServer instance used by this call (exclusive borrow).name stringdescription stringinput_schema_json stringannotations ToolAnnotationshandler fn(&string) ToolResultThis call does not return a value.
($&Server) add_resourcepub fn (s $&Server) add_resource(uri string, name string, description string, mime_type string, handler fn(&string) string)Operation on $&Server: add resource.
s $&ServerServer instance used by this call (exclusive borrow).uri stringname stringdescription stringmime_type stringhandler fn(&string) stringThis call does not return a value.
($&Server) add_resource_templatepub fn (s $&Server) add_resource_template(uri_template string, name string, description string, mime_type string)Operation on $&Server: add resource template.
s $&ServerServer instance used by this call (exclusive borrow).uri_template stringname stringdescription stringmime_type stringThis call does not return a value.
($&Server) add_resource_template_handlerpub fn (s $&Server) add_resource_template_handler(uri_template string, name string, description string, mime_type string, handler fn(&string, &string) string)Operation on $&Server: add resource template handler.
s $&ServerServer instance used by this call (exclusive borrow).uri_template stringname stringdescription stringmime_type stringhandler fn(&string, &string) stringThis call does not return a value.
($&Server) add_promptpub fn (s $&Server) add_prompt(name string, description string, arguments_json string, handler fn(&string) string)Operation on $&Server: add prompt.
s $&ServerServer instance used by this call (exclusive borrow).name stringdescription stringarguments_json stringhandler fn(&string) stringThis call does not return a value.
($&Server) set_completion_handlerpub fn (s $&Server) set_completion_handler(handler fn(&string, &string, &string) []string)Operation on $&Server: set completion handler.
s $&ServerServer instance used by this call (exclusive borrow).handler fn(&string, &string, &string) []stringThis call does not return a value.
($&Server) handle_json_linepub fn (s $&Server) handle_json_line(line &string) stringOperation on $&Server: handle json line.
s $&ServerServer instance used by this call (exclusive borrow).line &stringstring — result string
($&Server) serve_stdiopub fn (s $&Server) serve_stdio() intOperation on $&Server: serve stdio. Throws on failure; handle the error or propagate it to the caller.
s $&ServerServer instance used by this call (exclusive borrow).int — a value of this type
($&Server) serve_http_serverpub fn (s $&Server) serve_http_server(srv $&http.Server) intserve_http_server runs the Streamable HTTP MCP accept loop on a pre-bound http.Server (so callers can bind 127.0.0.1:0 and inspect srv.addr first). Throws on failure; handle the error or propagate it to the caller.
s $&ServerServer instance used by this call (exclusive borrow).srv $&http.Serverint — a value of this type
($&Server) serve_httppub fn (s $&Server) serve_http(addr string) intOperation on $&Server: serve http. Throws on failure; handle the error or propagate it to the caller.
s $&ServerServer instance used by this call (exclusive borrow).addr stringint — a value of this type
struct Clientpub struct Client {
pub base_url string
pub session_id string
pub server_name string
pub server_version string
pub extra_headers []string
}Mcp Client session maintaining connection and operations.
base_url stringsession_id stringserver_name stringserver_version stringextra_headers []stringnew_http_clientpub fn new_http_client(base_url string) ClientConstruct http client.
base_url stringClient — a value of this type
($&Client) add_headerpub fn (c $&Client) add_header(name string, value string)Operation on $&Client: add header.
c $&ClientClient instance used by this call (exclusive borrow).name stringvalue stringThis call does not return a value.
($&Client) set_bearer_tokenpub fn (c $&Client) set_bearer_token(token string)Operation on $&Client: set bearer token.
c $&ClientClient instance used by this call (exclusive borrow).token stringThis call does not return a value.
(&Client) clone_clientpub fn (c &Client) clone_client() ClientOperation on &Client: clone client.
c &ClientClient instance used by this call (borrow).Client — a value of this type
($&Client) initializepub fn (c $&Client) initialize() intExecute initialize on $&Client. Throws on failure; handle the error or propagate it to the caller.
c $&ClientClient instance used by this call (exclusive borrow).int — a value of this type
($&Client) close_sessionpub fn (c $&Client) close_session() intOperation on $&Client: close session. Throws on failure; handle the error or propagate it to the caller.
c $&ClientClient instance used by this call (exclusive borrow).int — a value of this type
($&Client) pingpub fn (c $&Client) ping() boolSend a ping heartbeat request to verify connection liveness.
c $&ClientClient instance used by this call (exclusive borrow).bool — true or false
($&Client) list_toolspub fn (c $&Client) list_tools() []ToolInfoOperation on $&Client: list tools. Throws on failure; handle the error or propagate it to the caller.
c $&ClientClient instance used by this call (exclusive borrow).[]ToolInfo — slice result
($&Client) call_toolpub fn (c $&Client) call_tool(name string, arguments_json string) ToolResultOperation on $&Client: call tool. Throws on failure; handle the error or propagate it to the caller.
c $&ClientClient instance used by this call (exclusive borrow).name stringarguments_json stringToolResult — a value of this type
($&Client) list_resourcespub fn (c $&Client) list_resources() []ResourceInfoOperation on $&Client: list resources. Throws on failure; handle the error or propagate it to the caller.
c $&ClientClient instance used by this call (exclusive borrow).[]ResourceInfo — slice result
($&Client) list_resource_templatespub fn (c $&Client) list_resource_templates() []ResourceTemplateInfoOperation on $&Client: list resource templates. Throws on failure; handle the error or propagate it to the caller.
c $&ClientClient instance used by this call (exclusive borrow).[]ResourceTemplateInfo — slice result
($&Client) completepub fn (c $&Client) complete(ref_type string, ref_id string, argument_name string, argument_value string) []stringExecute complete on $&Client. Throws on failure; handle the error or propagate it to the caller.
c $&ClientClient instance used by this call (exclusive borrow).ref_type stringref_id stringargument_name stringargument_value string[]string — slice result
($&Client) read_resourcepub fn (c $&Client) read_resource(uri string) stringOperation on $&Client: read resource. Throws on failure; handle the error or propagate it to the caller.
c $&ClientClient instance used by this call (exclusive borrow).uri stringstring — result string
($&Client) list_promptspub fn (c $&Client) list_prompts() []PromptInfoOperation on $&Client: list prompts. Throws on failure; handle the error or propagate it to the caller.
c $&ClientClient instance used by this call (exclusive borrow).[]PromptInfo — slice result
($&Client) get_promptpub fn (c $&Client) get_prompt(name string, arguments_json string) stringOperation on $&Client: read prompt. Throws on failure; handle the error or propagate it to the caller.
c $&ClientClient instance used by this call (exclusive borrow).name stringarguments_json stringstring — result string
($&Client) set_logging_levelpub fn (c $&Client) set_logging_level(level string) intOperation on $&Client: set logging level. Throws on failure; handle the error or propagate it to the caller.
c $&ClientClient instance used by this call (exclusive borrow).level stringint — a value of this type
struct StdioClientpub struct StdioClient {
pub server_name string
pub server_version string
pub closed bool
}Mcp Client session maintaining connection and operations.
server_name stringserver_version stringclosed boolclosed_stdio_clientpub fn closed_stdio_client() StdioClientClosed stdio client.
No arguments are required.
StdioClient — a value of this type
connect_stdiopub fn connect_stdio(command string, args []string) StdioClientConnect stdio. Throws on failure; handle the error or propagate it to the caller.
command stringargs []stringStdioClient — a value of this type
($&StdioClient) initializepub fn (c $&StdioClient) initialize() intExecute initialize on $&StdioClient. Throws on failure; handle the error or propagate it to the caller.
c $&StdioClientStdioClient instance used by this call (exclusive borrow).int — a value of this type
($&StdioClient) pingpub fn (c $&StdioClient) ping() boolSend a ping heartbeat request to verify connection liveness.
c $&StdioClientStdioClient instance used by this call (exclusive borrow).bool — true or false
($&StdioClient) list_toolspub fn (c $&StdioClient) list_tools() []ToolInfoOperation on $&StdioClient: list tools. Throws on failure; handle the error or propagate it to the caller.
c $&StdioClientStdioClient instance used by this call (exclusive borrow).[]ToolInfo — slice result
($&StdioClient) call_toolpub fn (c $&StdioClient) call_tool(name string, arguments_json string) ToolResultOperation on $&StdioClient: call tool. Throws on failure; handle the error or propagate it to the caller.
c $&StdioClientStdioClient instance used by this call (exclusive borrow).name stringarguments_json stringToolResult — a value of this type
($&StdioClient) list_resourcespub fn (c $&StdioClient) list_resources() []ResourceInfoOperation on $&StdioClient: list resources. Throws on failure; handle the error or propagate it to the caller.
c $&StdioClientStdioClient instance used by this call (exclusive borrow).[]ResourceInfo — slice result
($&StdioClient) list_resource_templatespub fn (c $&StdioClient) list_resource_templates() []ResourceTemplateInfoOperation on $&StdioClient: list resource templates. Throws on failure; handle the error or propagate it to the caller.
c $&StdioClientStdioClient instance used by this call (exclusive borrow).[]ResourceTemplateInfo — slice result
($&StdioClient) completepub fn (c $&StdioClient) complete(ref_type string, ref_id string, argument_name string, argument_value string) []stringExecute complete on $&StdioClient. Throws on failure; handle the error or propagate it to the caller.
c $&StdioClientStdioClient instance used by this call (exclusive borrow).ref_type stringref_id stringargument_name stringargument_value string[]string — slice result
($&StdioClient) read_resourcepub fn (c $&StdioClient) read_resource(uri string) stringOperation on $&StdioClient: read resource. Throws on failure; handle the error or propagate it to the caller.
c $&StdioClientStdioClient instance used by this call (exclusive borrow).uri stringstring — result string
($&StdioClient) list_promptspub fn (c $&StdioClient) list_prompts() []PromptInfoOperation on $&StdioClient: list prompts. Throws on failure; handle the error or propagate it to the caller.
c $&StdioClientStdioClient instance used by this call (exclusive borrow).[]PromptInfo — slice result
($&StdioClient) get_promptpub fn (c $&StdioClient) get_prompt(name string, arguments_json string) stringOperation on $&StdioClient: read prompt. Throws on failure; handle the error or propagate it to the caller.
c $&StdioClientStdioClient instance used by this call (exclusive borrow).name stringarguments_json stringstring — result string
($&StdioClient) set_logging_levelpub fn (c $&StdioClient) set_logging_level(level string) intOperation on $&StdioClient: set logging level. Throws on failure; handle the error or propagate it to the caller.
c $&StdioClientStdioClient instance used by this call (exclusive borrow).level stringint — a value of this type
($&StdioClient) closepub fn (c $&StdioClient) close() intOperation on $&StdioClient: close the resource. Throws on failure; handle the error or propagate it to the caller.
c $&StdioClientStdioClient instance used by this call (exclusive borrow).int — a value of this type
($&StdioClient) close_nowaitpub fn (c $&StdioClient) close_nowait() intclose_nowait closes client pipes after sending notifications/exit without waiting on child exit; use this for external MCP servers that ignore notifications/exit while inherited non-FD_CLOEXEC pipes keep stdin open.
c $&StdioClientStdioClient instance used by this call (exclusive borrow).int — a value of this type