/**
* Parse the result returned by MCP tool to extract the actual data content
* @param mcpResult The original result returned by MCP tool
* @returns The parsed data object
*/
export function parseMcpResult(mcpResult: any): any {
if (!mcpResult || !mcpResult.content) {
throw new Error('Invalid MCP result format')
}
// Process content array format
if (Array.isArray(mcpResult.content)) {
const textContent = mcpResult.content.find((item: any) => item.type === 'text')
if (textContent && textContent.text) {
const parsedData: any = JSON.parse(textContent.text)
return parsedData.data || parsedData
}
}
return mcpResult
}
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/xiaolaa2/ableton-copilot-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server