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§
- McpResource
Tool - One of
list_mcp_resources,list_mcp_resource_templatesandread_mcp_resource, which take aserverargument 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 oftool’s annotations, orNonewhen it has none. - convert_
result - pi’s
convertMcpResult:isErrorresults 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/toollabel of the session toolnamewhen 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§
- Resource
Servers - The servers resource tools reach, at call time.