to_mcp_tool_result#

scikitplot.corpus.to_mcp_tool_result(documents, *, tool_name='corpus_search', is_error=False)[source]#

Format documents as an MCP tools/call response.

Parameters:
documentsSequence[CorpusDocument]

Search results.

tool_namestr, optional

Name of the MCP tool that produced these results.

is_errorbool, optional

Whether this response represents an error.

Returns:
dict[str, Any]

MCP tool result with content array and isError flag.

Parameters:
Return type:

dict[str, Any]

Notes

User note: Return this from your MCP server’s tools/call handler:

@server.tool("corpus_search")
async def search(query: str) -> dict:
    results = builder.search(query)
    return to_mcp_tool_result([r.doc for r in results])