SOLFIND
Web Lens
Portal home

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

  1. Skip to content [direct]
  2. en - English [direct]
  3. de - Deutsch [direct]
  4. es - español [direct]
  5. fr - français [direct]
  6. hi - हिन्दी [direct]
  7. ja - 日本語 [direct]
  8. ko - 한국어 [direct]
  9. pt - português (Brasil) [direct]
  10. ru - русский язык [direct]
  11. tr - Türkçe [direct]
  12. uk - українська мова [direct]
  13. zh - 简体中文 [direct]
  14. zh-hant - 繁體中文 [direct]
  15. modelcontextprotocol/python-sdk [direct]
  16. What's new in v2 [direct]
  17. Get started [direct]
  18. Installation [direct]
  19. First steps [direct]
  20. Connect to a real host [direct]
  21. Testing [direct]
  22. Servers [direct]
  23. Tools [direct]
  24. Structured Output [direct]
  25. Resources [direct]
  26. URI templates [direct]
  27. Prompts [direct]
  28. Completions [direct]
  29. Images, audio & icons [direct]
  30. Handling errors [direct]
  31. Inside your handler [direct]
  32. The Context [direct]
  33. Dependencies [direct]
  34. Lifespan [direct]
  35. Elicitation [direct]
  36. Multi-round-trip requests [direct]
  37. Sampling and roots [direct]
  38. Progress [direct]
  39. Logging [direct]
  40. Subscriptions [direct]
  41. Running your server [direct]
  42. Add to an existing app [direct]
  43. Deploy & scale [direct]
  44. Authorization [direct]
  45. OpenTelemetry [direct]
  46. Serving legacy clients [direct]
  47. Clients [direct]
  48. Callbacks [direct]
  49. Transports [direct]
  50. OAuth [direct]
  51. Identity assertion [direct]
  52. Multiple servers [direct]
  53. Subscriptions [direct]
  54. Caching [direct]
  55. Protocol versions [direct]
  56. Deprecated features [direct]
  57. Advanced [direct]
  58. The low-level Server [direct]
  59. Pagination [direct]
  60. Middleware [direct]
  61. Extensions [direct]
  62. MCP Apps [direct]
  63. Troubleshooting [direct]
  64. Translations [direct]
  65. Migration Guide [direct]
  66. cli [direct]
  67. client [direct]
  68. os [direct]
  69. server [direct]
  70. shared [direct]
  71. mcp_types [direct]
  72. RuntimeError [direct]
  73. Client [direct]
  74. ClientSession [direct]
  75. ClientSessionGroup [direct]
  76. ErrorData [direct]
  77. InvalidUriTemplate [direct]
  78. MCPDeprecationWarning [direct]
  79. ServerSession [direct]
  80. StdioServerParameters [direct]