mcp - MCP Python SDK
https://py.sdk.modelcontextprotocol.io/api/mcp/ • 79 KB fetched Open original page
mcp - MCP Python SDK
Skip to content
MCP Python SDK
mcp
*
en - English
*
de - Deutsch
*
es - español
*
fr - français
*
hi - हिन्दी
*
ja - 日本語
*
ko - 한국어
*
pt - português (Brasil)
*
ru - русский язык
*
tr - Türkçe
*
uk - українська мова
*
zh - 简体中文
*
zh-hant - 繁體中文
Search
modelcontextprotocol/python-sdk
MCP Python SDK
modelcontextprotocol/python-sdk
*
MCP Python SDK
*
What's new in v2
*
Get started
Get started
*
Installation
*
First steps
*
Connect to a real host
*
Testing
*
Servers
Servers
*
Tools
*
Structured Output
*
Resources
*
URI templates
*
Prompts
*
Completions
*
Images, audio & icons
*
Handling errors
*
Inside your handler
Inside your handler
*
The Context
*
Dependencies
*
Lifespan
*
Elicitation
*
Multi-round-trip requests
*
Sampling and roots
*
Progress
*
Logging
*
Subscriptions
*
Running your server
Running your server
*
Add to an existing app
*
Deploy & scale
*
Authorization
*
OpenTelemetry
*
Serving legacy clients
*
Clients
Clients
*
Callbacks
*
Transports
*
OAuth
*
Identity assertion
*
Multiple servers
*
Subscriptions
*
Caching
*
Protocol versions
*
Deprecated features
*
Advanced
Advanced
*
The low-level Server
*
Pagination
*
Middleware
*
Extensions
*
MCP Apps
*
Troubleshooting
*
Translations
*
Migration Guide
*
API Reference
API Reference
*
mcp
mcp
*
cli
*
client
*
os
*
server
*
shared
*
mcp_types
On this page
*
mcp
*
ClientResult
*
InputRequiredRoundsExceededError
*
Classes
*
Functions
*
Attributes
*
MCP Python SDK
*
API Reference
*
mcp
mcp
ClientResult
module-attribute
ClientResult = (
EmptyResult
| CreateMessageResult
| CreateMessageResultWithTools
| ListRootsResult
| ElicitResult
)
InputRequiredRoundsExceededError
Bases: RuntimeError
The server kept returning InputRequiredResult past the configured max_rounds .
Source code in src/mcp/client/_input_required.py
40
41
42
43
44
45
46
47
48
49
class InputRequiredRoundsExceededError ( RuntimeError ):
"""The server kept returning `InputRequiredResult` past the configured `max_rounds`."""
def __init__ ( self , max_rounds : int ) -> None :
super () . __init__ (
f "Server returned InputRequiredResult for more than { max_rounds } rounds; "
"raise input_required_max_rounds on the Client, or use "
"client.session.<method>(..., allow_input_required=True) to drive the loop manually."
)
self . max_rounds = max_rounds
Classes
* CallToolRequest — Used by the client to invoke a tool provided by the server.
* Client — A high-level MCP client for connecting to MCP servers.
* ClientCapabilities — Capabilities a client may support.
* ClientSession — Client half of an MCP connection, running on a Dispatcher .
* ClientSessionGroup — Client for managing connections to multiple MCP servers.
* CompleteRequest — A request from the client to the server, to ask for completion options.
* CreateMessageRequest — A request from the server to sample an LLM via the client.
* CreateMessageResult — The client's response to a sampling/createMessage request from the server.
* CreateMessageResultWithTools — The client's response to a sampling/createMessage request when tools were provided.
* ErrorData — Error information for JSON-RPC error responses.
* 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.
* Implementation — Describes the name and version of an MCP implementation ( clientInfo / serverInfo ).
* 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.
* InputRequiredRoundsExceededError — The server kept returning InputRequiredResult past the configured max_rounds .
* InvalidUriTemplate — Raised when a URI template string is malformed or unsupported.
* JSONRPCError — A response to a request that indicates an error occurred.
* JSONRPCRequest — A JSON-RPC request that expects a response.
* JSONRPCResponse — A successful (non-error) response to a request.
* 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.
* ListToolsResult — The server's response to a tools/list request from the client.
* LoggingMessageNotification — Notification of a log message passed from server to client.
* MCPDeprecationWarning — A custom deprecation warning for the MCP SDK.
* MCPError — Exception type raised when an error arrives over an MCP connection.
* Notification — Base class for JSON-RPC notifications.
* PingRequest — A ping, issued by either the server or the client, to check that the other party is still alive. The receiver must promptly respond, or else may be disconnected.
* ProgressNotification — An out-of-band notification used to inform the receiver of a progress update for a long-running request.
* PromptsCapability — Capability for prompts operations.
* 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.
* Resource — A known resource that the server is capable of reading.
* ResourcesCapability — Capability for resources operations.
* ResourceUpdatedNotification — A notification from the server to the client, informing it that a resource has changed and may need to be read again.
* RootsCapability — Capability for root operations.
* SamplingCapability — Sampling capability structure. Deprecated in 2026-07-28 (SEP-2577); shape unchanged.
* SamplingContextCapability — Capability for context inclusion during sampling.
* SamplingMessage — Describes a message issued to or received from an LLM API.
* SamplingToolsCapability — Capability indicating support for tool calling during sampling.
* ServerCapabilities — Capabilities that a server may support. Not a closed set.
* ServerSession — Per-request proxy for server-to-client requests and notifications.
* SetLevelRequest — A request from the client to the server, to enable or adjust logging.
* StdioServerParameters
* SubscribeRequest — Sent from the client to request resources/updated notifications from the server whenever a particular resource changes.
* Tool — Definition for a tool the client can call.
* ToolChoice — Controls tool selection behavior for sampling requests (2025-11-25+).
* ToolResultContent — The result of a tool use, provided by the user back to the assistant (2025-11-25+).
* ToolsCapability — Capability for tools operations.
* ToolUseContent — An assistant's request to invoke a tool during sampling (2025-11-25+).
* UnsubscribeRequest — Sent from the client to request cancellation of resources/updated notifications from the server. This should follow a previous resources/subscribe request.
* UriTemplate — A parsed RFC 6570 URI template.
* UrlElicitationRequiredError — Specialized error for when a tool requires URL mode elicitation(s) before proceeding.
Functions
* stdio_client — Spawns an MCP server subprocess and connects to it over stdin/stdout.
* stdio_server — Serve MCP over the process's stdin and stdout.
Attributes
* ClientNotification — Notifications sent from the client to the server.
* ClientRequest — Union of client-to-server request payloads across all supported protocol versions.
* ClientResult
* IncludeContext — Scope of MCP-server context a sampling request asks the client to attach.
* LoggingLevel — The severity of a log message.
* SamplingContent — Basic content types for sampling responses (without tool use).
* SamplingMessageContentBlock — Content block types allowed in sampling messages.
* SamplingRole — The sender or recipient of messages and data in a conversation.
* ServerNotification — Union of server-to-client notification payloads across all supported protocol versions.
* ServerRequest — Union of standalone JSON-RPC requests a server can send to a client.
* ServerResult — Union of every result payload a server can return for a client request.
* StopReason — The reason why sampling stopped, if known.
Back to top
Previous
Migration Guide
Next
cli
Made with
Zensical
Links found on this page
- Skip to content [direct]
- en - English [direct]
- de - Deutsch [direct]
- es - español [direct]
- fr - français [direct]
- hi - हिन्दी [direct]
- ja - 日本語 [direct]
- ko - 한국어 [direct]
- pt - português (Brasil) [direct]
- ru - русский язык [direct]
- tr - Türkçe [direct]
- uk - українська мова [direct]
- zh - 简体中文 [direct]
- zh-hant - 繁體中文 [direct]
- modelcontextprotocol/python-sdk [direct]
- What's new in v2 [direct]
- Get started [direct]
- Installation [direct]
- First steps [direct]
- Connect to a real host [direct]
- Testing [direct]
- Servers [direct]
- Tools [direct]
- Structured Output [direct]
- Resources [direct]
- URI templates [direct]
- Prompts [direct]
- Completions [direct]
- Images, audio & icons [direct]
- Handling errors [direct]
- Inside your handler [direct]
- The Context [direct]
- Dependencies [direct]
- Lifespan [direct]
- Elicitation [direct]
- Multi-round-trip requests [direct]
- Sampling and roots [direct]
- Progress [direct]
- Logging [direct]
- Subscriptions [direct]
- Running your server [direct]
- Add to an existing app [direct]
- Deploy & scale [direct]
- Authorization [direct]
- OpenTelemetry [direct]
- Serving legacy clients [direct]
- Clients [direct]
- Callbacks [direct]
- Transports [direct]
- OAuth [direct]
- Identity assertion [direct]
- Multiple servers [direct]
- Subscriptions [direct]
- Caching [direct]
- Protocol versions [direct]
- Deprecated features [direct]
- Advanced [direct]
- The low-level Server [direct]
- Pagination [direct]
- Middleware [direct]
- Extensions [direct]
- MCP Apps [direct]
- Troubleshooting [direct]
- Translations [direct]
- Migration Guide [direct]
- cli [direct]
- client [direct]
- os [direct]
- server [direct]
- shared [direct]
- mcp_types [direct]
- RuntimeError [direct]
- Client [direct]
- ClientSession [direct]
- ClientSessionGroup [direct]
- ErrorData [direct]
- InvalidUriTemplate [direct]
- MCPDeprecationWarning [direct]
- ServerSession [direct]
- StdioServerParameters [direct]
|
|