server library

Classes

MCPServer
Base class to extend when implementing an MCP server.

Enums

IncludeContext
The types of context in which should be included in a prompt.
JsonType
The valid types for properties in a JSON-RCP2 schema.
LoggingLevel
The severity of a log message.
ProtocolVersion
Enum of the known protocol versions.
Role
The sender or recipient of messages and data in a conversation.
ValidationErrorType
Enum representing the types of validation failures when checking data against a schema.

Mixins

CompletionsSupport
A mixin for MCP servers which support the completion capability.
LoggingSupport
A mixin for MCP servers which support the logging capability.
PromptsSupport
A mixin for MCP servers which support the prompts capability.
ResourcesSupport
A mixin for MCP servers which support the resources capability.
RootsTrackingSupport
Mix this in to any MCPServer to add support tracking the Roots as given by the client in an opinionated way.
ToolsSupport
A mixin for MCP servers which support the tools capability.

Extension Types

Annotated
Base type for objects that include optional annotations for the client.
Annotations
The annotations for an Annotated object.
AudioContent
Audio provided to or from an LLM.
BlobResourceContents
A ResourceContents that contains binary data encoded as base64.
BooleanSchema
A JSON Schema definition for a bool.
CallToolRequest
Used by the client to invoke a tool provided by the server.
CallToolResult
The server's response to a tool call.
CancelledNotification
This notification can be sent by either side to indicate that it is cancelling a previously-issued request.
ClientCapabilities
Capabilities a client may support.
CompleteRequest
A request from the client to the server, to ask for completion options.
CompleteResult
The server's response to a completion/complete request
Completion
An individual completion from a CompleteResult.
CompletionArgument
An argument passed to a CompleteRequest.
Completions
Completions parameter for ServerCapabilities.
Content
Could be either TextContent, ImageContent, AudioContent or EmbeddedResource.
CreateMessageRequest
A request from the server to sample an LLM via the client.
CreateMessageResult
The client's response to a sampling/create_message request from the server.
Cursor
An opaque token used to represent a cursor for pagination.
EmbeddedResource
The contents of a resource, embedded into a prompt or tool call result.
EmptyResult
A response that indicates success but carries no data.
GetPromptRequest
Used by the client to get a prompt provided by the server.
GetPromptResult
The server's response to a prompts/get request from the client.
ImageContent
An image provided to or from an LLM.
Implementation
Describes the name and version of an MCP implementation.
InitializedNotification
This notification is sent from the client to the server after initialization has finished.
InitializeRequest
This request is sent from the client to the server when it first connects, asking it to begin initialization.
InitializeResult
After receiving an initialize request from the client, the server sends this response.
IntegerSchema
A JSON Schema definition for an int.
ListPromptsRequest
Sent from the client to request a list of prompts and prompt templates the server has.
ListPromptsResult
The server's response to a prompts/list request from the client.
ListResourcesRequest
Sent from the client to request a list of resources the server has.
ListResourcesResult
The server's response to a resources/list request from the client.
ListResourceTemplatesRequest
Sent from the client to request a list of resource templates the server has.
ListResourceTemplatesResult
The server's response to a resources/templates/list request from the client.
ListRootsRequest
Sent from the server to request a list of root URIs from the client.
ListRootsResult
The client's response to a roots/list request from the server.
ListSchema
A JSON Schema definition for a List.
ListToolsRequest
Sent from the client to request a list of tools the server has.
ListToolsResult
The server's response to a tools/list request from the client.
Logging
Extension type for the logging capability.
LoggingMessageNotification
Notification of a log message passed from server to client.
Meta
Generic metadata passed with most requests, can be anything.
MetaWithProgressToken
A Meta object with a known progress token key.
ModelHint
Hints to use for model selection.
ModelPreferences
The server's preferences for model selection, requested of the client during sampling.
Notification
Base interface for all notifications.
NullSchema
A JSON Schema definition for null.
NumberSchema
A JSON Schema definition for a num.
ObjectSchema
A JSON Schema definition for an object with properties.
PaginatedRequest
A "mixin"-like extension type for any request that contains a Cursor at the key "cursor".
PaginatedResult
A "mixin"-like extension type for any result type that contains a Cursor at the key "cursor".
PingRequest
A ping, issued by either the server or the client, to check that the other party is still alive.
ProgressNotification
An out-of-band notification used to inform the receiver of a progress update for a long-running request.
ProgressToken
A progress token, used to associate progress notifications with the original request.
Prompt
A prompt or prompt template that the server offers.
PromptArgument
Describes an argument that a prompt can accept.
PromptListChangedNotification
An optional notification from the server to the client, informing it that the list of prompts it offers has changed.
PromptMessage
Describes a message returned as part of a prompt.
PromptReference
Identifies a prompt.
Prompts
Prompts parameter for ServerCapabilities.
ReadResourceRequest
Sent from the client to the server, to read a specific resource URI.
ReadResourceResult
The server's response to a resources/read request from the client.
Reference
Union type for references, see PromptReference and ResourceReference.
Request
Base interface for all request types.
RequestId
An opaque request ID.
Resource
A known resource that the server is capable of reading.
ResourceContents
Base class for the contents of a specific resource or sub-resource.
ResourceListChangedNotification
An optional notification from the server to the client, informing it that the list of resources it can read from has changed.
ResourceReference
A reference to a resource or resource template definition.
Resources
Resources parameter for ServerCapabilities.
ResourceTemplate
A template description for resources available on the server.
ResourceUpdatedNotification
A notification from the server to the client, informing it that a resource has changed and may need to be read again.
Result
Base interface for all responses to requests.
Root
Represents a root directory or file that the server can operate on.
RootsCapabilities
Whether the client supports notifications for changes to the roots list.
RootsListChangedNotification
A notification from the client to the server, informing it that the list of roots has changed.
SamplingMessage
Describes a message issued to or received from an LLM API.
Schema
A JSON Schema object defining the any kind of property.
ServerCapabilities
Capabilities that a server may support.
SetLevelRequest
A request from the client to the server, to enable or adjust logging.
StringSchema
A JSON Schema definition for a String.
SubscribeRequest
Sent from the client to request resources/updated notifications from the server whenever a particular resource changes.
TextContent
Text provided to or from an LLM.
TextResourceContents
A ResourceContents that contains text.
Tool
Definition for a tool the client can call.
ToolAnnotations
Additional properties describing a Tool to clients.
ToolListChangedNotification
An optional notification from the server to the client, informing it that the list of tools it offers has changed.
Tools
Tools parameter for ServerCapabilities.
UnsubscribeRequest
Sent from the client to request cancellation of resources/updated notifications from the server.
ValidationError
A validation error with detailed information about the location of the error.
WithProgressToken
A "mixin"-like extension type for any extension type that might contain a ProgressToken at the key "progressToken".

Extensions

SchemaValidation on Schema