MCPServer Class

Properties   Methods   Events   Config Settings   Errors  

Implements an easy way to expose custom tools, prompts, and resources to Model Context Protocol (MCP) clients.

Syntax

class mcpsdk.MCPServer

Remarks

The MCPServer class provides a simple, event-driven API for interacting with clients that use the Model Context Protocol (MCP).

Supported Transport Mechanisms

The MCPServer class supports multiple transport mechanisms that are used to facilitate communication, which can be specified by setting the transport property.

For local communication scenarios, such as when the server is launched as a subprocess of a client application, the class is capable of communicating via standard input and output streams. This setup is simple and enables direct data exchange between the client and server within the same process environment.

In remote deployment scenarios, where the server must be accessible to multiple concurrent clients across a network, the class also supports HTTP as the transport layer, using standard HTTP requests and responses for communication. To accommodate different hosting needs, the class includes a built-in embedded HTTP server, but it can also be integrated into an existing web infrastructure such as ASP.NET Core, Apache Tomcat, or other frameworks.

While the developer experience is largely the same between these, there are some differences in authentication and request processing depending on how the server is hosted. Comprehensive information on these hosting options and configuration can be found in the Hosting Options page.

Key Features

The MCPServer class supports all major MCP functionality, including tools, prompts, resources, and sampling.

Tools

Tools provide an opportunity for LLM clients to execute custom code, interact with external systems, and access dynamic or external data. Anything for which a function can be written can also be exposed as a tool. Common examples include database queries, file operations, or computations.

Registering Tools

Tools must be registered with the server via the register_tool method to be exposed to the client. Each registration requires a unique Name and a natural language Description. The name identifies the tool, while the description helps LLM clients determine when to use it. Since tool selection is client-driven, writing clear and specific descriptions is key to improving tool usage accuracy.

A tool may have zero or more associated parameters. Each parameter must be registered before the tool it will be associated with. Each parameter requires a Name and a Required boolean indicating if that parameter is required.

server.RegisterToolParam("limit", false); server.RegisterTool("random-num", "Generates a random number");

Handling Tool Invocations

Once a tool is registered, the client may invoke it at any time. When this occurs, the on_tool_request event is fired. This event includes the Name of the requested tool, which the server can use to determine how to respond. If the tool requires input, the server can retrieve parameters from the client using the get_tool_param_value method.

If the tool completes successfully and needs to return output, the server may respond using the add_tool_message method. If an error occurs, such as an unrecognized tool is requested or a failure occurs during execution, the server should set the IsError parameter to True to inform the client that the request failed.

server.OnToolRequest += (s, e) => { if (e.Name == "random-num") { server.AddToolMessage((int)TToolMessageTypes.mtText, randomNum); } else { e.IsError = true; } };

Prompts

Prompts are predefined conversation starters or instructions that can be quickly inserted into the LLM's context to guide specific interactions or workflows. Prompts serve as standardized templates for common conversational patterns and allow for consistent responses for tasks like reviewing code, analyzing data, or answering specific types of questions. Prompts may also include arguments that allow runtime customization.

Unlike tools, prompts are user-driven. The client does not select prompts on its own; instead, the user chooses when and which prompt to insert, which allows for consistent and reusable guidance tailored to specific workflows.

Registering Prompts

Prompts must be registered with the server via the register_prompt method to be exposed to the client. Each registration requires a unique Name and a natural language Description. The name identifies the prompt, while the description helps the user understand its purpose. Once registered, the prompt becomes available for the end user to insert into the client context as needed.

A prompt may have zero or more associated arguments. Each argument must be registered before the prompt it will be associated with. Each argument requires a Name and a Required boolean indicating if that argument is required.

// Define argument schema. server.RegisterPromptArg("code", true); server.RegisterPromptArg("language", false); // Register the prompt. string name = "explain-code"; string description = "Explain how code works"; server.RegisterPrompt(name, description);

Handling Prompt Requests

When a user selects a prompt, the client notifies the server, causing the on_prompt_request event to be fired. This event includes the Name of the requested prompt, allowing the server to determine the correct response to be sent using the add_prompt_message method. Any related prompt arguments may also be retrieved by their associated name using the get_prompt_param_value method.

server.OnPromptRequest += (s, e) => { // Retrieve runtime values sent by client. string code = server.GetPromptParamValue("code"); string language = server.GetPromptParamValue("language") ?? "Unknown"; // Build response messages. // Assuming the client sent 'a = 1 + 2;' for the 'code' argument, and 'python' for the 'language' argument. server.AddPromptMessage((int)TRoles.rtAssistant, "Don't add comments."); server.AddPromptMessage((int)TRoles.rtUser, $"Explain how this {language} code works:\n\n{code}"); };

Resources

Resources provide persistent, read-only content that can be requested once by the user and reused throughout the session. These are typically static files such as documentation, source code, or other reference materials that help provide context for LLM interactions.

Registering Resources

Resources must be registered with the server via the register_resource method to be exposed to the client. Each registration requires a unique Uri, a short display Name, and a natural language Description.

server.RegisterResource("file://server.cs", "Server Demo", "The source code for a simple MCP SDK Server Demo");

Handling Resource Requests

When a user requests a resource, the on_resource_request event is fired. This event includes the Uri of the requested resource, allowing the server to locate and load the correct resource using the add_resource_content method. The client will manage the resource afterward, making it available for reuse as needed.

server.OnResourceRequest += (s, e) => { string fileName = e.Uri.Substring("file://".Length); if (File.Exists(fileName)) { string content = File.ReadAllText(fileName); server.AddResourceContent(e.Uri, content, "text/plain"); } };

Property List


The following is the full list of the properties of the class with short descriptions. Click on the links for further details.

listeningWhether the class is listening for incoming connections.
processing_modeThe mode in which the class will be hosted.
prompt_countThe number of records in the Prompt arrays.
prompt_descriptionThe brief, human-readable description of what the prompt does.
prompt_nameThe unique name associated with the prompt.
registered_prompt_arg_countThe number of records in the RegisteredPromptArg arrays.
registered_prompt_arg_descriptionThe brief, human-readable description of what information should be provided to this argument.
registered_prompt_arg_nameThe unique name associated with the prompt argument.
registered_prompt_arg_requiredWhether the prompt argument must be supplied by the client when requesting the prompt.
registered_tool_param_countThe number of records in the RegisteredToolParam arrays.
registered_tool_param_param_typeThe type of data associated with the tool parameter.
registered_tool_param_valueThe value associated with the tool parameter.
requestThe body of the HTTP request to be processed by the class.
request_headersThe full set of headers of the HTTP request to be processed by the class.
resource_countThe number of records in the Resource arrays.
resource_descriptionThe brief, human-readable description of the purpose of the resource as well as appropriate use cases.
resource_mimetypeThe media type of the resource content.
resource_nameThe display name associated with the resource.
resource_sizeThe size of the resource content, in bytes.
resource_uriThe unique resource identifier associated with the resource.
responseThe body of the HTTP response generated after processing a request with the class.
response_headersThe full set of headers of the HTTP response generated after processing a request with the class.
sampling_message_countThe number of records in the SamplingMessage arrays.
sampling_message_roleThe speaker or author of the message.
sampling_message_textThe instruction that can be passed into the client's language model.
server_cert_effective_dateThe date on which this certificate becomes valid.
server_cert_expiration_dateThe date on which the certificate expires.
server_cert_extended_key_usageA comma-delimited list of extended key usage identifiers.
server_cert_fingerprintThe hex-encoded, 16-byte MD5 fingerprint of the certificate.
server_cert_fingerprint_sha1The hex-encoded, 20-byte SHA-1 fingerprint of the certificate.
server_cert_fingerprint_sha256The hex-encoded, 32-byte SHA-256 fingerprint of the certificate.
server_cert_issuerThe issuer of the certificate.
server_cert_private_keyThe private key of the certificate (if available).
server_cert_private_key_availableWhether a PrivateKey is available for the selected certificate.
server_cert_private_key_containerThe name of the PrivateKey container for the certificate (if available).
server_cert_public_keyThe public key of the certificate.
server_cert_public_key_algorithmThe textual description of the certificate's public key algorithm.
server_cert_public_key_lengthThe length of the certificate's public key (in bits).
server_cert_serial_numberThe serial number of the certificate encoded as a string.
server_cert_signature_algorithmThe text description of the certificate's signature algorithm.
server_cert_storeThe name of the certificate store for the client certificate.
server_cert_store_passwordIf the type of certificate store requires a password, this property is used to specify the password needed to open the certificate store.
server_cert_store_typeThe type of certificate store for this certificate.
server_cert_subject_alt_namesComma-separated lists of alternative subject names for the certificate.
server_cert_thumbprint_md5The MD5 hash of the certificate.
server_cert_thumbprint_sha1The SHA-1 hash of the certificate.
server_cert_thumbprint_sha256The SHA-256 hash of the certificate.
server_cert_usageThe text description of UsageFlags .
server_cert_usage_flagsThe flags that show intended use for the certificate.
server_cert_versionThe certificate's version number.
server_cert_subjectThe subject of the certificate used for client authentication.
server_cert_encodedThe certificate (PEM/Base64 encoded).
server_settings_allowed_auth_methodsSpecifies the authentication schemes that the class will allow.
server_settings_local_hostSpecifies the name of the local host or user-assigned IP interface through which connections are initiated or accepted.
server_settings_local_portIncludes the Transmission Control Protocol (TCP) port in the local host where the class listens.
server_settings_timeoutSpecifies the timeout in seconds for the class.
system_promptAn instruction sent to the client's language model to influence its behavior during a sampling request.
tool_countThe number of records in the Tool arrays.
tool_descriptionThe brief, human-readable description of what the tool does.
tool_nameThe unique name associated with the tool.
transportThe transport mechanism used for communication.

Method List


The following is the full list of the methods of the class with short descriptions. Click on the links for further details.

add_prompt_messageAdds a prompt message to be returned during a prompt request.
add_resource_contentAdds data to be returned during a resource request.
add_tool_messageAdds a tool message to be returned during a tool request.
configSets or retrieves a configuration setting.
do_eventsProcesses events from the internal queue.
get_prompt_param_valueRetrieves the value of an existing prompt parameter.
get_tool_param_valueRetrieves the value of an existing tool parameter.
process_requestProcesses the request and sends the result.
process_requestsInstructs the class to start processing incoming requests.
register_promptRegisters a prompt that can be requested by the client.
register_prompt_argRegisters an argument for a prompt.
register_resourceRegisters a resource that can be requested by the client.
register_toolRegisters a tool that can be requested by the client.
register_tool_paramRegisters a parameter for a tool.
send_sampling_requestRequests language model reasoning from the client.
start_listeningInstructs the class to start listening for incoming connections.
stop_listeningInstructs the class to stop listening for new connections.
unregister_promptUnregisters an existing prompt.
unregister_resourceUnregisters an existing resource.
unregister_toolUnregisters an existing tool.

Event List


The following is the full list of the events fired by the class with short descriptions. Click on the links for further details.

on_errorFires when an error occurs during operation.
on_logFires once for each log message.
on_prompt_requestFires when a prompt is requested by the client.
on_resource_requestFires when a resource is requested by the client.
on_session_endFires when the class ends a session.
on_session_startFires when the class starts a session.
on_tool_requestFires when a tool is requested by the client.

Config Settings


The following is a list of config settings for the class with short descriptions. Click on the links for further details.

LogLevelSpecifies the level of detail that is logged.
MaxTokensSpecifies the maximum number of tokens to generate when sampling the client's LLM.
PageSizePromptsSpecifies the page size to use when responding to prompt listing requests from the client.
PageSizeResourcesSpecifies the page size to use when responding to resource listing requests from the client.
PageSizeToolsSpecifies the page size to use when responding to tool listing requests from the client.
BuildInfoInformation about the product's build.
CodePageThe system code page used for Unicode to Multibyte translations.
LicenseInfoInformation about the current license.
MaskSensitiveDataWhether sensitive data is masked in log messages.
ProcessIdleEventsWhether the class uses its internal event loop to process events when the main thread is idle.
SelectWaitMillisThe length of time in milliseconds the class will wait when DoEvents is called if there are no events to process.
UseInternalSecurityAPIWhether or not to use the system security libraries or an internal implementation.

listening property

Whether the class is listening for incoming connections.

Syntax

def get_listening() -> bool: ...

listening = property(get_listening, None)

Default Value

FALSE

Remarks

When the transport property is set to ttStdio, or it is set to ttHTTP and the processing_mode property is set to modeEmbeddedServer, this property indicates whether the class is listening for connections on the port specified by the property.

The start_listening and stop_listening methods can be used to control whether the class is listening.

This property is read-only.

processing_mode property

The mode in which the class will be hosted.

Syntax

def get_processing_mode() -> int: ...
def set_processing_mode(value: int) -> None: ...

processing_mode = property(get_processing_mode, set_processing_mode)

Possible Values

0   # EmbeddedServer
1 # ExternalServer
2 # Offline

Default Value

0

Remarks

When the transport property is set to ttHTTP, this property governs whether the class operates via the embedded HTTP server, an external server, or in a fully-offline mode. Possible values are as follows:

  • modeEmbeddedServer (0, default): Uses the embedded server.
  • modeExternalServer (1): Uses an external server framework.
  • modeOffline (2): Uses offline processing.

Please refer to the Hosting Options pages to learn more about the different processing modes and how they relate to configuring a host server.

prompt_count property

The number of records in the Prompt arrays.

Syntax

def get_prompt_count() -> int: ...

prompt_count = property(get_prompt_count, None)

Default Value

0

Remarks

This property controls the size of the following arrays:

The array indices start at 0 and end at prompt_count - 1.

This property is read-only.

prompt_description property

The brief, human-readable description of what the prompt does.

Syntax

def get_prompt_description(prompt_index: int) -> str: ...

Default Value

""

Remarks

The brief, human-readable description of what the prompt does.

This property holds a brief, human-readable description of what the prompt does, which is critical in helping the client to understand the purpose and functionality of the prompt.

The prompt_index parameter specifies the index of the item in the array. The size of the array is controlled by the prompt_count property.

This property is read-only.

prompt_name property

The unique name associated with the prompt.

Syntax

def get_prompt_name(prompt_index: int) -> str: ...

Default Value

""

Remarks

The unique name associated with the prompt.

This property identifies the unique name associated with the prompt.

The prompt_index parameter specifies the index of the item in the array. The size of the array is controlled by the prompt_count property.

This property is read-only.

registered_prompt_arg_count property

The number of records in the RegisteredPromptArg arrays.

Syntax

def get_registered_prompt_arg_count() -> int: ...
def set_registered_prompt_arg_count(value: int) -> None: ...

registered_prompt_arg_count = property(get_registered_prompt_arg_count, set_registered_prompt_arg_count)

Default Value

0

Remarks

This property controls the size of the following arrays:

The array indices start at 0 and end at registered_prompt_arg_count - 1.

registered_prompt_arg_description property

The brief, human-readable description of what information should be provided to this argument.

Syntax

def get_registered_prompt_arg_description(registered_prompt_arg_index: int) -> str: ...
def set_registered_prompt_arg_description(registered_prompt_arg_index: int, value: str) -> None: ...

Default Value

""

Remarks

The brief, human-readable description of what information should be provided to this argument.

This property holds a brief, human-readable description of what information should be provided to this argument.

The registered_prompt_arg_index parameter specifies the index of the item in the array. The size of the array is controlled by the registered_prompt_arg_count property.

registered_prompt_arg_name property

The unique name associated with the prompt argument.

Syntax

def get_registered_prompt_arg_name(registered_prompt_arg_index: int) -> str: ...
def set_registered_prompt_arg_name(registered_prompt_arg_index: int, value: str) -> None: ...

Default Value

""

Remarks

The unique name associated with the prompt argument.

This property identifies the unique name associated with the prompt argument.

The registered_prompt_arg_index parameter specifies the index of the item in the array. The size of the array is controlled by the registered_prompt_arg_count property.

registered_prompt_arg_required property

Whether the prompt argument must be supplied by the client when requesting the prompt.

Syntax

def get_registered_prompt_arg_required(registered_prompt_arg_index: int) -> bool: ...
def set_registered_prompt_arg_required(registered_prompt_arg_index: int, value: bool) -> None: ...

Default Value

TRUE

Remarks

Whether the prompt argument must be supplied by the client when requesting the prompt.

This property indicates whether the prompt argument must be supplied by the client when requesting the prompt.

The registered_prompt_arg_index parameter specifies the index of the item in the array. The size of the array is controlled by the registered_prompt_arg_count property.

registered_tool_param_count property

The number of records in the RegisteredToolParam arrays.

Syntax

def get_registered_tool_param_count() -> int: ...
def set_registered_tool_param_count(value: int) -> None: ...

registered_tool_param_count = property(get_registered_tool_param_count, set_registered_tool_param_count)

Default Value

0

Remarks

This property controls the size of the following arrays:

The array indices start at 0 and end at registered_tool_param_count - 1.

registered_tool_param_param_type property

The type of data associated with the tool parameter.

Syntax

def get_registered_tool_param_param_type(registered_tool_param_index: int) -> int: ...
def set_registered_tool_param_param_type(registered_tool_param_index: int, value: int) -> None: ...

Possible Values

0   # String
1 # Number
2 # Bool
3 # Array
4 # Object

Default Value

0

Remarks

The type of data associated with the tool parameter.

This property indicates the type of data associated with the tool parameter.

Valid data types include:

  • 0 (ptString)
  • 1 (ptNumber)
  • 2 (ptBool)
  • 3 (ptArray)
  • 4 (ptObject)

The registered_tool_param_index parameter specifies the index of the item in the array. The size of the array is controlled by the registered_tool_param_count property.

registered_tool_param_value property

The value associated with the tool parameter.

Syntax

def get_registered_tool_param_value(registered_tool_param_index: int) -> str: ...
def set_registered_tool_param_value(registered_tool_param_index: int, value: str) -> None: ...

Default Value

""

Remarks

The value associated with the tool parameter.

This property contains the value associated with the tool parameter.

The registered_tool_param_index parameter specifies the index of the item in the array. The size of the array is controlled by the registered_tool_param_count property.

request property

The body of the HTTP request to be processed by the class.

Syntax

def get_request() -> bytes: ...
def set_request(value: bytes) -> None: ...

request = property(get_request, set_request)

Default Value

""

Remarks

When the transport property is set to ttHTTP and the processing_mode property is set to modeOffline, the class processes inbound HTTP requests via this property and the request_headers property.

After setting this property to the full body content of the HTTP request, as well as setting any headers in the request_headers property, the class will begin processing the request when the process_request method is called.

request_headers property

The full set of headers of the HTTP request to be processed by the class.

Syntax

def get_request_headers() -> str: ...
def set_request_headers(value: str) -> None: ...

request_headers = property(get_request_headers, set_request_headers)

Default Value

""

Remarks

When the transport property is set to ttHTTP and the processing_mode property is set to modeOffline, the class processes inbound HTTP requests via this property and the request property.

After setting this property to the header content of the HTTP request, as well as setting the body content in the request property, the class will begin processing the request when the process_request method is called.

resource_count property

The number of records in the Resource arrays.

Syntax

def get_resource_count() -> int: ...

resource_count = property(get_resource_count, None)

Default Value

0

Remarks

This property controls the size of the following arrays:

The array indices start at 0 and end at resource_count - 1.

This property is read-only.

resource_description property

The brief, human-readable description of the purpose of the resource as well as appropriate use cases.

Syntax

def get_resource_description(resource_index: int) -> str: ...

Default Value

""

Remarks

The brief, human-readable description of the purpose of the resource as well as appropriate use cases.

This property holds a brief, human-readable description of the purpose of the resource as well as appropriate use cases.

The resource_index parameter specifies the index of the item in the array. The size of the array is controlled by the resource_count property.

This property is read-only.

resource_mimetype property

The media type of the resource content.

Syntax

def get_resource_mimetype(resource_index: int) -> str: ...

Default Value

""

Remarks

The media type of the resource content.

This property holds the media type of resource content (e.g., text/plain, image/png, etc.) and helps clients interpret the resource correctly and determine how it should be processed or displayed.

The resource_index parameter specifies the index of the item in the array. The size of the array is controlled by the resource_count property.

This property is read-only.

resource_name property

The display name associated with the resource.

Syntax

def get_resource_name(resource_index: int) -> str: ...

Default Value

""

Remarks

The display name associated with the resource.

This property indicates the display associated with the resource that is shown to end users by the client.

The resource_index parameter specifies the index of the item in the array. The size of the array is controlled by the resource_count property.

This property is read-only.

resource_size property

The size of the resource content, in bytes.

Syntax

def get_resource_size(resource_index: int) -> int: ...

Default Value

0

Remarks

The size of the resource content, in bytes.

This property indicates the size of the resource content, in bytes.

The resource_index parameter specifies the index of the item in the array. The size of the array is controlled by the resource_count property.

This property is read-only.

resource_uri property

The unique resource identifier associated with the resource.

Syntax

def get_resource_uri(resource_index: int) -> str: ...

Default Value

""

Remarks

The unique resource identifier associated with the resource.

This property identifies the unique resource identifier associated with the resource.

The resource_index parameter specifies the index of the item in the array. The size of the array is controlled by the resource_count property.

This property is read-only.

response property

The body of the HTTP response generated after processing a request with the class.

Syntax

def get_response() -> bytes: ...
def set_response(value: bytes) -> None: ...

response = property(get_response, set_response)

Default Value

""

Remarks

When the transport property is set to ttHTTP and the processing_mode property is set to modeOffline, this property holds the body of the HTTP response that was generated as a result of calling the process_request method.

Note that this response is not sent to a client, and instead the class simply populates this property along with the response_headers property.

response_headers property

The full set of headers of the HTTP response generated after processing a request with the class.

Syntax

def get_response_headers() -> str: ...
def set_response_headers(value: str) -> None: ...

response_headers = property(get_response_headers, set_response_headers)

Default Value

""

Remarks

When the transport property is set to ttHTTP and the processing_mode property is set to modeOffline, this property holds the headers of the HTTP response that was generated as a result of calling the process_request method.

Note that this response is not sent to a client, and instead the class simply populates this property along with the response property.

sampling_message_count property

The number of records in the SamplingMessage arrays.

Syntax

def get_sampling_message_count() -> int: ...
def set_sampling_message_count(value: int) -> None: ...

sampling_message_count = property(get_sampling_message_count, set_sampling_message_count)

Default Value

0

Remarks

This property controls the size of the following arrays:

The array indices start at 0 and end at sampling_message_count - 1.

sampling_message_role property

The speaker or author of the message.

Syntax

def get_sampling_message_role(sampling_message_index: int) -> int: ...

Possible Values

0   # User
1 # Assistant

Default Value

0

Remarks

The speaker or author of the message.

This property indicates who authored each message and helps provide conversational context to language models. Valid roles include:

0 (rtUser) Message from the end user requesting assistance.
1 (rtAssistant) Message from the client providing responses.

The sampling_message_index parameter specifies the index of the item in the array. The size of the array is controlled by the sampling_message_count property.

This property is read-only.

sampling_message_text property

The instruction that can be passed into the client's language model.

Syntax

def get_sampling_message_text(sampling_message_index: int) -> str: ...
def set_sampling_message_text(sampling_message_index: int, value: str) -> None: ...

Default Value

""

Remarks

The instruction that can be passed into the client's language model.

This property contains natural language describing an instruction that can be passed into the client's language model (e.g., Review python code, Summarize an article, or Provide an example of using the /n software MCP SDK).

The sampling_message_index parameter specifies the index of the item in the array. The size of the array is controlled by the sampling_message_count property.

server_cert_effective_date property

The date on which this certificate becomes valid.

Syntax

def get_server_cert_effective_date() -> str: ...

server_cert_effective_date = property(get_server_cert_effective_date, None)

Default Value

""

Remarks

The date on which this certificate becomes valid. Before this date, it is not valid. The date is localized to the system's time zone. The following example illustrates the format of an encoded date:

23-Jan-2000 15:00:00.

This property is read-only.

server_cert_expiration_date property

The date on which the certificate expires.

Syntax

def get_server_cert_expiration_date() -> str: ...

server_cert_expiration_date = property(get_server_cert_expiration_date, None)

Default Value

""

Remarks

The date on which the certificate expires. After this date, the certificate will no longer be valid. The date is localized to the system's time zone. The following example illustrates the format of an encoded date:

23-Jan-2001 15:00:00.

This property is read-only.

server_cert_extended_key_usage property

A comma-delimited list of extended key usage identifiers.

Syntax

def get_server_cert_extended_key_usage() -> str: ...

server_cert_extended_key_usage = property(get_server_cert_extended_key_usage, None)

Default Value

""

Remarks

A comma-delimited list of extended key usage identifiers. These are the same as ASN.1 object identifiers (OIDs).

This property is read-only.

server_cert_fingerprint property

The hex-encoded, 16-byte MD5 fingerprint of the certificate.

Syntax

def get_server_cert_fingerprint() -> str: ...

server_cert_fingerprint = property(get_server_cert_fingerprint, None)

Default Value

""

Remarks

The hex-encoded, 16-byte MD5 fingerprint of the certificate. This property is primarily used for keys which do not have a corresponding X.509 public certificate, such as PEM keys that only contain a private key. It is commonly used for SSH keys.

The following example illustrates the format: bc:2a:72:af:fe:58:17:43:7a:5f:ba:5a:7c:90:f7:02

This property is read-only.

server_cert_fingerprint_sha1 property

The hex-encoded, 20-byte SHA-1 fingerprint of the certificate.

Syntax

def get_server_cert_fingerprint_sha1() -> str: ...

server_cert_fingerprint_sha1 = property(get_server_cert_fingerprint_sha1, None)

Default Value

""

Remarks

The hex-encoded, 20-byte SHA-1 fingerprint of the certificate. This property is primarily used for keys which do not have a corresponding X.509 public certificate, such as PEM keys that only contain a private key. It is commonly used for SSH keys.

The following example illustrates the format: 30:7b:fa:38:65:83:ff:da:b4:4e:07:3f:17:b8:a4:ed:80:be:ff:84

This property is read-only.

server_cert_fingerprint_sha256 property

The hex-encoded, 32-byte SHA-256 fingerprint of the certificate.

Syntax

def get_server_cert_fingerprint_sha256() -> str: ...

server_cert_fingerprint_sha256 = property(get_server_cert_fingerprint_sha256, None)

Default Value

""

Remarks

The hex-encoded, 32-byte SHA-256 fingerprint of the certificate. This property is primarily used for keys which do not have a corresponding X.509 public certificate, such as PEM keys that only contain a private key. It is commonly used for SSH keys.

The following example illustrates the format: 6a:80:5c:33:a9:43:ea:b0:96:12:8a:64:96:30:ef:4a:8a:96:86:ce:f4:c7:be:10:24:8e:2b:60:9e:f3:59:53

This property is read-only.

server_cert_issuer property

The issuer of the certificate.

Syntax

def get_server_cert_issuer() -> str: ...

server_cert_issuer = property(get_server_cert_issuer, None)

Default Value

""

Remarks

The issuer of the certificate. This property contains a string representation of the name of the issuing authority for the certificate.

This property is read-only.

server_cert_private_key property

The private key of the certificate (if available).

Syntax

def get_server_cert_private_key() -> str: ...

server_cert_private_key = property(get_server_cert_private_key, None)

Default Value

""

Remarks

The private key of the certificate (if available). The key is provided as PEM/Base64-encoded data.

NOTE: The server_cert_private_key may be available but not exportable. In this case, server_cert_private_key returns an empty string.

This property is read-only.

server_cert_private_key_available property

Whether a PrivateKey is available for the selected certificate.

Syntax

def get_server_cert_private_key_available() -> bool: ...

server_cert_private_key_available = property(get_server_cert_private_key_available, None)

Default Value

FALSE

Remarks

Whether a server_cert_private_key is available for the selected certificate. If server_cert_private_key_available is True, the certificate may be used for authentication purposes (e.g., server authentication).

This property is read-only.

server_cert_private_key_container property

The name of the PrivateKey container for the certificate (if available).

Syntax

def get_server_cert_private_key_container() -> str: ...

server_cert_private_key_container = property(get_server_cert_private_key_container, None)

Default Value

""

Remarks

The name of the server_cert_private_key container for the certificate (if available). This functionality is available only on Windows platforms.

This property is read-only.

server_cert_public_key property

The public key of the certificate.

Syntax

def get_server_cert_public_key() -> str: ...

server_cert_public_key = property(get_server_cert_public_key, None)

Default Value

""

Remarks

The public key of the certificate. The key is provided as PEM/Base64-encoded data.

This property is read-only.

server_cert_public_key_algorithm property

The textual description of the certificate's public key algorithm.

Syntax

def get_server_cert_public_key_algorithm() -> str: ...

server_cert_public_key_algorithm = property(get_server_cert_public_key_algorithm, None)

Default Value

""

Remarks

The textual description of the certificate's public key algorithm. The property contains either the name of the algorithm (e.g., "RSA" or "RSA_DH") or an object identifier (OID) string representing the algorithm.

This property is read-only.

server_cert_public_key_length property

The length of the certificate's public key (in bits).

Syntax

def get_server_cert_public_key_length() -> int: ...

server_cert_public_key_length = property(get_server_cert_public_key_length, None)

Default Value

0

Remarks

The length of the certificate's public key (in bits). Common values are 512, 1024, and 2048.

This property is read-only.

server_cert_serial_number property

The serial number of the certificate encoded as a string.

Syntax

def get_server_cert_serial_number() -> str: ...

server_cert_serial_number = property(get_server_cert_serial_number, None)

Default Value

""

Remarks

The serial number of the certificate encoded as a string. The number is encoded as a series of hexadecimal digits, with each pair representing a byte of the serial number.

This property is read-only.

server_cert_signature_algorithm property

The text description of the certificate's signature algorithm.

Syntax

def get_server_cert_signature_algorithm() -> str: ...

server_cert_signature_algorithm = property(get_server_cert_signature_algorithm, None)

Default Value

""

Remarks

The text description of the certificate's signature algorithm. The property contains either the name of the algorithm (e.g., "RSA" or "RSA_MD5RSA") or an object identifier (OID) string representing the algorithm.

This property is read-only.

server_cert_store property

The name of the certificate store for the client certificate.

Syntax

def get_server_cert_store() -> bytes: ...
def set_server_cert_store(value: bytes) -> None: ...

server_cert_store = property(get_server_cert_store, set_server_cert_store)

Default Value

"MY"

Remarks

The name of the certificate store for the client certificate.

The server_cert_store_type property denotes the type of the certificate store specified by server_cert_store. If the store is password-protected, specify the password in server_cert_store_password.

server_cert_store is used in conjunction with the server_cert_subject property to specify client certificates. If server_cert_store has a value, and server_cert_subject or server_cert_encoded is set, a search for a certificate is initiated. Please see the server_cert_subject property for details.

Designations of certificate stores are platform dependent.

The following designations are the most common User and Machine certificate stores in Windows:

MYA certificate store holding personal certificates with their associated private keys.
CACertifying authority certificates.
ROOTRoot certificates.

When the certificate store type is cstPFXFile, this property must be set to the name of the file. When the type is cstPFXBlob, the property must be set to the binary contents of a PFX file (i.e., PKCS#12 certificate store).

server_cert_store_password property

If the type of certificate store requires a password, this property is used to specify the password needed to open the certificate store.

Syntax

def get_server_cert_store_password() -> str: ...
def set_server_cert_store_password(value: str) -> None: ...

server_cert_store_password = property(get_server_cert_store_password, set_server_cert_store_password)

Default Value

""

Remarks

If the type of certificate store requires a password, this property is used to specify the password needed to open the certificate store.

server_cert_store_type property

The type of certificate store for this certificate.

Syntax

def get_server_cert_store_type() -> int: ...
def set_server_cert_store_type(value: int) -> None: ...

server_cert_store_type = property(get_server_cert_store_type, set_server_cert_store_type)

Possible Values

0   # User
1 # Machine
2 # PFXFile
3 # PFXBlob
4 # JKSFile
5 # JKSBlob
6 # PEMKeyFile
7 # PEMKeyBlob
8 # PublicKeyFile
9 # PublicKeyBlob
10 # SSHPublicKeyBlob
11 # P7BFile
12 # P7BBlob
13 # SSHPublicKeyFile
14 # PPKFile
15 # PPKBlob
16 # XMLFile
17 # XMLBlob
18 # JWKFile
19 # JWKBlob
20 # SecurityKey
21 # BCFKSFile
22 # BCFKSBlob
23 # PKCS11
99 # Auto

Default Value

0

Remarks

The type of certificate store for this certificate.

The class supports both public and private keys in a variety of formats. When the cstAuto value is used, the class will automatically determine the type. This property can take one of the following values:

0 (cstUser - default)For Windows, this specifies that the certificate store is a certificate store owned by the current user.

NOTE: This store type is not available in Java.

1 (cstMachine)For Windows, this specifies that the certificate store is a machine store.

NOTE: This store type is not available in Java.

2 (cstPFXFile)The certificate store is the name of a PFX (PKCS#12) file containing certificates.
3 (cstPFXBlob)The certificate store is a string (binary or Base64-encoded) representing a certificate store in PFX (PKCS#12) format.
4 (cstJKSFile)The certificate store is the name of a Java Key Store (JKS) file containing certificates.

NOTE: This store type is only available in Java.

5 (cstJKSBlob)The certificate store is a string (binary or Base64-encoded) representing a certificate store in Java Key Store (JKS) format.

NOTE: This store type is only available in Java.

6 (cstPEMKeyFile)The certificate store is the name of a PEM-encoded file that contains a private key and an optional certificate.
7 (cstPEMKeyBlob)The certificate store is a string (binary or Base64-encoded) that contains a private key and an optional certificate.
8 (cstPublicKeyFile)The certificate store is the name of a file that contains a PEM- or DER-encoded public key certificate.
9 (cstPublicKeyBlob)The certificate store is a string (binary or Base64-encoded) that contains a PEM- or DER-encoded public key certificate.
10 (cstSSHPublicKeyBlob)The certificate store is a string (binary or Base64-encoded) that contains an SSH-style public key.
11 (cstP7BFile)The certificate store is the name of a PKCS#7 file containing certificates.
12 (cstP7BBlob)The certificate store is a string (binary) representing a certificate store in PKCS#7 format.
13 (cstSSHPublicKeyFile)The certificate store is the name of a file that contains an SSH-style public key.
14 (cstPPKFile)The certificate store is the name of a file that contains a PPK (PuTTY Private Key).
15 (cstPPKBlob)The certificate store is a string (binary) that contains a PPK (PuTTY Private Key).
16 (cstXMLFile)The certificate store is the name of a file that contains a certificate in XML format.
17 (cstXMLBlob)The certificate store is a string that contains a certificate in XML format.
18 (cstJWKFile)The certificate store is the name of a file that contains a JWK (JSON Web Key).
19 (cstJWKBlob)The certificate store is a string that contains a JWK (JSON Web Key).
21 (cstBCFKSFile)The certificate store is the name of a file that contains a BCFKS (Bouncy Castle FIPS Key Store).

NOTE: This store type is only available in Java and .NET.

22 (cstBCFKSBlob)The certificate store is a string (binary or Base64-encoded) representing a certificate store in BCFKS (Bouncy Castle FIPS Key Store) format.

NOTE: This store type is only available in Java and .NET.

23 (cstPKCS11)The certificate is present on a physical security key accessible via a PKCS#11 interface.

To use a security key, the necessary data must first be collected using the CertMgr class. The list_store_certificates method may be called after setting cert_store_type to cstPKCS11, cert_store_password to the PIN, and cert_store to the full path of the PKCS#11 DLL. The certificate information returned in the on_cert_list event's CertEncoded parameter may be saved for later use.

When using a certificate, pass the previously saved security key information as the server_cert_store and set server_cert_store_password to the PIN.

Code Example. SSH Authentication with Security Key: certmgr.CertStoreType = CertStoreTypes.cstPKCS11; certmgr.OnCertList += (s, e) => { secKeyBlob = e.CertEncoded; }; certmgr.CertStore = @"C:\Program Files\OpenSC Project\OpenSC\pkcs11\opensc-pkcs11.dll"; certmgr.CertStorePassword = "123456"; //PIN certmgr.ListStoreCertificates(); sftp.SSHCert = new Certificate(CertStoreTypes.cstPKCS11, secKeyBlob, "123456", "*"); sftp.SSHUser = "test"; sftp.SSHLogon("myhost", 22);

99 (cstAuto)The store type is automatically detected from the input data. This setting may be used with both public and private keys and can detect any of the supported formats automatically.

server_cert_subject_alt_names property

Comma-separated lists of alternative subject names for the certificate.

Syntax

def get_server_cert_subject_alt_names() -> str: ...

server_cert_subject_alt_names = property(get_server_cert_subject_alt_names, None)

Default Value

""

Remarks

Comma-separated lists of alternative subject names for the certificate.

This property is read-only.

server_cert_thumbprint_md5 property

The MD5 hash of the certificate.

Syntax

def get_server_cert_thumbprint_md5() -> str: ...

server_cert_thumbprint_md5 = property(get_server_cert_thumbprint_md5, None)

Default Value

""

Remarks

The MD5 hash of the certificate. It is primarily used for X.509 certificates. If the hash does not already exist, it is automatically computed.

This property is read-only.

server_cert_thumbprint_sha1 property

The SHA-1 hash of the certificate.

Syntax

def get_server_cert_thumbprint_sha1() -> str: ...

server_cert_thumbprint_sha1 = property(get_server_cert_thumbprint_sha1, None)

Default Value

""

Remarks

The SHA-1 hash of the certificate. It is primarily used for X.509 certificates. If the hash does not already exist, it is automatically computed.

This property is read-only.

server_cert_thumbprint_sha256 property

The SHA-256 hash of the certificate.

Syntax

def get_server_cert_thumbprint_sha256() -> str: ...

server_cert_thumbprint_sha256 = property(get_server_cert_thumbprint_sha256, None)

Default Value

""

Remarks

The SHA-256 hash of the certificate. It is primarily used for X.509 certificates. If the hash does not already exist, it is automatically computed.

This property is read-only.

server_cert_usage property

The text description of UsageFlags .

Syntax

def get_server_cert_usage() -> str: ...

server_cert_usage = property(get_server_cert_usage, None)

Default Value

""

Remarks

The text description of server_cert_usage_flags.

This value will be one or more of the following strings and will be separated by commas:

  • Digital Signature
  • Non-Repudiation
  • Key Encipherment
  • Data Encipherment
  • Key Agreement
  • Certificate Signing
  • CRL Signing
  • Encipher Only

If the provider is OpenSSL, the value is a comma-separated list of X.509 certificate extension names.

This property is read-only.

server_cert_usage_flags property

The flags that show intended use for the certificate.

Syntax

def get_server_cert_usage_flags() -> int: ...

server_cert_usage_flags = property(get_server_cert_usage_flags, None)

Default Value

0

Remarks

The flags that show intended use for the certificate. The value of server_cert_usage_flags is a combination of the following flags:

0x80Digital Signature
0x40Non-Repudiation
0x20Key Encipherment
0x10Data Encipherment
0x08Key Agreement
0x04Certificate Signing
0x02CRL Signing
0x01Encipher Only

Please see the server_cert_usage property for a text representation of server_cert_usage_flags.

This functionality currently is not available when the provider is OpenSSL.

This property is read-only.

server_cert_version property

The certificate's version number.

Syntax

def get_server_cert_version() -> str: ...

server_cert_version = property(get_server_cert_version, None)

Default Value

""

Remarks

The certificate's version number. The possible values are the strings "V1", "V2", and "V3".

This property is read-only.

server_cert_subject property

The subject of the certificate used for client authentication.

Syntax

def get_server_cert_subject() -> str: ...
def set_server_cert_subject(value: str) -> None: ...

server_cert_subject = property(get_server_cert_subject, set_server_cert_subject)

Default Value

""

Remarks

The subject of the certificate used for client authentication.

This property must be set after all other certificate properties are set. When this property is set, a search is performed in the current certificate store to locate a certificate with a matching subject.

If a matching certificate is found, the property is set to the full subject of the matching certificate.

If an exact match is not found, the store is searched for subjects containing the value of the property.

If a match is still not found, the property is set to an empty string, and no certificate is selected.

The special value "*" picks a random certificate in the certificate store.

The certificate subject is a comma-separated list of distinguished name fields and values. For instance, "CN=www.server.com, OU=test, C=US, E=example@email.com". Common fields and their meanings are as follows:

FieldMeaning
CNCommon Name. This is commonly a hostname like www.server.com.
OOrganization
OUOrganizational Unit
LLocality
SState
CCountry
EEmail Address

If a field value contains a comma, it must be quoted.

server_cert_encoded property

The certificate (PEM/Base64 encoded).

Syntax

def get_server_cert_encoded() -> bytes: ...
def set_server_cert_encoded(value: bytes) -> None: ...

server_cert_encoded = property(get_server_cert_encoded, set_server_cert_encoded)

Default Value

""

Remarks

The certificate (PEM/Base64 encoded). This property is used to assign a specific certificate. The server_cert_store and server_cert_subject properties also may be used to specify a certificate.

When server_cert_encoded is set, a search is initiated in the current server_cert_store for the private key of the certificate. If the key is found, server_cert_subject is updated to reflect the full subject of the selected certificate; otherwise, server_cert_subject is set to an empty string.

server_settings_allowed_auth_methods property

Specifies the authentication schemes that the class will allow.

Syntax

def get_server_settings_allowed_auth_methods() -> str: ...
def set_server_settings_allowed_auth_methods(value: str) -> None: ...

server_settings_allowed_auth_methods = property(get_server_settings_allowed_auth_methods, set_server_settings_allowed_auth_methods)

Default Value

"Anonymous,Basic,Digest,NTLM,Negotiate"

Remarks

Specifies the authentication schemes that the class will allow.

This property must be set to a valid comma-separated string of authentication scheme values that the embedded server will allow. Possible values are as follows:

  • Anonymous: Unauthenticated connection requests will be allowed.
  • Basic: HTTP Basic authentication is allowed.
  • Digest: Digest authentication is allowed.
  • NTLM: NTLM authentication is allowed.
  • Negotiate: Windows Negotiate (Kerberos) authentication is allowed.

server_settings_local_host property

Specifies the name of the local host or user-assigned IP interface through which connections are initiated or accepted.

Syntax

def get_server_settings_local_host() -> str: ...
def set_server_settings_local_host(value: str) -> None: ...

server_settings_local_host = property(get_server_settings_local_host, set_server_settings_local_host)

Default Value

""

Remarks

Specifies the name of the local host or user-assigned IP interface through which connections are initiated or accepted.

This field contains the name of the local host as obtained by the gethostname() system call, or if the user has assigned an IP address, the value of that address.

In multihomed hosts (machines with more than one IP interface) setting LocalHost to the IP address of an interface will make the class initiate connections (or accept in the case of server classes) only through that interface. It is recommended to provide an IP address rather than a hostname when setting this field to ensure the desired interface is used.

If the class is connected, the server_settings_local_host field shows the IP address of the interface through which the connection is made in internet dotted format (aaa.bbb.ccc.ddd). In most cases, this is the address of the local host, except for multihomed hosts (machines with more than one IP interface).

NOTE: server_settings_local_host is not persistent. You must always set it in code, and never in the property window.

server_settings_local_port property

Includes the Transmission Control Protocol (TCP) port in the local host where the class listens.

Syntax

def get_server_settings_local_port() -> int: ...
def set_server_settings_local_port(value: int) -> None: ...

server_settings_local_port = property(get_server_settings_local_port, set_server_settings_local_port)

Default Value

0

Remarks

Includes the Transmission Control Protocol (TCP) port in the local host where the class listens.

This field must be set before the class can start listening. If this is set to 0, then the TCP/IP subsystem will pick a port number at random.

The service port is not shared among servers, so two classes cannot be listening on the same port at the same time.

server_settings_timeout property

Specifies the timeout in seconds for the class.

Syntax

def get_server_settings_timeout() -> int: ...
def set_server_settings_timeout(value: int) -> None: ...

server_settings_timeout = property(get_server_settings_timeout, set_server_settings_timeout)

Default Value

60

Remarks

Specifies the timeout in seconds for the class.

If this is set to 0, all operations will run uninterrupted until successful completion or an error condition is encountered.

If this is set to a positive value, the class will wait for the operation to complete before returning control.

If the timeout expires, and the operation is not yet complete, the class throws an exception.

Note that all timeouts are inactivity timeouts, meaning the timeout period is extended by the value specified in this property when any amount of data is successfully sent or received.

system_prompt property

An instruction sent to the client's language model to influence its behavior during a sampling request.

Syntax

def get_system_prompt() -> str: ...
def set_system_prompt(value: str) -> None: ...

system_prompt = property(get_system_prompt, set_system_prompt)

Default Value

""

Remarks

When the transport property is set to ttStdio, this property specifies an instruction sent to the client's language model to influence its behavior when the send_sampling_request method is called. It acts as high-level guidance or context for how the language model should interpret and respond to the messages in the sampling_messages properties.

Example: server.SystemPrompt = "You are an assistant meant to summarize text only using a formal tone."; SamplingMessage message = new SamplingMessage(); message.Role = TRoles.rtUser; message.Text = "Summarize the following text: " + text; server.SamplingMessages.Add(message); string result = server.SendSamplingRequest();

tool_count property

The number of records in the Tool arrays.

Syntax

def get_tool_count() -> int: ...

tool_count = property(get_tool_count, None)

Default Value

0

Remarks

This property controls the size of the following arrays:

The array indices start at 0 and end at tool_count - 1.

This property is read-only.

tool_description property

The brief, human-readable description of what the tool does.

Syntax

def get_tool_description(tool_index: int) -> str: ...

Default Value

""

Remarks

The brief, human-readable description of what the tool does.

This property holds a brief, human-readable description of what the tool does, which is critical in helping the client to understand when the tool should be invoked.

The tool_index parameter specifies the index of the item in the array. The size of the array is controlled by the tool_count property.

This property is read-only.

tool_name property

The unique name associated with the tool.

Syntax

def get_tool_name(tool_index: int) -> str: ...

Default Value

""

Remarks

The unique name associated with the tool.

This property identifies the unique name associated with the tool.

The tool_index parameter specifies the index of the item in the array. The size of the array is controlled by the tool_count property.

This property is read-only.

transport property

The transport mechanism used for communication.

Syntax

def get_transport() -> int: ...
def set_transport(value: int) -> None: ...

transport = property(get_transport, set_transport)

Possible Values

1   # Stdio
2 # HTTP

Default Value

1

Remarks

This property indicates whether the class operates via the standard input/output or HTTP transport mechanism. Possible values are as follows:

  • ttStdio (1, default): Enables communication through standard input and output streams, but the class is limited to serving a single client at once due to the server acting as a subprocess of a client application.
  • ttHTTP (2): Enables communication via HTTP requests and responses, and allows the class to serve multiple clients at once.

add_prompt_message method

Adds a prompt message to be returned during a prompt request.

Syntax

def add_prompt_message(role: int, text: str) -> None: ...

Remarks

This method is used to add a new prompt message to be passed back to the client during an ongoing prompt request. It may only be called from within the on_prompt_request event.

Role determines the message's origin and context within the conversation flow. Valid roles include:

0 (rtUser) Message from the end user requesting assistance.
1 (rtAssistant) Message from the client providing responses.

Text contains natural language describing the prompt that will be passed into the client's language model (e.g., Review python code, Summarize an article, or Provide an example of using the /n software MCP SDK).

Example: server.OnPromptRequest += (s, e) => { if (e.Name.Equals("Greeting")) { server.AddPromptMessage((int)TRoles.rtUser, "Hello!"); } };

Advanced Example: server.OnPromptRequest += (s, e) => { if (e.Name.Equals("Code Review")) { string code = server.GetPromptParamValue("code"); string language = server.GetPromptParamValue("language"); string reviewType = server.GetPromptParamValue("reviewType"); string instructions = "Please review the following " + language + " code."; if (!string.IsNullOrEmpty(reviewType)) { instructions += " focusing on " + reviewType; } instructions += ":"; server.AddPromptMessage((int)TRoles.rtUser, instructions); server.AddPromptMessage((int)TRoles.rtUser, code); } };

add_resource_content method

Adds data to be returned during a resource request.

Syntax

def add_resource_content(uri: str, text: str, mime_type: str) -> None: ...

Remarks

This method is used to add resource content to be passed back to the client during an ongoing resource request, providing the actual data that clients are requesting when they access a specific resource. It may only be called from within the on_resource_request event and may be called multiple times during the same resource request to provide multiple related resources or different versions of the same content.

Uri specifies the unique resource identifier that corresponds to the content being provided.

Text contains text data that will be included in the response for the ongoing resource request.

MimeType (e.g., text/plain or application/json) informs the client of how the data passed into Text should be interpreted and processed.

Example: server.OnResourceRequest += (s, e) => { string uri = e.Uri.ToString(); if (uri.StartsWith("file:///")) { string fileName = uri.Substring("file:///".Length).Replace('/', Path.DirectorySeparatorChar); string fullPath = Path.Combine(baseDir, fileName); if (File.Exists(fullPath)) { string data = File.ReadAllText(fullPath); server.AddResourceContent(uri, data, "text/plain"); } } };

Advanced Example server.OnResourceRequest += (s, e) => { string uri = e.Uri.ToString(); if (uri.StartsWith("file:///")) { string fileName = uri.Substring("file:///".Length).Replace('/', Path.DirectorySeparatorChar); string fullPath = Path.Combine(baseDir, fileName); string fileExtension = Path.GetExtension(fullPath).ToLower(); string mimeType = GetMimeType(fileExtension); if (IsImageFile(fileExtension)) { // Handle image files. byte[] imageBytes = File.ReadAllBytes(fullPath); string base64Image = Convert.ToBase64String(imageBytes); server.AddResourceContent(uri, base64Image, mimeType); } else { // Handle text files. string data = File.ReadAllText(fullPath); server.AddResourceContent(uri, data, mimeType); } } };

add_tool_message method

Adds a tool message to be returned during a tool request.

Syntax

def add_tool_message(message_type: int, value: str) -> None: ...

Remarks

This method is used to add a new tool message to be passed back to the client during an ongoing tool request. It may only be called from within the on_tool_request event, and should only be called once per each type of data to be returned.

MessageType identifies the data type of the message being added. Valid data types include:

0 (mtText) Natural language text data.
1 (mtAudio) A base64-encoded string representing audio data (e.g., MP3 or WAV).
2 (mtImage) A base64-encoded string representing image data (e.g., PNG or JPEG).
3 (mtResource) A string message representing the contents of a text-based resource (e.g., file://logs/output.txt).

Value contains text that will be included in the response for the ongoing tool request.

config method

Sets or retrieves a configuration setting.

Syntax

def config(configuration_string: str) -> str: ...

Remarks

config is a generic method available in every class. It is used to set and retrieve configuration settings for the class.

These settings are similar in functionality to properties, but they are rarely used. In order to avoid "polluting" the property namespace of the class, access to these internal properties is provided through the config method.

To set a configuration setting named PROPERTY, you must call Config("PROPERTY=VALUE"), where VALUE is the value of the setting expressed as a string. For boolean values, use the strings "True", "False", "0", "1", "Yes", or "No" (case does not matter).

To read (query) the value of a configuration setting, you must call Config("PROPERTY"). The value will be returned as a string.

do_events method

Processes events from the internal queue.

Syntax

def do_events() -> None: ...

Remarks

This method causes the component to process any available events. If no events are available, it waits for a preset period of time and then returns.

get_prompt_param_value method

Retrieves the value of an existing prompt parameter.

Syntax

def get_prompt_param_value(name: str) -> str: ...

Remarks

This method is used to retrieve the value of an existing prompt parameter. It may only be called from within the on_prompt_request event.

Name contains a unique identifier for the prompt parameter that is being retrieved. This must match the value passed into the register_prompt_arg method when the parameter was registered.

The value associated with the prompt parameter is returned when calling this method. If the specified parameter does not exist or was not provided by the client, then an empty string is returned.

Example: // Define argument schema. server.RegisterPromptArg("code", "Code to explain", true); server.RegisterPromptArg("language", "Programming language", false); // Register the prompt. string name = "explain-code"; string description = "Explain how code works"; server.RegisterPrompt(name, description); // Handling the prompt request. server.OnPromptRequest += (s, e) => { // Retrieve runtime values sent by client. string code = server.GetPromptParamValue("code"); string language = server.GetPromptParamValue("language") ?? "Unknown"; // Build response messages. // Assuming the client sent 'a = 1 + 2;' for the 'code' argument, and 'python' for the 'language' argument. // The following response should contain a user message with the text 'Explain how this python code works: \n\na = 1 + 2;'. server.AddPromptMessage("user", $"Explain how this {language} code works:\n\n{code}"); };

get_tool_param_value method

Retrieves the value of an existing tool parameter.

Syntax

def get_tool_param_value(name: str) -> str: ...

Remarks

This method is used to retrieve the value of an existing tool parameter. It may only be called from within the on_tool_request event.

Name contains a unique identifier for the tool parameter that is being retrieved. This must match the value passed into the register_tool_param method when the parameter was registered.

The value associated with the tool parameter is returned when calling this method. If the specified parameter does not exist or was not provided by the client, then an empty string is returned.

process_request method

Processes the request and sends the result.

Syntax

def process_request() -> None: ...

Remarks

When the transport property is set to ttHTTP and the processing_mode property is set to modeExternalServer or modeOffline, this method acts as the main entry point for the class and is used to process a specific request. This method should not be called when the class is running in the modeEmbeddedServer mode.

Note that when using the modeOffline mode, the class processes the request and its associated headers supplied via the request and request_headers properties, respectively, and therefore ignores the parameters of this method.

Note that authentication occurs fully outside the scope of the class, and the logic that verifies these credentials is separate from any interaction with the class. Only once the request has been authenticated through this external verification should the be passed to this method.

process_requests method

Instructs the class to start processing incoming requests.

Syntax

def process_requests() -> None: ...

Remarks

This method instructs the class to process requests.

Notice that start_listening needs to be called before calling this method.

register_prompt method

Registers a prompt that can be requested by the client.

Syntax

def register_prompt(name: str, description: str) -> None: ...

Remarks

This method is used to register a new prompt that can be requested by the client.

Name specifies the unique name identifier for the prompt.

Description is critical in helping the client to understand the purpose and functionality of the prompt and should be set to a brief, human-readable description of what the prompt does.

Any prompt arguments associated with the prompt to be registered must be registered via the register_prompt_arg method before this method is called.

Once the prompt has been registered, it is added to the prompts properties and may be requested by the client, causing the on_prompt_request event to be fired. Additionally, the registered_prompt_args properties is cleared, and all prompt arguments previously in the properties are applied to the prompt.

Example: // Register two prompt argument schemas. server.RegisterPromptArg("code", "Code to explain", true); server.RegisterPromptArg("language", "Programming language", false); // Register the prompt with the added arguments. server.RegisterPrompt("explain-code", "Explain how code works");

Example: // Define argument schema. server.RegisterPromptArg("code", "Code to explain", true); server.RegisterPromptArg("language", "Programming language", false); // Register the prompt. string name = "explain-code"; string description = "Explain how code works"; server.RegisterPrompt(name, description); // Handling the prompt request. server.OnPromptRequest += (s, e) => { // Retrieve runtime values sent by client. string code = server.GetPromptParamValue("code"); string language = server.GetPromptParamValue("language") ?? "Unknown"; // Build response messages. // Assuming the client sent 'a = 1 + 2;' for the 'code' argument, and 'python' for the 'language' argument. // The following response should contain a user message with the text 'Explain how this python code works: \n\na = 1 + 2;'. server.AddPromptMessage("user", $"Explain how this {language} code works:\n\n{code}"); };

register_prompt_arg method

Registers an argument for a prompt.

Syntax

def register_prompt_arg(name: str, description: str, required: bool) -> None: ...

Remarks

This method is used to register a new argument for a prompt that has not yet been registered via the register_prompt method.

Name specifies the unique name identifier for the prompt argument.

Description identifies what information should be provided to this argument.

Required specifies whether the prompt argument must be supplied by the client when requesting the prompt.

Once the prompt argument has been registered, it is added to the registered_prompt_args properties. All of the prompt arguments in this properties will be applied to the next prompt registered via register_prompt, after which the properties is cleared.

Example: // Register two prompt argument schemas. server.RegisterPromptArg("code", "Code to explain", true); server.RegisterPromptArg("language", "Programming language", false); // Register the prompt with the added arguments. server.RegisterPrompt("explain-code", "Explain how code works");

register_resource method

Registers a resource that can be requested by the client.

Syntax

def register_resource(uri: str, name: str, description: str) -> None: ...

Remarks

This method is used to register a new resource that can be requested by the client.

Uri specifies the unique identifier for the resource, of which common formats include file:///filename.ext for files, standard HTTP/HTTPS URLs for web resources, or custom schemes like db://table_name.

Name indicates the display name of the resource shown to end users by the client.

Description should be set to a brief, human-readable description of the resource's purpose, its content type, and appropriate use cases.

Once the resource has been registered, it is added to the resources properties and may be requested by the client, causing the on_resource_request event to be fired.

Note that once registered, resources become available for discovery, but the actual content (including format details and MIME type) is not loaded until a specific resource has been requested.

Resource URIs

Resource URIs represent a unique identifier for a resource and must follow the format: [scheme]://[host]/[path]

Common schemes include:

file://: For local or file-like resources, even if they do not map directly to a local file (e.g., file:///example.png).
https://: Refers to web-accessible resources. This should only be used if the clients can fetch and parse the content directly (e.g., https://www.nsoftware.com).
git://: Indicates resources that originate from a Git repository (e.g., git://github.com/nsoftware/repo.git).

Custom URI Schemes

In addition to the previously listed schemes, applications may define their own custom URI schemes. These must be in accordance with RFC3986, especially with regards to reserved characters and general formatting recommendations. Characters such as :, /, and ? must be percent-encoded when used as data.

Client behavior may vary; therefore when registering resource URIs, servers must be prepared to handle every resource they register, regardless of client behavior. MCP-compatible clients may ignore scheme recommendations or fail to fetch resources as expected.

register_tool method

Registers a tool that can be requested by the client.

Syntax

def register_tool(name: str, description: str) -> None: ...

Remarks

This method is used to register a new tool that can be requested by the client.

Name specifies the unique name identifier for the tool.

Description is critical in helping the client to understand when to invoke this tool should be set to a brief, human-readable description of what the tool does.

Any tool parameters associated with the tool to be registered must be registered via the register_tool_param method before this method is called.

Once the tool has been registered, it is added to the tools properties and may be requested by the client, causing the on_tool_request event to be fired. Additionally, the registered_tool_params properties is cleared, and all tool parameters previously in the properties are applied to the tool.

register_tool_param method

Registers a parameter for a tool.

Syntax

def register_tool_param(name: str, required: bool) -> None: ...

Remarks

This method is used to register a new parameter for a tool that has not yet been registered via the register_tool method.

Name specifies the unique name identifier for the tool parameter.

Required specifies whether the tool parameter must be supplied by the client when requesting the tool.

Once the tool parameter has been registered, it is added to the registered_tool_params properties. All of the tool parameters in this properties will be applied to the next tool registered via register_tool, after which the properties is cleared.

send_sampling_request method

Requests language model reasoning from the client.

Syntax

def send_sampling_request() -> str: ...

Remarks

When the transport property is set to ttStdio, this method is used to send a sampling request to the client, which is often used in order to utilize language model reasoning.

When called, the set of messages in the sampling_messages properties will be passed over to the client in order for them to be used as a prompt for the client's language model. This method will then return the output of the prompt as text.

Example: server.OnToolRequest += (s, e) => { if (e.Name.Contains("summarize-text")) { // Grab text to summarize from the corresponding tool parameter. string text = GetText(); // Custom logic. // Add a prompt asking the client's LLM to summarize the text we just received. SamplingMessage message = new SamplingMessage(); message.Role = TRoles.rtUser; message.Text = "Summarize the following text: " + text; server.SamplingMessages.Add(message); // Send the sampling messages over to the client and request a response. string result = server.SendSamplingRequest(); // Return some text. server.AddToolMessage((int)TToolMessageTypes.mtText, result); } };

System Prompts

When performing a sampling request, the server may specify a system prompt to influence the client's LLM behavior during sampling. A system prompt provides high-level guidance or context for how the language model should interpret and respond to the messages in sampling_messages. It is especially useful for establishing tone, role, or task-specific instructions.

Example: server.SystemPrompt = "You are an assistant meant to summarize text only using a formal tone."; SamplingMessage message = new SamplingMessage(); message.Role = TRoles.rtUser; message.Text = "Summarize the following text: " + text; server.SamplingMessages.Add(message); string result = server.SendSamplingRequest();

start_listening method

Instructs the class to start listening for incoming connections.

Syntax

def start_listening() -> None: ...

Remarks

When the transport property is set to ttStdio, or it is set to ttHTTP and the processing_mode property is set to modeEmbeddedServer, this method instructs the class to start listening for incoming connections on the port specified by .

To stop listening for new connections, please refer to the stop_listening method.

stop_listening method

Instructs the class to stop listening for new connections.

Syntax

def stop_listening() -> None: ...

Remarks

When the transport property is set to ttStdio, or it is set to ttHTTP and the processing_mode property is set to modeEmbeddedServer, this method instructs the class to stop listening for new connections. After being called, any new connection attempts will be rejected. Calling this method does not disconnect existing connections.

unregister_prompt method

Unregisters an existing prompt.

Syntax

def unregister_prompt(name: str) -> None: ...

Remarks

This method is used to unregister a prompt that had previously been registered via the register_prompt method. Once called, the specified prompt will be removed from the prompts properties and will not be able to be requested by the client until it is registered again with register_prompt.

Name specifies the unique name identifier for the prompt that will be unregistered. This should match the value passed into register_prompt when the prompt was registered.

Example: // Register a prompt, making it available for clients to request. server.RegisterPromptArg("code-to-review", "The source code to review", true); server.RegisterPrompt("review-code", "Review the specified code"); // Handle client requests. // Unregister the prompt and prevent clients from being able to request it. server.UnregisterPrompt("review-code");

unregister_resource method

Unregisters an existing resource.

Syntax

def unregister_resource(uri: str) -> None: ...

Remarks

This method is used to unregister a resource that had previously been registered via the register_resource method. Once called, the specified resource will be removed from the resources properties and will not be able to be requested by the client until it is registered again with register_resource.

Uri specifies the unique identifier for the resource that will be unregistered. This should match the value passed into register_resource when the resource was registered.

Example: // Register a resource, making it available for clients to request. server.RegisterResource("file:///kb/test.txt", "Sample resource file", "A sample resource file with text content"); // Handle client requests. // Unregister the resource and prevent clients from being able to request it. server.UnregisterResource("file:///kb/test.txt");

Resource URIs

Resource URIs represent a unique identifier for a resource and must follow the format: [scheme]://[host]/[path]

Common schemes include:

file://: For local or file-like resources, even if they do not map directly to a local file (e.g., file:///example.png).
https://: Refers to web-accessible resources. This should only be used if the clients can fetch and parse the content directly (e.g., https://www.nsoftware.com).
git://: Indicates resources that originate from a Git repository (e.g., git://github.com/nsoftware/repo.git).

Custom URI Schemes

In addition to the previously listed schemes, applications may define their own custom URI schemes. These must be in accordance with RFC3986, especially with regards to reserved characters and general formatting recommendations. Characters such as :, /, and ? must be percent-encoded when used as data.

Client behavior may vary; therefore when registering resource URIs, servers must be prepared to handle every resource they register, regardless of client behavior. MCP-compatible clients may ignore scheme recommendations or fail to fetch resources as expected.

unregister_tool method

Unregisters an existing tool.

Syntax

def unregister_tool(name: str) -> None: ...

Remarks

This method is used to unregister a tool that had previously been registered via the register_tool method. Once called, the specified tool will be removed from the tools properties and will not be able to be invoked by the client until it is registered again with register_tool.

Name specifies the unique name identifier for the tool that will be unregistered. This should match the value passed into register_tool when the tool was registered.

Example: // Register a tool, making it available for clients to invoke. server.RegisterTool("random-num", "Generate a random number"); // Handle client requests. // Unregister the tool and prevent clients from being able to invoke it. server.UnregisterTool("random-num");

on_error event

Fires when an error occurs during operation.

Syntax

class MCPServerErrorEventParams(object):
  @property
  def connection_id() -> int: ...

  @property
  def error_code() -> int: ...

  @property
  def description() -> str: ...

# In class MCPServer:
@property
def on_error() -> Callable[[MCPServerErrorEventParams], None]: ...
@on_error.setter
def on_error(event_hook: Callable[[MCPServerErrorEventParams], None]) -> None: ...

Remarks

This event is fired when an unhandled exception is caught by the class, providing information about the error.

ConnectionId identifies the connection associated with the error.

ErrorCode contains the numeric error code representing the specific error condition.

Description contains a textual description of the error that occurred.

on_log event

Fires once for each log message.

Syntax

class MCPServerLogEventParams(object):
  @property
  def log_level() -> int: ...

  @property
  def message() -> str: ...

  @property
  def log_type() -> str: ...

# In class MCPServer:
@property
def on_log() -> Callable[[MCPServerLogEventParams], None]: ...
@on_log.setter
def on_log(event_hook: Callable[[MCPServerLogEventParams], None]) -> None: ...

Remarks

This event is fired once for each log message generated by the class. The verbosity is controlled by the LogLevel configuration.

LogLevel indicates the detail level of the message. Possible values are:

0 (None) No messages are logged.
1 (Info - Default) Informational events are logged.
2 (Verbose) Detailed data is logged.
3 (Debug) Debug data including all sent and received NFS operations are logged.

Message is the log message.

LogType identifies the type of log entry. Possible values are as follows:

  • NFS

on_prompt_request event

Fires when a prompt is requested by the client.

Syntax

class MCPServerPromptRequestEventParams(object):
  @property
  def name() -> str: ...

  @property
  def description() -> str: ...

# In class MCPServer:
@property
def on_prompt_request() -> Callable[[MCPServerPromptRequestEventParams], None]: ...
@on_prompt_request.setter
def on_prompt_request(event_hook: Callable[[MCPServerPromptRequestEventParams], None]) -> None: ...

Remarks

This event is fired when a prompt has been requested by the client and allows the server to run custom logic. The text-based output to be returned to the client should be passed to the add_prompt_message method while handling this event. This method may be called multiple times during the same prompt request to build a complete conversation history with alternating roles.

The get_prompt_param_value method may be called from within this event to retrieve the values for the prompt arguments associated with the requested prompt.

Name contains the unique name associated with the prompt.

Description holds the brief, human-readable description of what the prompt does.

Example: // Define argument schema. server.RegisterPromptArg("code", "Code to explain", true); server.RegisterPromptArg("language", "Programming language", false); // Register the prompt. string name = "explain-code"; string description = "Explain how code works"; server.RegisterPrompt(name, description); // Handling the prompt request. server.OnPromptRequest += (s, e) => { // Retrieve runtime values sent by client. string code = server.GetPromptParamValue("code"); string language = server.GetPromptParamValue("language") ?? "Unknown"; // Build response messages. // Assuming the client sent 'a = 1 + 2;' for the 'code' argument, and 'python' for the 'language' argument. // The following response should contain a user message with the text 'Explain how this python code works: \n\na = 1 + 2;'. server.AddPromptMessage("user", $"Explain how this {language} code works:\n\n{code}"); };

on_resource_request event

Fires when a resource is requested by the client.

Syntax

class MCPServerResourceRequestEventParams(object):
  @property
  def uri() -> str: ...

# In class MCPServer:
@property
def on_resource_request() -> Callable[[MCPServerResourceRequestEventParams], None]: ...
@on_resource_request.setter
def on_resource_request(event_hook: Callable[[MCPServerResourceRequestEventParams], None]) -> None: ...

Remarks

This event is fired when a resource has been requested by the client and allows the server to run custom logic. The resource content to be returned to the client should be passed to the add_resource_content method while handling this event. This method may be called multiple times during the same resource request to provide multiple related resources or different versions of the same content.

Uri specifies the unique resource identifier for the requested resource.

Example: server.OnResourceRequest += (s, e) => { string uri = e.Uri.ToString(); if (uri == "file:///logs/app.log") { string logData = File.ReadAllText("app.log"); server.AddResourceContent(uri, logData, "text/plain"); } else { server.Response = "[Unknown resource]"; } };

Resource URIs

Resource URIs represent a unique identifier for a resource and must follow the format: [scheme]://[host]/[path]

Common schemes include:

file://: For local or file-like resources, even if they do not map directly to a local file (e.g., file:///example.png).
https://: Refers to web-accessible resources. This should only be used if the clients can fetch and parse the content directly (e.g., https://www.nsoftware.com).
git://: Indicates resources that originate from a Git repository (e.g., git://github.com/nsoftware/repo.git).

Custom URI Schemes

In addition to the previously listed schemes, applications may define their own custom URI schemes. These must be in accordance with RFC3986, especially with regards to reserved characters and general formatting recommendations. Characters such as :, /, and ? must be percent-encoded when used as data.

Client behavior may vary; therefore when registering resource URIs, servers must be prepared to handle every resource they register, regardless of client behavior. MCP-compatible clients may ignore scheme recommendations or fail to fetch resources as expected.

on_session_end event

Fires when the class ends a session.

Syntax

class MCPServerSessionEndEventParams(object):
  @property
  def session_id() -> int: ...

# In class MCPServer:
@property
def on_session_end() -> Callable[[MCPServerSessionEndEventParams], None]: ...
@on_session_end.setter
def on_session_end(event_hook: Callable[[MCPServerSessionEndEventParams], None]) -> None: ...

Remarks

When the transport property is set to ttHTTP, this event fires when the class ends a previously started session. The class doesn't expect any errors to occur or be reported by handlers of this event.

SessionId specifies the unique identifier for the current session and can be obtained from the initial on_session_start event when the session is first opened.

on_session_start event

Fires when the class starts a session.

Syntax

class MCPServerSessionStartEventParams(object):
  @property
  def session_id() -> int: ...

  @property
  def result_code() -> int: ...
  @result_code.setter
  def result_code(value) -> None: ...

# In class MCPServer:
@property
def on_session_start() -> Callable[[MCPServerSessionStartEventParams], None]: ...
@on_session_start.setter
def on_session_start(event_hook: Callable[[MCPServerSessionStartEventParams], None]) -> None: ...

Remarks

When the transport property is set to ttHTTP, this event fires when a new session with a connected client begins. The lifetime of a session is a single HTTP request and response, meaning once the response has been sent, the session ends.

SessionId is the unique identifier of the session, assigned by the class. It is provided as a parameter in all other events so that the operations for a particular client session may be tracked.

ResultCode provides an opportunity to report the operation as failed. This parameter will always be 0 when the event is fired, indicating the operation was successful. If the event cannot be handled in a "successful" manner for some reason, this must be set to a non-zero value.

Reporting an error will abort the operation.

on_tool_request event

Fires when a tool is requested by the client.

Syntax

class MCPServerToolRequestEventParams(object):
  @property
  def connection_id() -> int: ...

  @property
  def name() -> str: ...

  @property
  def description() -> str: ...

  @property
  def is_error() -> bool: ...
  @is_error.setter
  def is_error(value) -> None: ...

# In class MCPServer:
@property
def on_tool_request() -> Callable[[MCPServerToolRequestEventParams], None]: ...
@on_tool_request.setter
def on_tool_request(event_hook: Callable[[MCPServerToolRequestEventParams], None]) -> None: ...

Remarks

This event is fired when a tool has been requested by the client and allows the server to run custom logic. If applicable, the text-based output to be returned to the client should be passed to the add_tool_message method while handling this event. This method may be called multiple times, once for each data type, if the tool needs to pass multiple types of data back to the client.

The get_tool_param_value method may be called from within this event to retrieve the values for the tool parameters associated with the requested tool.

Name identifies the unique name associated with the tool.

Description holds the brief, human-readable description of what the tool does, and while not necessary, is often used here for sampling.

IsError may be set to True to indicate when an error condition is met and the tool cannot be handled successfully.

Example: server.OnToolRequest += (s, e) => { if (e.Name.Contains("read-docs")) { // Execute custom logic. string documentation = ReadDocumentation(); // Return some text. server.AddToolMessage((int)TToolMessageTypes.mtText, documentation); } };

MCPServer Config Settings

The class accepts one or more of the following configuration settings. Configuration settings are similar in functionality to properties, but they are rarely used. In order to avoid "polluting" the property namespace of the class, access to these internal properties is provided through the config method.

MCPServer Config Settings

LogLevel:   Specifies the level of detail that is logged.

This configuration controls the level of detail that is logged through the on_log event. Possible values are:

0 (None)No messages are logged.
1 (Info - Default)Informational events are logged.
2 (Verbose)Detailed data is logged.
3 (Debug)Debug data including all relevant sent and received NFS operations are logged.
MaxTokens:   Specifies the maximum number of tokens to generate when sampling the client's LLM.

This setting controls the maximum number of tokens a client's LLM can generate in response to a call to send_sampling_request. The default value is 100.

PageSizePrompts:   Specifies the page size to use when responding to prompt listing requests from the client.

This setting controls the page size when listing prompts. The default value is 100.

The receiving MCP client should also support pagination.

PageSizeResources:   Specifies the page size to use when responding to resource listing requests from the client.

This setting controls the page size when listing resources. The default value is 100.

The receiving MCP client should also support pagination.

PageSizeTools:   Specifies the page size to use when responding to tool listing requests from the client.

This setting controls the page size when listing tools. The default value is 100.

The receiving MCP client should also support pagination.

Base Config Settings

BuildInfo:   Information about the product's build.

When queried, this setting will return a string containing information about the product's build.

CodePage:   The system code page used for Unicode to Multibyte translations.

The default code page is Unicode UTF-8 (65001).

The following is a list of valid code page identifiers:

IdentifierName
037IBM EBCDIC - U.S./Canada
437OEM - United States
500IBM EBCDIC - International
708Arabic - ASMO 708
709Arabic - ASMO 449+, BCON V4
710Arabic - Transparent Arabic
720Arabic - Transparent ASMO
737OEM - Greek (formerly 437G)
775OEM - Baltic
850OEM - Multilingual Latin I
852OEM - Latin II
855OEM - Cyrillic (primarily Russian)
857OEM - Turkish
858OEM - Multilingual Latin I + Euro symbol
860OEM - Portuguese
861OEM - Icelandic
862OEM - Hebrew
863OEM - Canadian-French
864OEM - Arabic
865OEM - Nordic
866OEM - Russian
869OEM - Modern Greek
870IBM EBCDIC - Multilingual/ROECE (Latin-2)
874ANSI/OEM - Thai (same as 28605, ISO 8859-15)
875IBM EBCDIC - Modern Greek
932ANSI/OEM - Japanese, Shift-JIS
936ANSI/OEM - Simplified Chinese (PRC, Singapore)
949ANSI/OEM - Korean (Unified Hangul Code)
950ANSI/OEM - Traditional Chinese (Taiwan; Hong Kong SAR, PRC)
1026IBM EBCDIC - Turkish (Latin-5)
1047IBM EBCDIC - Latin 1/Open System
1140IBM EBCDIC - U.S./Canada (037 + Euro symbol)
1141IBM EBCDIC - Germany (20273 + Euro symbol)
1142IBM EBCDIC - Denmark/Norway (20277 + Euro symbol)
1143IBM EBCDIC - Finland/Sweden (20278 + Euro symbol)
1144IBM EBCDIC - Italy (20280 + Euro symbol)
1145IBM EBCDIC - Latin America/Spain (20284 + Euro symbol)
1146IBM EBCDIC - United Kingdom (20285 + Euro symbol)
1147IBM EBCDIC - France (20297 + Euro symbol)
1148IBM EBCDIC - International (500 + Euro symbol)
1149IBM EBCDIC - Icelandic (20871 + Euro symbol)
1200Unicode UCS-2 Little-Endian (BMP of ISO 10646)
1201Unicode UCS-2 Big-Endian
1250ANSI - Central European
1251ANSI - Cyrillic
1252ANSI - Latin I
1253ANSI - Greek
1254ANSI - Turkish
1255ANSI - Hebrew
1256ANSI - Arabic
1257ANSI - Baltic
1258ANSI/OEM - Vietnamese
1361Korean (Johab)
10000MAC - Roman
10001MAC - Japanese
10002MAC - Traditional Chinese (Big5)
10003MAC - Korean
10004MAC - Arabic
10005MAC - Hebrew
10006MAC - Greek I
10007MAC - Cyrillic
10008MAC - Simplified Chinese (GB 2312)
10010MAC - Romania
10017MAC - Ukraine
10021MAC - Thai
10029MAC - Latin II
10079MAC - Icelandic
10081MAC - Turkish
10082MAC - Croatia
12000Unicode UCS-4 Little-Endian
12001Unicode UCS-4 Big-Endian
20000CNS - Taiwan
20001TCA - Taiwan
20002Eten - Taiwan
20003IBM5550 - Taiwan
20004TeleText - Taiwan
20005Wang - Taiwan
20105IA5 IRV International Alphabet No. 5 (7-bit)
20106IA5 German (7-bit)
20107IA5 Swedish (7-bit)
20108IA5 Norwegian (7-bit)
20127US-ASCII (7-bit)
20261T.61
20269ISO 6937 Non-Spacing Accent
20273IBM EBCDIC - Germany
20277IBM EBCDIC - Denmark/Norway
20278IBM EBCDIC - Finland/Sweden
20280IBM EBCDIC - Italy
20284IBM EBCDIC - Latin America/Spain
20285IBM EBCDIC - United Kingdom
20290IBM EBCDIC - Japanese Katakana Extended
20297IBM EBCDIC - France
20420IBM EBCDIC - Arabic
20423IBM EBCDIC - Greek
20424IBM EBCDIC - Hebrew
20833IBM EBCDIC - Korean Extended
20838IBM EBCDIC - Thai
20866Russian - KOI8-R
20871IBM EBCDIC - Icelandic
20880IBM EBCDIC - Cyrillic (Russian)
20905IBM EBCDIC - Turkish
20924IBM EBCDIC - Latin-1/Open System (1047 + Euro symbol)
20932JIS X 0208-1990 & 0121-1990
20936Simplified Chinese (GB2312)
21025IBM EBCDIC - Cyrillic (Serbian, Bulgarian)
21027Extended Alpha Lowercase
21866Ukrainian (KOI8-U)
28591ISO 8859-1 Latin I
28592ISO 8859-2 Central Europe
28593ISO 8859-3 Latin 3
28594ISO 8859-4 Baltic
28595ISO 8859-5 Cyrillic
28596ISO 8859-6 Arabic
28597ISO 8859-7 Greek
28598ISO 8859-8 Hebrew
28599ISO 8859-9 Latin 5
28605ISO 8859-15 Latin 9
29001Europa 3
38598ISO 8859-8 Hebrew
50220ISO 2022 Japanese with no halfwidth Katakana
50221ISO 2022 Japanese with halfwidth Katakana
50222ISO 2022 Japanese JIS X 0201-1989
50225ISO 2022 Korean
50227ISO 2022 Simplified Chinese
50229ISO 2022 Traditional Chinese
50930Japanese (Katakana) Extended
50931US/Canada and Japanese
50933Korean Extended and Korean
50935Simplified Chinese Extended and Simplified Chinese
50936Simplified Chinese
50937US/Canada and Traditional Chinese
50939Japanese (Latin) Extended and Japanese
51932EUC - Japanese
51936EUC - Simplified Chinese
51949EUC - Korean
51950EUC - Traditional Chinese
52936HZ-GB2312 Simplified Chinese
54936Windows XP: GB18030 Simplified Chinese (4 Byte)
57002ISCII Devanagari
57003ISCII Bengali
57004ISCII Tamil
57005ISCII Telugu
57006ISCII Assamese
57007ISCII Oriya
57008ISCII Kannada
57009ISCII Malayalam
57010ISCII Gujarati
57011ISCII Punjabi
65000Unicode UTF-7
65001Unicode UTF-8
The following is a list of valid code page identifiers for Mac OS only:
IdentifierName
1ASCII
2NEXTSTEP
3JapaneseEUC
4UTF8
5ISOLatin1
6Symbol
7NonLossyASCII
8ShiftJIS
9ISOLatin2
10Unicode
11WindowsCP1251
12WindowsCP1252
13WindowsCP1253
14WindowsCP1254
15WindowsCP1250
21ISO2022JP
30MacOSRoman
10UTF16String
0x90000100UTF16BigEndian
0x94000100UTF16LittleEndian
0x8c000100UTF32String
0x98000100UTF32BigEndian
0x9c000100UTF32LittleEndian
65536Proprietary

LicenseInfo:   Information about the current license.

When queried, this setting will return a string containing information about the license this instance of a class is using. It will return the following information:

  • Product: The product the license is for.
  • Product Key: The key the license was generated from.
  • License Source: Where the license was found (e.g., RuntimeLicense, License File).
  • License Type: The type of license installed (e.g., Royalty Free, Single Server).
  • Last Valid Build: The last valid build number for which the license will work.
MaskSensitiveData:   Whether sensitive data is masked in log messages.

In certain circumstances it may be beneficial to mask sensitive data, like passwords, in log messages. Set this to True to mask sensitive data. The default is True.

ProcessIdleEvents:   Whether the class uses its internal event loop to process events when the main thread is idle.

If set to False, the class will not fire internal idle events. Set this to False to use the class in a background thread on Mac OS. By default, this setting is True.

SelectWaitMillis:   The length of time in milliseconds the class will wait when DoEvents is called if there are no events to process.

If there are no events to process when do_events is called, the class will wait for the amount of time specified here before returning. The default value is 20.

UseInternalSecurityAPI:   Whether or not to use the system security libraries or an internal implementation.

When set to False, the class will use the system security libraries by default to perform cryptographic functions where applicable.

Setting this configuration setting to True tells the class to use the internal implementation instead of using the system security libraries.

On Windows, this setting is set to False by default. On Linux/macOS, this setting is set to True by default.

To use the system security libraries for Linux, OpenSSL support must be enabled. For more information on how to enable OpenSSL, please refer to the OpenSSL Notes section.

MCPServer Errors

MCPServer Errors

104   The class is already listening.