Getting started
Basic Usage
Get up and running with Integrate SDK in minutes
Server Configuration
First, create a server configuration file with your OAuth credentials:
// lib/integrate.ts
import { createMCPServer, githubIntegration } from "integrate-sdk/server";
export const { client: serverClient } = createMCPServer({
apiKey: process.env.INTEGRATE_API_KEY,
integrations: [
githubIntegration({
clientId: process.env.GITHUB_CLIENT_ID,
clientSecret: process.env.GITHUB_CLIENT_SECRET,
scopes: ["repo", "user"],
}),
],
});You can get an API key from the Integrate Dashboard.
Client Usage
The client is automatically configured when making requests to the server.
Here's a complete example that calls a GitHub tool:
import { client } from "integrate-sdk";
if (!(await client.isAuthorized("github"))) {
await client.authorize("github");
}
const result = await client.github.createIssue({
owner: "owner",
repo: "repo",
title: "Bug report",
body: "Description of the bug",
});
console.log("Issue created:", result);Client-Side vs Server-Side
The SDK works in both browser and Node.js environments, but with different capabilities:
Browser Environment ✅
- Full OAuth authorization UI (popup/redirect)
- Make API calls to integrated services
- Complete session management
Server Environment 🖥️
- Make API calls with provider access tokens
- No OAuth UI (throws error if attempted)
- Perfect for backend API routes
import { client } from "integrate-sdk";
client.setProviderToken("github", {
accessToken: userAccessToken,
tokenType: "Bearer",
expiresIn: 3600,
});
const repos = await client.github.listRepos({ username: "octocat" });
await client.authorize("github");💡 Tip: Handle OAuth authorization in the browser, then store the access token in your database for backend API calls.
Step-by-Step Breakdown
1. Import the SDK
import { client } from "integrate-sdk";2. Set Up OAuth Credentials
Before using the SDK, you need to create OAuth apps for the services you want to integrate:
- GitHub: Create an OAuth App at GitHub Developer Settings
- Gmail: Create a project and OAuth 2.0 credentials in Google Cloud Console
Store your credentials in environment variables:
INTEGRATE_API_KEY=your_integrate_api_key
GITHUB_CLIENT_ID=your_github_client_id
GITHUB_CLIENT_SECRET=your_github_client_secret
GMAIL_CLIENT_ID=your_gmail_client_id
GMAIL_CLIENT_SECRET=your_gmail_client_secret3. Call Tools
import { client } from "integrate-sdk";
const result = await client.github.createIssue({
owner: "owner",
repo: "repo",
title: "Bug report",
body: "Description of the bug",
});List Available Tools
To see what tools are available:
import { client } from "integrate-sdk";
const tools = client.getEnabledTools();
console.log(
"Available tools:",
tools.map((t) => t.name)
);Error Handling
Wrap your code in try-catch blocks to handle errors:
import { client } from "integrate-sdk";
try {
const result = await client.github.createIssue({
owner: "owner",
repo: "repo",
title: "Bug report",
});
console.log("Success:", result);
} catch (error) {
console.error("Error:", error.message);
}Next Steps
- Learn about OAuth Authorization Flow to handle user authentication
- Explore Built-in Integrations to see what integrations are available
- Check out Advanced Usage for re-authentication, error handling, and more
- Integrate with Vercel AI SDK to give AI models access to your tools