API Reference
ClientSession
Bases: BaseSession[ClientRequest, ClientNotification, ClientResult, ServerRequest, ServerNotification]
Source code in src/mcp/client/session.py
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 |
|
send_ping
async
send_ping() -> EmptyResult
Send a ping request.
Source code in src/mcp/client/session.py
179 180 181 182 183 184 185 186 187 188 |
|
send_progress_notification
async
send_progress_notification(
progress_token: str | int,
progress: float,
total: float | None = None,
message: str | None = None,
) -> None
Send a progress notification.
Source code in src/mcp/client/session.py
190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 |
|
set_logging_level
async
set_logging_level(level: LoggingLevel) -> EmptyResult
Send a logging/setLevel request.
Source code in src/mcp/client/session.py
212 213 214 215 216 217 218 219 220 221 222 |
|
list_resources
async
list_resources(
cursor: str | None = None,
) -> ListResourcesResult
Send a resources/list request.
Source code in src/mcp/client/session.py
224 225 226 227 228 229 230 231 232 233 234 |
|
list_resource_templates
async
list_resource_templates(
cursor: str | None = None,
) -> ListResourceTemplatesResult
Send a resources/templates/list request.
Source code in src/mcp/client/session.py
236 237 238 239 240 241 242 243 244 245 246 |
|
read_resource
async
read_resource(uri: AnyUrl) -> ReadResourceResult
Send a resources/read request.
Source code in src/mcp/client/session.py
248 249 250 251 252 253 254 255 256 257 258 |
|
subscribe_resource
async
subscribe_resource(uri: AnyUrl) -> EmptyResult
Send a resources/subscribe request.
Source code in src/mcp/client/session.py
260 261 262 263 264 265 266 267 268 269 270 |
|
unsubscribe_resource
async
unsubscribe_resource(uri: AnyUrl) -> EmptyResult
Send a resources/unsubscribe request.
Source code in src/mcp/client/session.py
272 273 274 275 276 277 278 279 280 281 282 |
|
call_tool
async
call_tool(
name: str,
arguments: dict[str, Any] | None = None,
read_timeout_seconds: timedelta | None = None,
progress_callback: ProgressFnT | None = None,
) -> CallToolResult
Send a tools/call request with optional progress callback support.
Source code in src/mcp/client/session.py
284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 |
|
list_prompts
async
list_prompts(
cursor: str | None = None,
) -> ListPromptsResult
Send a prompts/list request.
Source code in src/mcp/client/session.py
335 336 337 338 339 340 341 342 343 344 345 |
|
get_prompt
async
get_prompt(
name: str, arguments: dict[str, str] | None = None
) -> GetPromptResult
Send a prompts/get request.
Source code in src/mcp/client/session.py
347 348 349 350 351 352 353 354 355 356 357 |
|
complete
async
complete(
ref: ResourceTemplateReference | PromptReference,
argument: dict[str, str],
context_arguments: dict[str, str] | None = None,
) -> CompleteResult
Send a completion/complete request.
Source code in src/mcp/client/session.py
359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 |
|
list_tools
async
list_tools(cursor: str | None = None) -> ListToolsResult
Send a tools/list request.
Source code in src/mcp/client/session.py
384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 |
|
send_roots_list_changed
async
send_roots_list_changed() -> None
Send a roots/list_changed notification.
Source code in src/mcp/client/session.py
403 404 405 406 407 408 409 410 411 |
|
ClientSessionGroup
Client for managing connections to multiple MCP servers.
This class is responsible for encapsulating management of server connections. It aggregates tools, resources, and prompts from all connected servers.
For auxiliary handlers, such as resource subscription, this is delegated to the client and can be accessed via the session.
Example Usage
name_fn = lambda name, server_info: f"{(server_info.name)}_{name}" async with ClientSessionGroup(component_name_hook=name_fn) as group: for server_params in server_params: await group.connect_to_server(server_param) ...
Source code in src/mcp/client/session_group.py
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 |
|
__init__
__init__(
exit_stack: AsyncExitStack | None = None,
component_name_hook: _ComponentNameHook | None = None,
) -> None
Initializes the MCP client.
Source code in src/mcp/client/session_group.py
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
|
__aexit__
async
__aexit__(
_exc_type: type[BaseException] | None,
_exc_val: BaseException | None,
_exc_tb: TracebackType | None,
) -> bool | None
Closes session exit stacks and main exit stack upon completion.
Source code in src/mcp/client/session_group.py
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
|
prompts
property
Returns the prompts as a dictionary of names to prompts.
resources
property
Returns the resources as a dictionary of names to resources.
call_tool
async
Executes a tool given its name and arguments.
Source code in src/mcp/client/session_group.py
175 176 177 178 179 |
|
disconnect_from_server
async
disconnect_from_server(session: ClientSession) -> None
Disconnects from a single MCP server.
Source code in src/mcp/client/session_group.py
181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 |
|
connect_with_session
async
connect_with_session(
server_info: Implementation, session: ClientSession
) -> ClientSession
Connects to a single MCP server.
Source code in src/mcp/client/session_group.py
218 219 220 221 222 223 |
|
connect_to_server
async
connect_to_server(
server_params: ServerParameters,
) -> ClientSession
Connects to a single MCP server.
Source code in src/mcp/client/session_group.py
225 226 227 228 229 230 231 |
|
StdioServerParameters
Bases: BaseModel
Source code in src/mcp/client/stdio/__init__.py
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
|
args
class-attribute
instance-attribute
Command line arguments to pass to the executable.
env
class-attribute
instance-attribute
The environment to use when spawning the process.
If not specified, the result of get_default_environment() will be used.
cwd
class-attribute
instance-attribute
The working directory to use when spawning the process.
encoding
class-attribute
instance-attribute
encoding: str = 'utf-8'
The text encoding used when sending/receiving messages to the server
defaults to utf-8
encoding_error_handler
class-attribute
instance-attribute
encoding_error_handler: Literal[
"strict", "ignore", "replace"
] = "strict"
The text encoding error handler.
See https://docs.python.org/3/library/codecs.html#codec-base-classes for explanations of possible values
stdio_client
async
stdio_client(
server: StdioServerParameters, errlog: TextIO = stderr
)
Client transport for stdio: this will connect to a server by spawning a process and communicating with it over stdin/stdout.
Source code in src/mcp/client/stdio/__init__.py
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 |
|
ServerSession
Bases: BaseSession[ServerRequest, ServerNotification, ServerResult, ClientRequest, ClientNotification]
Source code in src/mcp/server/session.py
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 |
|
check_client_capability
check_client_capability(
capability: ClientCapabilities,
) -> bool
Check if the client supports a specific capability.
Source code in src/mcp/server/session.py
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
|
send_log_message
async
send_log_message(
level: LoggingLevel,
data: Any,
logger: str | None = None,
related_request_id: RequestId | None = None,
) -> None
Send a log message notification.
Source code in src/mcp/server/session.py
178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 |
|
send_resource_updated
async
send_resource_updated(uri: AnyUrl) -> None
Send a resource updated notification.
Source code in src/mcp/server/session.py
200 201 202 203 204 205 206 207 208 209 |
|
create_message
async
create_message(
messages: list[SamplingMessage],
*,
max_tokens: int,
system_prompt: str | None = None,
include_context: IncludeContext | None = None,
temperature: float | None = None,
stop_sequences: list[str] | None = None,
metadata: dict[str, Any] | None = None,
model_preferences: ModelPreferences | None = None,
related_request_id: RequestId | None = None
) -> CreateMessageResult
Send a sampling/create_message request.
Source code in src/mcp/server/session.py
211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 |
|
list_roots
async
list_roots() -> ListRootsResult
Send a roots/list request.
Source code in src/mcp/server/session.py
247 248 249 250 251 252 253 254 255 256 |
|
elicit
async
elicit(
message: str,
requestedSchema: ElicitRequestedSchema,
related_request_id: RequestId | None = None,
) -> ElicitResult
Send an elicitation/create request.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
message
|
str
|
The message to present to the user |
required |
requestedSchema
|
ElicitRequestedSchema
|
Schema defining the expected response structure |
required |
Returns:
Type | Description |
---|---|
ElicitResult
|
The client's response |
Source code in src/mcp/server/session.py
258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 |
|
send_ping
async
send_ping() -> EmptyResult
Send a ping request.
Source code in src/mcp/server/session.py
287 288 289 290 291 292 293 294 295 296 |
|
send_progress_notification
async
send_progress_notification(
progress_token: str | int,
progress: float,
total: float | None = None,
message: str | None = None,
related_request_id: str | None = None,
) -> None
Send a progress notification.
Source code in src/mcp/server/session.py
298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 |
|
send_resource_list_changed
async
send_resource_list_changed() -> None
Send a resource list changed notification.
Source code in src/mcp/server/session.py
322 323 324 325 326 327 328 329 330 |
|
send_tool_list_changed
async
send_tool_list_changed() -> None
Send a tool list changed notification.
Source code in src/mcp/server/session.py
332 333 334 335 336 337 338 339 340 |
|
send_prompt_list_changed
async
send_prompt_list_changed() -> None
Send a prompt list changed notification.
Source code in src/mcp/server/session.py
342 343 344 345 346 347 348 349 350 |
|
stdio_server
async
Server transport for stdio: this communicates with an MCP client by reading from the current process' stdin and writing to stdout.
Source code in src/mcp/server/stdio.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
|
McpError
Bases: Exception
Exception type raised when an error arrives over an MCP connection.
Source code in src/mcp/shared/exceptions.py
4 5 6 7 8 9 10 11 12 13 14 |
|
__init__
__init__(error: ErrorData)
Initialize McpError.
Source code in src/mcp/shared/exceptions.py
11 12 13 14 |
|
CallToolRequest
Bases: Request[CallToolRequestParams, Literal['tools/call']]
Used by the client to invoke a tool provided by the server.
Source code in src/mcp/types.py
879 880 881 882 883 |
|
ClientCapabilities
Bases: BaseModel
Capabilities a client may support.
Source code in src/mcp/types.py
243 244 245 246 247 248 249 250 251 252 253 254 |
|
experimental
class-attribute
instance-attribute
Experimental, non-standard capabilities that the client supports.
sampling
class-attribute
instance-attribute
sampling: SamplingCapability | None = None
Present if the client supports sampling from an LLM.
elicitation
class-attribute
instance-attribute
elicitation: ElicitationCapability | None = None
Present if the client supports elicitation from the user.
roots
class-attribute
instance-attribute
roots: RootsCapability | None = None
Present if the client supports listing roots.
CompleteRequest
Bases: Request[CompleteRequestParams, Literal['completion/complete']]
A request from the client to the server, to ask for completion options.
Source code in src/mcp/types.py
1105 1106 1107 1108 1109 |
|
CreateMessageRequest
Bases: Request[CreateMessageRequestParams, Literal['sampling/createMessage']]
A request from the server to sample an LLM via the client.
Source code in src/mcp/types.py
1033 1034 1035 1036 1037 |
|
CreateMessageResult
Bases: Result
The client's response to a sampling/create_message request from the server.
Source code in src/mcp/types.py
1043 1044 1045 1046 1047 1048 1049 1050 1051 |
|
stopReason
class-attribute
instance-attribute
stopReason: StopReason | None = None
The reason why sampling stopped, if known.
ErrorData
Bases: BaseModel
Error information for JSON-RPC error responses.
Source code in src/mcp/types.py
161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 |
|
message
instance-attribute
message: str
A short description of the error. The message SHOULD be limited to a concise single sentence.
data
class-attribute
instance-attribute
data: Any | None = None
Additional information about the error. The value of this member is defined by the sender (e.g. detailed error information, nested errors etc.).
GetPromptRequest
Bases: Request[GetPromptRequestParams, Literal['prompts/get']]
Used by the client to get a prompt provided by the server.
Source code in src/mcp/types.py
655 656 657 658 659 |
|
GetPromptResult
Bases: Result
The server's response to a prompts/get request from the client.
Source code in src/mcp/types.py
769 770 771 772 773 774 |
|
description
class-attribute
instance-attribute
description: str | None = None
An optional description for the prompt.
Implementation
Bases: BaseMetadata
Describes the name and version of an MCP implementation.
Source code in src/mcp/types.py
216 217 218 219 220 |
|
InitializedNotification
Bases: Notification[NotificationParams | None, Literal['notifications/initialized']]
This notification is sent from the client to the server after initialization has finished.
Source code in src/mcp/types.py
344 345 346 347 348 349 350 351 |
|
InitializeRequest
Bases: Request[InitializeRequestParams, Literal['initialize']]
This request is sent from the client to the server when it first connects, asking it to begin initialization.
Source code in src/mcp/types.py
323 324 325 326 327 328 329 330 |
|
InitializeResult
Bases: Result
After receiving an initialize request from the client, the server sends this.
Source code in src/mcp/types.py
333 334 335 336 337 338 339 340 341 |
|
JSONRPCError
Bases: BaseModel
A response to a request that indicates an error occurred.
Source code in src/mcp/types.py
182 183 184 185 186 187 188 |
|
JSONRPCRequest
Bases: Request[dict[str, Any] | None, str]
A request that expects a response.
Source code in src/mcp/types.py
124 125 126 127 128 129 130 |
|
JSONRPCResponse
Bases: BaseModel
A successful (non-error) response to a request.
Source code in src/mcp/types.py
140 141 142 143 144 145 146 |
|
ListPromptsRequest
Bases: PaginatedRequest[Literal['prompts/list']]
Sent from the client to request a list of prompts and prompt templates.
Source code in src/mcp/types.py
606 607 608 609 |
|
ListPromptsResult
Bases: PaginatedResult
The server's response to a prompts/list request from the client.
Source code in src/mcp/types.py
639 640 641 642 |
|
ListResourcesRequest
Bases: PaginatedRequest[Literal['resources/list']]
Sent from the client to request a list of resources the server has.
Source code in src/mcp/types.py
397 398 399 400 |
|
ListResourcesResult
Bases: PaginatedResult
The server's response to a resources/list request from the client.
Source code in src/mcp/types.py
458 459 460 461 |
|
ListToolsResult
Bases: PaginatedResult
The server's response to a tools/list request from the client.
Source code in src/mcp/types.py
865 866 867 868 |
|
LoggingMessageNotification
Bases: Notification[LoggingMessageNotificationParams, Literal['notifications/message']]
Notification of a log message passed from server to client.
Source code in src/mcp/types.py
938 939 940 941 942 |
|
Notification
Bases: BaseModel
, Generic[NotificationParamsT, MethodT]
Base class for JSON-RPC notifications.
Source code in src/mcp/types.py
97 98 99 100 101 102 |
|
PingRequest
Bases: Request[RequestParams | None, Literal['ping']]
A ping, issued by either the server or the client, to check that the other party is still alive.
Source code in src/mcp/types.py
354 355 356 357 358 359 360 361 |
|
ProgressNotification
Bases: Notification[ProgressNotificationParams, Literal['notifications/progress']]
An out-of-band notification used to inform the receiver of a progress update for a long-running request.
Source code in src/mcp/types.py
387 388 389 390 391 392 393 394 |
|
PromptsCapability
Bases: BaseModel
Capability for prompts operations.
Source code in src/mcp/types.py
257 258 259 260 261 262 |
|
listChanged
class-attribute
instance-attribute
listChanged: bool | None = None
Whether this server supports notifications for changes to the prompt list.
ReadResourceRequest
Bases: Request[ReadResourceRequestParams, Literal['resources/read']]
Sent from the client to the server, to read a specific resource URI.
Source code in src/mcp/types.py
487 488 489 490 491 |
|
ReadResourceResult
Bases: Result
The server's response to a resources/read request from the client.
Source code in src/mcp/types.py
526 527 528 529 |
|
Resource
Bases: BaseMetadata
A known resource that the server is capable of reading.
Source code in src/mcp/types.py
409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 |
|
uri
instance-attribute
uri: Annotated[AnyUrl, UrlConstraints(host_required=False)]
The URI of this resource.
description
class-attribute
instance-attribute
description: str | None = None
A description of what this resource represents.
mimeType
class-attribute
instance-attribute
mimeType: str | None = None
The MIME type of this resource, if known.
size
class-attribute
instance-attribute
size: int | None = None
The size of the raw resource content, in bytes (i.e., before base64 encoding or any tokenization), if known.
This can be used by Hosts to display file sizes and estimate context window usage.
meta
class-attribute
instance-attribute
See MCP specification for notes on _meta usage.
ResourcesCapability
Bases: BaseModel
Capability for resources operations.
Source code in src/mcp/types.py
265 266 267 268 269 270 271 272 |
|
ResourceUpdatedNotification
Bases: Notification[ResourceUpdatedNotificationParams, Literal['notifications/resources/updated']]
A notification from the server to the client, informing it that a resource has changed and may need to be read again.
Source code in src/mcp/types.py
594 595 596 597 598 599 600 601 602 603 |
|
RootsCapability
Bases: BaseModel
Capability for root operations.
Source code in src/mcp/types.py
223 224 225 226 227 228 |
|
listChanged
class-attribute
instance-attribute
listChanged: bool | None = None
Whether the client supports notifications for changes to the roots list.
SamplingMessage
Bases: BaseModel
Describes a message issued to or received from an LLM API.
Source code in src/mcp/types.py
717 718 719 720 721 722 |
|
ServerCapabilities
Bases: BaseModel
Capabilities that a server may support.
Source code in src/mcp/types.py
295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 |
|
experimental
class-attribute
instance-attribute
Experimental, non-standard capabilities that the server supports.
logging
class-attribute
instance-attribute
logging: LoggingCapability | None = None
Present if the server supports sending log messages to the client.
prompts
class-attribute
instance-attribute
prompts: PromptsCapability | None = None
Present if the server offers any prompt templates.
resources
class-attribute
instance-attribute
resources: ResourcesCapability | None = None
Present if the server offers any resources to read.
tools
class-attribute
instance-attribute
tools: ToolsCapability | None = None
Present if the server offers any tools to call.
completions
class-attribute
instance-attribute
completions: CompletionsCapability | None = None
Present if the server offers autocompletion suggestions for prompts and resources.
SetLevelRequest
Bases: Request[SetLevelRequestParams, Literal['logging/setLevel']]
A request from the client to the server, to enable or adjust logging.
Source code in src/mcp/types.py
916 917 918 919 920 |
|
SubscribeRequest
Bases: Request[SubscribeRequestParams, Literal['resources/subscribe']]
Sent from the client to request resources/updated notifications from the server whenever a particular resource changes.
Source code in src/mcp/types.py
555 556 557 558 559 560 561 562 |
|
Tool
Bases: BaseMetadata
Definition for a tool the client can call.
Source code in src/mcp/types.py
843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 |
|
description
class-attribute
instance-attribute
description: str | None = None
A human-readable description of the tool.
inputSchema
instance-attribute
A JSON Schema object defining the expected parameters for the tool.
outputSchema
class-attribute
instance-attribute
An optional JSON Schema object defining the structure of the tool's output returned in the structuredContent field of a CallToolResult.
annotations
class-attribute
instance-attribute
annotations: ToolAnnotations | None = None
Optional additional tool information.
meta
class-attribute
instance-attribute
See MCP specification for notes on _meta usage.
ToolsCapability
Bases: BaseModel
Capability for tools operations.
Source code in src/mcp/types.py
275 276 277 278 279 280 |
|
listChanged
class-attribute
instance-attribute
listChanged: bool | None = None
Whether this server supports notifications for changes to the tool list.
UnsubscribeRequest
Bases: Request[UnsubscribeRequestParams, Literal['resources/unsubscribe']]
Sent from the client to request cancellation of resources/updated notifications from the server.
Source code in src/mcp/types.py
573 574 575 576 577 578 579 580 |
|