Skip to main content

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 with authenticate(). 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:
If you run without a token at construction time the SDK will still read AGENT_CLIENT_ID/SECRET when loginInteractive() is invoked.

API Reference

BarndoorSDK

Main SDK class for API interactions.
Parameters:
  • apiBaseUrl (string): Base URL of the Barndoor API
  • options.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)
Methods:

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:
When running in the browser you can also create the SDK first and later call await sdk.authenticate(token) once your SPA receives a JWT. Note: Interactive login (loginInteractive) requires Node.js for the local callback server.

Examples

See the examples/ directory for complete working examples:
  • openai-integration.js - OpenAI + MCP function calling integration
  • basic-mcp-client.js - Direct MCP client without AI framework

TypeScript Support

The SDK is written in TypeScript and includes full type definitions:

Contributing

  1. Clone the repository
  2. Install dependencies: npm install
  3. Build the project: npm run build
  4. Run tests: npm test
  5. Run type checking: npm run type-check
  6. Run safety checks: npm run safety-check