Skip to main content

Module tools

Module tools 

Source
Expand description

MCP tools as session tools, and the three resource tools. Port of extensions/mcp/tools.ts and resources.ts in pi v1.0.0.

Model-facing text over 20 KB keeps its start and end, with the full text saved to a temp file the model can read. Binary resources other than images are saved to temp files too. Results keep the server’s whole CallToolResult, without _meta, as structured content.

Structs§

McpResourceTool
One of list_mcp_resources, list_mcp_resource_templates and read_mcp_resource, which take a server argument and reach every connected server with resources.
McpTool
An MCP server’s tool.

Constants§

LIST_MCP_RESOURCES_TOOL
Lists resources.
LIST_MCP_RESOURCE_TEMPLATES_TOOL
Lists resource templates.
OUTPUT_MAX_BYTES
Model-facing text beyond this is cut in the middle.
READ_MCP_RESOURCE_TOOL
Reads the resources resource links name.

Functions§

annotations
pi’s toToolAnnotations: the boolean hints of tool’s annotations, or None when it has none.
convert_result
pi’s convertMcpResult: isError results become error results.
is_app_resource
MCP App user interfaces, which only hosts that render them can use.
limit_content
Keeps model-facing text within OUTPUT_MAX_BYTES: longer text becomes one block in Codex’s format with the full text’s path, before any images.
model_content
server’s content blocks for the model, before the output limit.
resource_tools
The three resource tools over servers.
server_tool_label
The server/tool label of the session tool name when an MCP server provides it, which pi’s MCP renderers show in place of the name.
tool_name
mcp__<server>__<tool> with everything but [A-Za-z0-9_] as _. A name too long, or taken by another tool, is cut and given a hash suffix.

Type Aliases§

ResourceServers
The servers resource tools reach, at call time.