UNPKG

@baruchiro/actual-mcp

Version:

Actual Budget MCP server exposing API functionality

73 lines 2.67 kB
import { CallToolResult, TextContent, ImageContent, AudioContent } from '@modelcontextprotocol/sdk/types.js'; /** * Standard MCP content item types (union of all supported content types) */ export type ContentItem = TextContent | ImageContent | AudioContent; /** * Text content item (most common type) */ export type TextContentItem = TextContent; /** * Standard MCP response structure (compatible with CallToolResult) */ export type Response = CallToolResult; /** * Optional context for building error responses. Carrying the tool name * and an optional stable code lets clients render and audit failures * without needing server log access. */ export interface ErrorContext { toolName?: string; code?: string; } /** * Normalized shape extracted from any thrown value. */ export interface NormalizedError { message: string; code?: string; name?: string; stack?: string; } /** * Create a successful plain text response * @param text - The text message * @returns A success response object with text content */ export declare function success(text: string): CallToolResult; /** * Create a success response with structured content * @param content - Array of content items * @returns A success response object with provided content */ export declare function successWithContent(content: ContentItem): CallToolResult; /** * 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 declare function successWithJson<T>(data: T): CallToolResult; /** * Create an error response * @param message - The error message * @param context - Optional tool name and stable error code * @returns An error response object */ export declare function error(message: string, context?: ErrorContext): CallToolResult; /** * Best-effort extraction of a useful message and code from any thrown value. * Handles `Error` instances, plain objects with `message`/`error`/`reason` * properties, strings, and falls back to JSON for unknown shapes. */ export declare function normalizeError(err: unknown): NormalizedError; /** * Create an error response from an Error object or any thrown value. * Extracts a usable message even from non-Error rejections (plain objects, * strings, etc.) so clients never see "[object Object]". * * @param err - The error object or value * @param context - Optional tool name and stable error code for the response * @returns An error response object */ export declare function errorFromCatch(err: unknown, context?: ErrorContext): CallToolResult; //# sourceMappingURL=response.d.ts.map