ConsoleResult
An MCP CallToolResult with text, image, and notebook conveniences.
Usage
MCPConsole.send() and AsyncMCPConsole.send() return this type, including for text-only output. content preserves the order of the original SDK blocks; text and images provide separate views of those blocks. All MCP fields and validation/serialization methods are inherited from mcp.types.CallToolResult. The result can be passed directly to code accepting that type. No image data is decoded or re-encoded.
print(result) renders text with MIME placeholders for images. In an IPython notebook, display(result) or leaving the result as the last expression renders each text and image block in order. Ordinary calls and text rendering do not import or require IPython.
Construct results with the SDK’s keyword fields, such as ConsoleResult(content=[]). Use model_dump() or model_dump_json() to serialize the complete result.
Attributes
content-
Native MCP content blocks in their original order.
structured_content-
The structured payload, or
Nonewhen omitted. is_error-
Whether the tool call ended in an MCP tool error.
meta-
MCP result metadata, or
Nonewhen omitted. result_type- The SDK’s result completion status.
Examples
from mcp_console import MCPConsole
with MCPConsole() as console:
result = console(r="plot(1:3)")
print(result)
for image in result.images:
print(image.mime_type)Images are native MCP ImageContent objects. Their data field holds base64 text; decode it when saving image bytes:
import base64
from pathlib import Path
image = result.images[0]
Path("plot.png").write_bytes(base64.b64decode(image.data))Attributes
| Name | Description |
|---|---|
| text | Text blocks concatenated without added separators or image placeholders. |
| images | Native image blocks in order, with their original MIME and base64 data. |
text
Text blocks concatenated without added separators or image placeholders.
text: str
This is the text received from Console, including lifecycle notices. Use structured_content for complete requirements inspection data.
images
Native image blocks in order, with their original MIME and base64 data.
images: list[ImageContent]
Methods
| Name | Description |
|---|---|
| __str__() | Render text and image placeholders without raising on tool errors. |
__str__()
Render text and image placeholders without raising on tool errors.
Usage
__str__()Successful requirements inspection retains the complete formatted JSON representation used by earlier string-returning clients.