Barndoor TypeScript SDK
A lightweight, framework-agnostic TypeScript/JavaScript client for the Barndoor Platform REST APIs and Model Context Protocol (MCP) servers. The SDK supports lazy authentication—you can build an SDK instance first, then inject a JWT later withauthenticate().
The SDK removes boiler-plate around:
- Secure, offline-friendly authentication to Barndoor (interactive PKCE flow + token caching).
- Server registry – list, inspect and connect third-party providers (Salesforce, Notion, Slack …).
- Managed Connector Proxy – build ready-to-use connection parameters for any LLM/agent framework (CrewAI, LangChain, custom code …) without importing Barndoor-specific adapters.
Be sure to checkout our examples and our NPM package
Installation
Quick Start
Basic Usage
Interactive Login
For development and prototyping, use the interactive login helper:loginInteractive() builds an SDK without requiring token in the ctor—it internally calls sdk.authenticate() for you.
Complete Workflow
Environment Configuration
The SDK automatically detects your environment and configures appropriate endpoints:AGENT_CLIENT_ID/SECRET when loginInteractive() is invoked.
API Reference
BarndoorSDK
Main SDK class for API interactions.apiBaseUrl(string): Base URL of the Barndoor APIoptions.token?(string): Initial JWT (pass later via authenticate() if omitted)options.timeout(number): Request timeout in seconds (default: 30)options.maxRetries(number): Maximum retry attempts (default: 3)
authenticate(jwtToken)
Sets/validates token for the SDK instance.
ensureServerConnected(serverSlug, options?)
Ensure a server is connected, launching OAuth if needed – same behaviour as quick-start helper.
listServers()
List all MCP servers available to your organization.
getServer(serverId)
Get detailed information about a specific server.
initiateConnection(serverId, returnUrl?)
Initiate OAuth connection flow for a server.
getConnectionStatus(serverId)
Get connection status for a server.
Quick-start Helpers
loginInteractive(options?)
Perform interactive OAuth login and return initialized SDK.
ensureServerConnected(sdk, serverSlug, options?)
Ensure a server is connected, launching OAuth if needed.
makeMcpConnectionParams(sdk, serverSlug, options?)
Generate MCP connection parameters for AI frameworks.
Error Handling
The SDK provides a comprehensive error hierarchy:Browser Support
The SDK works in both Node.js and browser environments:await sdk.authenticate(token) once your SPA receives a JWT.
Note: Interactive login (loginInteractive) requires Node.js for the local callback server.
Examples
See theexamples/ directory for complete working examples:
openai-integration.js- OpenAI + MCP function calling integrationbasic-mcp-client.js- Direct MCP client without AI framework
TypeScript Support
The SDK is written in TypeScript and includes full type definitions:Contributing
- Clone the repository
- Install dependencies:
npm install - Build the project:
npm run build - Run tests:
npm test - Run type checking:
npm run type-check - Run safety checks:
npm run safety-check
