actual-mcp
Version:
Actual Budget MCP server exposing API functionality
59 lines • 1.54 kB
JavaScript
// ----------------------------
// RESPONSE UTILITIES
// ----------------------------
/**
* Create a successful plain text response
* @param text - The text message
* @returns A success response object with text content
*/
export function success(text) {
return {
content: [{ type: 'text', text }],
};
}
/**
* Create a success response with structured content
* @param content - Array of content items
* @returns A success response object with provided content
*/
export function successWithContent(content) {
return {
content: [content],
};
}
/**
* Create a success response with JSON data
* @param data - Any data object that can be JSON-stringified
* @returns A success response with JSON data wrapped as a resource
*/
export function successWithJson(data) {
return {
content: [
{
type: 'text',
text: JSON.stringify(data),
},
],
};
}
/**
* Create an error response
* @param message - The error message
* @returns An error response object
*/
export function error(message) {
return {
isError: true,
content: [{ type: 'text', text: `Error: ${message}` }],
};
}
/**
* Create an error response from an Error object or any thrown value
* @param err - The error object or value
* @returns An error response object
*/
export function errorFromCatch(err) {
const message = err instanceof Error ? err.message : String(err);
return error(message);
}
//# sourceMappingURL=response.js.map