MCPcopy Index your code
hub / github.com/modelcontextprotocol/python-sdk / elicit

Method elicit

src/mcp/server/mcpserver/context.py:118–149  ·  view source on GitHub ↗

Elicit information from the client/user. This method can be used to interactively ask for additional information from the client within a tool's execution. The client might display the message to the user and collect a response according to the provided schema. If the client

(
        self,
        message: str,
        schema: type[ElicitSchemaModelT],
    )

Source from the content-addressed store, hash-verified

116 return await self._mcp_server.read_resource(uri, self)
117
118 async def elicit(
119 self,
120 message: str,
121 schema: type[ElicitSchemaModelT],
122 ) -> ElicitationResult[ElicitSchemaModelT]:
123 """Elicit information from the client/user.
124
125 This method can be used to interactively ask for additional information from the
126 client within a tool's execution. The client might display the message to the
127 user and collect a response according to the provided schema. If the client
128 is an agent, it might decide how to handle the elicitation -- either by asking
129 the user or automatically generating a response.
130
131 Args:
132 message: Message to present to the user
133 schema: A Pydantic model class defining the expected response structure.
134 According to the specification, only primitive types are allowed.
135
136 Returns:
137 An ElicitationResult containing the action taken and the data if accepted
138
139 Note:
140 Check the result.action to determine if the user accepted, declined, or cancelled.
141 The result.data will only be populated if action is "accept" and validation succeeded.
142 """
143
144 return await elicit_with_validation(
145 session=self.request_context.session,
146 message=message,
147 schema=schema,
148 related_request_id=self.request_id,
149 )
150
151 async def elicit_url(
152 self,

Callers

nothing calls this directly

Calls 1

elicit_with_validationFunction · 0.90

Tested by

no test coverage detected