XU XUv0.16.0

#github.com/xulang-org/packages/mcp

import: mcp #github.com/xulang-org/packages/mcp

counts: 7 functions, 39 methods, 10 types, 1 constants, 0 method sets

External 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_VERSION

XuAPI
pub const PROTOCOL_VERSION = "2025-03-26"

Purpose

Constant PROTOCOL_VERSION, defining protocol or algorithm parameters.

struct ToolAnnotations

XuAPI
pub 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
}

Purpose

Structure encapsulating title, read_only_hint, destructive_hint, idempotent_hint, open_world_hint.

Public fields

title string
field (string)
read_only_hint bool
field (bool)
destructive_hint bool
field (bool)
idempotent_hint bool
field (bool)
open_world_hint bool
field (bool)
has_annotations bool
field (bool)

empty_tool_annotations

XuAPI
pub fn empty_tool_annotations() ToolAnnotations

Purpose

Empty tool annotations.

Parameters

No arguments are required.

Returns

ToolAnnotations — a value of this type

struct ToolInfo

XuAPI
pub struct ToolInfo {
    pub name string
    pub description string
    pub input_schema_json string
    pub annotations ToolAnnotations
}

Purpose

Structure encapsulating name, description, input_schema_json, annotations.

Public fields

name string
name
description string
field (string)
input_schema_json string
field (string)
annotations ToolAnnotations
field (ToolAnnotations)

struct ResourceInfo

XuAPI
pub struct ResourceInfo {
    pub uri string
    pub name string
    pub description string
    pub mime_type string
}

Purpose

Structure encapsulating uri, name, description, mime_type.

Public fields

uri string
field (string)
name string
name
description string
field (string)
mime_type string
field (string)

struct ResourceTemplateInfo

XuAPI
pub struct ResourceTemplateInfo {
    pub uri_template string
    pub name string
    pub description string
    pub mime_type string
}

Purpose

Structure encapsulating uri_template, name, description, mime_type.

Public fields

uri_template string
field (string)
name string
name
description string
field (string)
mime_type string
field (string)

struct PromptInfo

XuAPI
pub struct PromptInfo {
    pub name string
    pub description string
    pub arguments_json string
}

Purpose

Structure encapsulating name, description, arguments_json.

Public fields

name string
name
description string
field (string)
arguments_json string
field (string)

struct ContentItem

XuAPI
pub struct ContentItem {
    pub kind string
    pub text string
}

Purpose

Structure encapsulating kind, text.

Public fields

kind string
kind tag
text string
text

struct ToolResult

XuAPI
pub struct ToolResult {
    pub content []ContentItem
    pub is_error bool
}

Purpose

Structure encapsulating content, is_error.

Public fields

content []ContentItem
field ([]ContentItem)
is_error bool
field (bool)

text_result

XuAPI
pub fn text_result(text string) ToolResult

Purpose

Text result.

Parameters

text string
text (string)

Returns

ToolResult — a value of this type

error_result

XuAPI
pub fn error_result(text string) ToolResult

Purpose

Error result.

Parameters

text string
text (string)

Returns

ToolResult — a value of this type

struct Server

XuAPI
pub struct Server {
    pub name string
    pub version string
    pub log_level string
}

Purpose

Structure encapsulating name, version, log_level.

Public fields

name string
name
version string
field (string)
log_level string
field (string)

new_server

XuAPI
pub fn new_server(name string, version string) Server

Purpose

Construct server.

Parameters

name string
name (string)
version string
version (string)

Returns

Server — a value of this type

($&Server) add_tool

XuAPI
pub fn (s $&Server) add_tool(name string, description string, input_schema_json string, handler fn(&string) ToolResult)

Purpose

Operation on $&Server: add tool.

Parameters

s $&Server
The Server instance used by this call (exclusive borrow).
name string
name (string)
description string
description (string)
input_schema_json string
input_schema_json (string)
handler fn(&string) ToolResult
handler (function value; type fn(&string) ToolResult)

Returns

This call does not return a value.

($&Server) add_tool_annotated

XuAPI
pub fn (s $&Server) add_tool_annotated(name string, description string, input_schema_json string, annotations ToolAnnotations, handler fn(&string) ToolResult)

Purpose

Operation on $&Server: add tool annotated.

Parameters

s $&Server
The Server instance used by this call (exclusive borrow).
name string
name (string)
description string
description (string)
input_schema_json string
input_schema_json (string)
annotations ToolAnnotations
annotations (ToolAnnotations)
handler fn(&string) ToolResult
handler (function value; type fn(&string) ToolResult)

Returns

This call does not return a value.

($&Server) add_resource

XuAPI
pub fn (s $&Server) add_resource(uri string, name string, description string, mime_type string, handler fn(&string) string)

Purpose

Operation on $&Server: add resource.

Parameters

s $&Server
The Server instance used by this call (exclusive borrow).
uri string
uri (string)
name string
name (string)
description string
description (string)
mime_type string
mime_type (string)
handler fn(&string) string
handler (function value; type fn(&string) string)

Returns

This call does not return a value.

($&Server) add_resource_template

XuAPI
pub fn (s $&Server) add_resource_template(uri_template string, name string, description string, mime_type string)

Purpose

Operation on $&Server: add resource template.

Parameters

s $&Server
The Server instance used by this call (exclusive borrow).
uri_template string
uri_template (string)
name string
name (string)
description string
description (string)
mime_type string
mime_type (string)

Returns

This call does not return a value.

($&Server) add_resource_template_handler

XuAPI
pub fn (s $&Server) add_resource_template_handler(uri_template string, name string, description string, mime_type string, handler fn(&string, &string) string)

Purpose

Operation on $&Server: add resource template handler.

Parameters

s $&Server
The Server instance used by this call (exclusive borrow).
uri_template string
uri_template (string)
name string
name (string)
description string
description (string)
mime_type string
mime_type (string)
handler fn(&string, &string) string
handler (function value; type fn(&string, &string) string)

Returns

This call does not return a value.

($&Server) add_prompt

XuAPI
pub fn (s $&Server) add_prompt(name string, description string, arguments_json string, handler fn(&string) string)

Purpose

Operation on $&Server: add prompt.

Parameters

s $&Server
The Server instance used by this call (exclusive borrow).
name string
name (string)
description string
description (string)
arguments_json string
arguments_json (string)
handler fn(&string) string
handler (function value; type fn(&string) string)

Returns

This call does not return a value.

($&Server) set_completion_handler

XuAPI
pub fn (s $&Server) set_completion_handler(handler fn(&string, &string, &string) []string)

Purpose

Operation on $&Server: set completion handler.

Parameters

s $&Server
The Server instance used by this call (exclusive borrow).
handler fn(&string, &string, &string) []string
handler (function value; type fn(&string, &string, &string) []string)

Returns

This call does not return a value.

($&Server) handle_json_line

XuAPI
pub fn (s $&Server) handle_json_line(line &string) string

Purpose

Operation on $&Server: handle json line.

Parameters

s $&Server
The Server instance used by this call (exclusive borrow).
line &string
line (read-only borrow; caller keeps the original; type &string)

Returns

string — result string

($&Server) serve_stdio

XuAPI
pub fn (s $&Server) serve_stdio() int

Purpose

Operation on $&Server: serve stdio. Throws on failure; handle the error or propagate it to the caller.

Parameters

s $&Server
The Server instance used by this call (exclusive borrow).

Returns

int — a value of this type

($&Server) serve_http_server

XuAPI
pub fn (s $&Server) serve_http_server(srv $&http.Server) int

Purpose

serve_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.

Parameters

s $&Server
The Server instance used by this call (exclusive borrow).
srv $&http.Server
srv (exclusive borrow; may modify the original; type $&http.Server)

Returns

int — a value of this type

($&Server) serve_http

XuAPI
pub fn (s $&Server) serve_http(addr string) int

Purpose

Operation on $&Server: serve http. Throws on failure; handle the error or propagate it to the caller.

Parameters

s $&Server
The Server instance used by this call (exclusive borrow).
addr string
address (string)

Returns

int — a value of this type

struct Client

XuAPI
pub struct Client {
    pub base_url string
    pub session_id string
    pub server_name string
    pub server_version string
    pub extra_headers []string
}

Purpose

Mcp Client session maintaining connection and operations.

Public fields

base_url string
field (string)
session_id string
field (string)
server_name string
field (string)
server_version string
field (string)
extra_headers []string
field ([]string)

new_http_client

XuAPI
pub fn new_http_client(base_url string) Client

Purpose

Construct http client.

Parameters

base_url string
base_url (string)

Returns

Client — a value of this type

($&Client) add_header

XuAPI
pub fn (c $&Client) add_header(name string, value string)

Purpose

Operation on $&Client: add header.

Parameters

c $&Client
The Client instance used by this call (exclusive borrow).
name string
name (string)
value string
value (string)

Returns

This call does not return a value.

($&Client) set_bearer_token

XuAPI
pub fn (c $&Client) set_bearer_token(token string)

Purpose

Operation on $&Client: set bearer token.

Parameters

c $&Client
The Client instance used by this call (exclusive borrow).
token string
token (string)

Returns

This call does not return a value.

(&Client) clone_client

XuAPI
pub fn (c &Client) clone_client() Client

Purpose

Operation on &Client: clone client.

Parameters

c &Client
The Client instance used by this call (borrow).

Returns

Client — a value of this type

($&Client) initialize

XuAPI
pub fn (c $&Client) initialize() int

Purpose

Execute initialize on $&Client. Throws on failure; handle the error or propagate it to the caller.

Parameters

c $&Client
The Client instance used by this call (exclusive borrow).

Returns

int — a value of this type

($&Client) close_session

XuAPI
pub fn (c $&Client) close_session() int

Purpose

Operation on $&Client: close session. Throws on failure; handle the error or propagate it to the caller.

Parameters

c $&Client
The Client instance used by this call (exclusive borrow).

Returns

int — a value of this type

($&Client) ping

XuAPI
pub fn (c $&Client) ping() bool

Purpose

Send a ping heartbeat request to verify connection liveness.

Parameters

c $&Client
The Client instance used by this call (exclusive borrow).

Returns

bool — true or false

($&Client) list_tools

XuAPI
pub fn (c $&Client) list_tools() []ToolInfo

Purpose

Operation on $&Client: list tools. Throws on failure; handle the error or propagate it to the caller.

Parameters

c $&Client
The Client instance used by this call (exclusive borrow).

Returns

[]ToolInfo — slice result

($&Client) call_tool

XuAPI
pub fn (c $&Client) call_tool(name string, arguments_json string) ToolResult

Purpose

Operation on $&Client: call tool. Throws on failure; handle the error or propagate it to the caller.

Parameters

c $&Client
The Client instance used by this call (exclusive borrow).
name string
name (string)
arguments_json string
arguments_json (string)

Returns

ToolResult — a value of this type

($&Client) list_resources

XuAPI
pub fn (c $&Client) list_resources() []ResourceInfo

Purpose

Operation on $&Client: list resources. Throws on failure; handle the error or propagate it to the caller.

Parameters

c $&Client
The Client instance used by this call (exclusive borrow).

Returns

[]ResourceInfo — slice result

($&Client) list_resource_templates

XuAPI
pub fn (c $&Client) list_resource_templates() []ResourceTemplateInfo

Purpose

Operation on $&Client: list resource templates. Throws on failure; handle the error or propagate it to the caller.

Parameters

c $&Client
The Client instance used by this call (exclusive borrow).

Returns

[]ResourceTemplateInfo — slice result

($&Client) complete

XuAPI
pub fn (c $&Client) complete(ref_type string, ref_id string, argument_name string, argument_value string) []string

Purpose

Execute complete on $&Client. Throws on failure; handle the error or propagate it to the caller.

Parameters

c $&Client
The Client instance used by this call (exclusive borrow).
ref_type string
ref_type (string)
ref_id string
ref_id (string)
argument_name string
argument_name (string)
argument_value string
argument_value (string)

Returns

[]string — slice result

($&Client) read_resource

XuAPI
pub fn (c $&Client) read_resource(uri string) string

Purpose

Operation on $&Client: read resource. Throws on failure; handle the error or propagate it to the caller.

Parameters

c $&Client
The Client instance used by this call (exclusive borrow).
uri string
uri (string)

Returns

string — result string

($&Client) list_prompts

XuAPI
pub fn (c $&Client) list_prompts() []PromptInfo

Purpose

Operation on $&Client: list prompts. Throws on failure; handle the error or propagate it to the caller.

Parameters

c $&Client
The Client instance used by this call (exclusive borrow).

Returns

[]PromptInfo — slice result

($&Client) get_prompt

XuAPI
pub fn (c $&Client) get_prompt(name string, arguments_json string) string

Purpose

Operation on $&Client: read prompt. Throws on failure; handle the error or propagate it to the caller.

Parameters

c $&Client
The Client instance used by this call (exclusive borrow).
name string
name (string)
arguments_json string
arguments_json (string)

Returns

string — result string

($&Client) set_logging_level

XuAPI
pub fn (c $&Client) set_logging_level(level string) int

Purpose

Operation on $&Client: set logging level. Throws on failure; handle the error or propagate it to the caller.

Parameters

c $&Client
The Client instance used by this call (exclusive borrow).
level string
level (string)

Returns

int — a value of this type

struct StdioClient

XuAPI
pub struct StdioClient {
    pub server_name string
    pub server_version string
    pub closed bool
}

Purpose

Mcp Client session maintaining connection and operations.

Public fields

server_name string
field (string)
server_version string
field (string)
closed bool
field (bool)

closed_stdio_client

XuAPI
pub fn closed_stdio_client() StdioClient

Purpose

Closed stdio client.

Parameters

No arguments are required.

Returns

StdioClient — a value of this type

connect_stdio

XuAPI
pub fn connect_stdio(command string, args []string) StdioClient

Purpose

Connect stdio. Throws on failure; handle the error or propagate it to the caller.

Parameters

command string
command (string)
args []string
variadic arguments ([]string)

Returns

StdioClient — a value of this type

($&StdioClient) initialize

XuAPI
pub fn (c $&StdioClient) initialize() int

Purpose

Execute initialize on $&StdioClient. Throws on failure; handle the error or propagate it to the caller.

Parameters

c $&StdioClient
The StdioClient instance used by this call (exclusive borrow).

Returns

int — a value of this type

($&StdioClient) ping

XuAPI
pub fn (c $&StdioClient) ping() bool

Purpose

Send a ping heartbeat request to verify connection liveness.

Parameters

c $&StdioClient
The StdioClient instance used by this call (exclusive borrow).

Returns

bool — true or false

($&StdioClient) list_tools

XuAPI
pub fn (c $&StdioClient) list_tools() []ToolInfo

Purpose

Operation on $&StdioClient: list tools. Throws on failure; handle the error or propagate it to the caller.

Parameters

c $&StdioClient
The StdioClient instance used by this call (exclusive borrow).

Returns

[]ToolInfo — slice result

($&StdioClient) call_tool

XuAPI
pub fn (c $&StdioClient) call_tool(name string, arguments_json string) ToolResult

Purpose

Operation on $&StdioClient: call tool. Throws on failure; handle the error or propagate it to the caller.

Parameters

c $&StdioClient
The StdioClient instance used by this call (exclusive borrow).
name string
name (string)
arguments_json string
arguments_json (string)

Returns

ToolResult — a value of this type

($&StdioClient) list_resources

XuAPI
pub fn (c $&StdioClient) list_resources() []ResourceInfo

Purpose

Operation on $&StdioClient: list resources. Throws on failure; handle the error or propagate it to the caller.

Parameters

c $&StdioClient
The StdioClient instance used by this call (exclusive borrow).

Returns

[]ResourceInfo — slice result

($&StdioClient) list_resource_templates

XuAPI
pub fn (c $&StdioClient) list_resource_templates() []ResourceTemplateInfo

Purpose

Operation on $&StdioClient: list resource templates. Throws on failure; handle the error or propagate it to the caller.

Parameters

c $&StdioClient
The StdioClient instance used by this call (exclusive borrow).

Returns

[]ResourceTemplateInfo — slice result

($&StdioClient) complete

XuAPI
pub fn (c $&StdioClient) complete(ref_type string, ref_id string, argument_name string, argument_value string) []string

Purpose

Execute complete on $&StdioClient. Throws on failure; handle the error or propagate it to the caller.

Parameters

c $&StdioClient
The StdioClient instance used by this call (exclusive borrow).
ref_type string
ref_type (string)
ref_id string
ref_id (string)
argument_name string
argument_name (string)
argument_value string
argument_value (string)

Returns

[]string — slice result

($&StdioClient) read_resource

XuAPI
pub fn (c $&StdioClient) read_resource(uri string) string

Purpose

Operation on $&StdioClient: read resource. Throws on failure; handle the error or propagate it to the caller.

Parameters

c $&StdioClient
The StdioClient instance used by this call (exclusive borrow).
uri string
uri (string)

Returns

string — result string

($&StdioClient) list_prompts

XuAPI
pub fn (c $&StdioClient) list_prompts() []PromptInfo

Purpose

Operation on $&StdioClient: list prompts. Throws on failure; handle the error or propagate it to the caller.

Parameters

c $&StdioClient
The StdioClient instance used by this call (exclusive borrow).

Returns

[]PromptInfo — slice result

($&StdioClient) get_prompt

XuAPI
pub fn (c $&StdioClient) get_prompt(name string, arguments_json string) string

Purpose

Operation on $&StdioClient: read prompt. Throws on failure; handle the error or propagate it to the caller.

Parameters

c $&StdioClient
The StdioClient instance used by this call (exclusive borrow).
name string
name (string)
arguments_json string
arguments_json (string)

Returns

string — result string

($&StdioClient) set_logging_level

XuAPI
pub fn (c $&StdioClient) set_logging_level(level string) int

Purpose

Operation on $&StdioClient: set logging level. Throws on failure; handle the error or propagate it to the caller.

Parameters

c $&StdioClient
The StdioClient instance used by this call (exclusive borrow).
level string
level (string)

Returns

int — a value of this type

($&StdioClient) close

XuAPI
pub fn (c $&StdioClient) close() int

Purpose

Operation on $&StdioClient: close the resource. Throws on failure; handle the error or propagate it to the caller.

Parameters

c $&StdioClient
The StdioClient instance used by this call (exclusive borrow).

Returns

int — a value of this type

($&StdioClient) close_nowait

XuAPI
pub fn (c $&StdioClient) close_nowait() int

Purpose

close_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.

Parameters

c $&StdioClient
The StdioClient instance used by this call (exclusive borrow).

Returns

int — a value of this type