askexperts
Version:
AskExperts SDK: build and use AI experts - ask them questions and pay with bitcoin on an open protocol
28 lines • 784 B
JavaScript
export function makeTool(callback) {
return async (params, extra) => {
let responseJson;
let isError = false;
try {
// Call the tool
responseJson = await callback(params, extra);
}
catch (error) {
isError = true;
responseJson = {
error: error instanceof Error ? error.message : String(error),
};
}
// Return in the format expected by MCP
return {
isError,
content: [
{
type: "text",
text: JSON.stringify(responseJson, null, 2),
},
],
structuredContent: responseJson,
};
};
}
//# sourceMappingURL=utils.js.map