Metorial Node.js SDK
The official Node.js/TypeScript SDK for Metorial. Give your AI agents access to tools like Slack, GitHub, SAP, and hundreds more through MCP โ without managing servers, auth flows, or infrastructure.
Sign up for a free account to get started.
Complete API Documentation
Installation
npm install metorial
# or
yarn add metorial
# or
pnpm add metorial
# or
bun add metorial
Supported LLM Integrations
This SDK provides adapter packages that format MCP tools for each LLM. You can also use the API directly.
| LLM Integration |
Import |
Format |
Models (non-exhaustive) |
Example |
| AI SDK |
@metorial/ai-sdk |
Framework tools |
Any model via Vercel AI SDK |
typescript-ai-sdk |
| OpenAI |
@metorial/openai |
OpenAI function calling |
gpt-4.1, gpt-4o, o1, o3 |
typescript-openai |
| Anthropic |
@metorial/anthropic |
Claude tool format |
claude-sonnet-4-5, claude-opus-4 |
typescript-anthropic |
| Google |
@metorial/google |
Gemini function declarations |
gemini-2.5-pro, gemini-2.5-flash |
typescript-google |
| Mistral |
@metorial/mistral |
Mistral function calling |
mistral-large-latest, codestral-latest |
typescript-mistral |
| DeepSeek |
@metorial/deepseek |
OpenAI-compatible |
deepseek-chat, deepseek-reasoner |
typescript-deepseek |
| TogetherAI |
@metorial/togetherai |
OpenAI-compatible |
Llama-4, Qwen-3 |
typescript-togetherai |
| XAI |
@metorial/xai |
OpenAI-compatible |
grok-3, grok-3-mini |
typescript-xai |
| LangChain |
@metorial/langchain |
LangChain tools |
Any model via LangChain |
typescript-langchain |
| OpenAI-Compatible |
@metorial/openai-compatible |
OpenAI-compatible |
Any OpenAI-compatible API |
typescript-openai-compatible |
Quick Start
This example uses Metorial Search, a built-in web search provider that requires no auth configuration. You just need two environment variables:
npm install metorial @metorial/ai-sdk @ai-sdk/anthropic ai
import { anthropic } from '@ai-sdk/anthropic';
import { metorialAiSdk } from '@metorial/ai-sdk';
import { Metorial } from 'metorial';
import { stepCountIs, streamText } from 'ai';
let metorial = new Metorial({ apiKey: process.env.METORIAL_API_KEY! });
// Create a deployment for Metorial Search (built-in web search, no auth needed)
let deployment = await metorial.providerDeployments.create({
name: 'Metorial Search',
providerId: 'metorial-search'
});
let session = await metorial.connect({
adapter: metorialAiSdk(),
providers: [{ providerDeploymentId: deployment.id }]
});
let result = streamText({
model: anthropic('claude-sonnet-4-20250514'),
prompt:
'Search the web for the latest news about AI agents and summarize the top 3 stories.',
stopWhen: stepCountIs(10),
tools: session.tools(),
onStepFinish: step => {
if (step.toolCalls?.length) {
console.log(step.toolCalls.map(tc => tc.toolName).join(', '));
}
}
});
for await (let part of result.textStream) {
process.stdout.write(part);
}
See the full runnable example at examples/typescript-quick-start/.
Authenticating MCP Tool Providers
The Quick Start above used Metorial Search, which requires no authentication. Most providers โ Slack, GitHub, SAP, and others โ require credentials. Here are the options, from simplest to most flexible.
Key concepts:
- Provider โ an MCP tool integration (e.g. Slack, GitHub, Metorial Search). Browse available providers at platform.metorial.com.
- Provider Deployment โ an instance of a provider configured for your project. You can create deployments in the dashboard or programmatically.
- Auth Credentials โ your OAuth app registration (client ID, client secret, scopes).
- Auth Config โ an already-authenticated connection with a token, service account, or specific user via an OAuth flow.
Dashboard-Configured Deployments
Some providers (Exa, Tavily) use API keys configured entirely in the dashboard. Just pass the deployment ID โ no auth code needed:
providers: [{ providerDeploymentId: 'your-exa-deployment-id' }];
Pre-Created Auth Config
An auth config represents an already-authenticated connection to a provider โ for example, a user who has completed the OAuth flow for Slack. Once created (via the dashboard or a setup session), reference it by ID:
providers: [
{
providerDeploymentId: 'your-slack-deployment-id',
providerAuthConfigId: 'your-auth-config-id'
}
];
Inline Credentials
Pass credentials directly without pre-creating them in the dashboard:
providers: [
{
providerDeploymentId: 'your-deployment-id',
providerAuthConfig: {
providerAuthMethodId: 'your-auth-method-id',
credentials: { access_token: 'user-access-token' }
}
}
];
OAuth Flow
For services like Slack or GitHub where each end-user authenticates individually, use setup sessions to handle the OAuth flow:
import { metorialAiSdk } from '@metorial/ai-sdk';
import { Metorial } from 'metorial';
let metorial = new Metorial({ apiKey: process.env.METORIAL_API_KEY! });
// 1. Create a setup session for the provider
let setupSession = await metorial.providerDeployments.setupSessions.create({
providerId: 'your-slack-provider-id',
providerAuthMethodId: 'your-slack-auth-method-id'
// callbackUri: 'https://yourapp.com/oauth/callback'
});
// 2. Send the OAuth URL to your user
console.log(`Authenticate here: ${setupSession.url}`);
// 3. Wait for the user to complete OAuth
let completed = await metorial.providerDeployments.setupSessions.waitForCompletion([
setupSession
]);
// 4. Use the auth config in a connected session
let session = await metorial.connect({
adapter: metorialAiSdk(),
providers: [
{
providerDeploymentId: 'your-slack-deployment-id',
providerAuthConfigId: completed[0]!.authConfig!.id
}
]
});
// Pass session.tools() to your model SDK
For a multi-provider OAuth example, see examples/typescript-ai-sdk/.
Multiple Providers in One Session
Combine providers freely in a single session โ each can use a different auth method:
providers: [
{ providerDeploymentId: 'your-search-deployment-id' },
{
providerDeploymentId: 'your-slack-deployment-id',
providerAuthConfigId: 'slack-auth-config-id'
},
{
providerDeploymentId: 'your-github-deployment-id',
providerAuthConfig: {
providerAuthMethodId: 'github-auth-method-id',
credentials: { access_token: 'ghp_...' }
}
}
];
Session Templates