$ show dedalus-labs/dedalus-agents-typescript
This repository provides a TypeScript SDK for the Dedalus API and an MCP (Model Context Protocol) server that exposes the API as MCP tools. The SDK is generated from an OpenAPI specification using Stainless, offering type-safe access to AI model functionalities including chat completions, embeddings, image generation, and audio processing. It includes features such as automatic retries with exponential backoff, streaming responses, file upload handling, and structured output parsing via Zod schemas. The MCP server implementation allows Dedalus API endpoints to be used as tools by MCP-compatible clients like Claude and Cursor. It includes a compatibility layer that transforms JSON schemas to accommodate various client limitations (e.g., handling unions, inlining references, truncating tool names). The server supports both stdio and HTTP transports and can be extended with custom tools. Key architectural elements include a resource-based client structure, a robust request/response transformation system, and a modular MCP server design. The codebase demonstrates strong engineering practices with comprehensive testing, active maintenance, and clear separation of concerns between the SDK and server components.
The LLM identified 4 files worth highlighting for reuse:
Extends the native Promise class with safe handling methods (`thenSafe`, `catchSafe`, `finallySafe`) that prevent unhandled promise rejections and provide consistent error handling across asynchronous operations. This isolated utility can be extracted for use in any TypeScript project dealing with promises.
Provides functions to convert between camelCase and snake_case for object keys, facilitating compatibility between TypeScript/JavaScript conventions and API expectations. The implementation handles nested objects and arrays, making it a reusable utility for any API client or server.
Contains a suite of functions for transforming JSON schemas to meet the constraints of various MCP clients (e.g., removing top-level unions, inlining $ref references, eliminating anyOf constructs, stripping format properties, and truncating tool names while ensuring uniqueness). This compatibility layer solves a common problem in MCP server development and can be adapted for other protocol implementations.
Implements the `toFile` function that normalizes diverse input types (Blob, File, Buffer, string, etc.) into a standardized file object suitable for upload operations. This utility encapsulates the complexity of handling file inputs across different environments (browser, Node.js) and is applicable to any service that processes file uploads.