We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/aakashH242/mcp-playwright'
If you have feedback or need assistance with the MCP directory API, please join our Discord server
testUtils.ts•642 B
type ToolContent = { type: string; text?: string };
/**
* Extracts text content from a tool response while guarding against
* non-text entries (e.g., future image or resource results).
*/
export function getTextContent(
result: { content?: ToolContent[] },
index = 0
): string {
const entry = result.content?.[index] as ToolContent | undefined;
if (!entry) {
throw new Error(`No content found at index ${index}`);
}
if (entry.type !== "text" || typeof entry.text !== "string") {
throw new Error(
`Expected text content at index ${index} but received ${entry.type ?? "unknown"}`
);
}
return entry.text;
}