Anthropic

Connect Integrations to
Anthropic

Build advanced AI agents with Anthropic. Connect 600+ integrations, automate workflows, and deploy with ease using Metorial.

Back to Anthropic overview

Integrating Metorial with AI SDK

Learn how to connect Metorial's 600+ integrations to your Vercel AI SDK applications.

Basic Integration Pattern

The core pattern for using Metorial with AI SDK involves three steps:

  1. Initialize the Metorial client
  2. Create a provider session with your deployments
  3. Pass the session tools to your AI SDK calls

Complete Example

import { metorialAISDK } from '@metorial/ai-sdk';
import { Metorial } from 'metorial';
import { generateText, streamText } from 'ai';
import { openai } from '@ai-sdk/openai';

const metorial = new Metorial({
  apiKey: process.env.METORIAL_API_KEY
});

await metorial.withProviderSession(
  metorialAISDK,
  { serverDeployments: ['your-deployment-id'] },
  async (session) => {
    // Use with generateText
    const result = await generateText({
      model: openai('gpt-4'),
      messages: [
        { role: 'user', content: 'What meetings do I have today?' }
      ],
      tools: session.tools,
      maxSteps: 10  // Allow multiple tool calls
    });
    
    console.log(result.text);
  }
);

Streaming Responses

Metorial works seamlessly with streaming:

await metorial.withProviderSession(
  metorialAISDK,
  { serverDeployments: ['your-deployment-id'] },
  async (session) => {
    const result = streamText({
      model: openai('gpt-4'),
      messages: [
        { role: 'user', content: 'Send a Slack message to #general' }
      ],
      tools: session.tools
    });
    
    for await (const chunk of result.textStream) {
      process.stdout.write(chunk);
    }
  }
);

Tool Execution

The AI SDK automatically handles tool execution when you provide tools. The model will:

  1. Analyze available tools from your Metorial deployment
  2. Decide which tools to call based on the user's request
  3. Execute tools through Metorial's MCP infrastructure
  4. Use the results to formulate its response

Session Lifecycle

The withProviderSession method manages the connection lifecycle:

  • Opens a session when called
  • Makes tools available during the callback
  • Automatically closes the session when done
  • Handles errors and cleanup

Error Handling

Always wrap your Metorial calls in try-catch blocks:

try {
  await metorial.withProviderSession(
    metorialAISDK,
    { serverDeployments: ['your-deployment-id'] },
    async (session) => {
      // Your code here
    }
  );
} catch (error) {
  console.error('Metorial session error:', error);
}

Common Use Cases

  • Calendar management: "What's on my calendar this week?"
  • Communication: "Send a message in Slack"
  • Data retrieval: "Get the latest data from our database"
  • Document management: "Summarize the document in Google Drive"
  • Task management: "Create a Jira ticket for this bug"

Anthropic on Metorial

Integrate Anthropic Claude with Metorial to give your AI agents access to over 600 powerful integrations through the Model Context Protocol (MCP). Our open-source platform is purpose-built for developers creating intelligent applications with Claude, Anthropic's advanced language model. With Metorial's Python and TypeScript SDKs, connecting Claude to calendars, CRMs, databases, project management tools, and hundreds of other services takes just a couple of lines of code. Stop spending days building custom integrations—Metorial handles authentication, API calls, and data formatting automatically so you can focus on crafting intelligent agent behaviors and user experiences. Whether you're building customer support bots, research assistants, or workflow automation with Claude, Metorial provides the integration infrastructure you need. Our MCP-native approach ensures your Anthropic-powered agents can interact with the tools your users already depend on, creating more valuable and practical AI solutions that integrate seamlessly into existing workflows.

Connect anything. Anywhere.

Ready to build with Metorial?

Let's take your AI-powered applications to the next level, together.

About Metorial

Metorial provides developers with instant access to 600+ MCP servers for building AI agents that can interact with real-world tools and services. Built on MCP, Metorial simplifies agent tool integration by offering pre-configured connections to popular platforms like Google Drive, Slack, GitHub, Notion, and hundreds of other APIs. Our platform supports all major AI agent frameworks—including LangChain, AutoGen, CrewAI, and LangGraph—enabling developers to add tool calling capabilities to their agents in just a few lines of code. By eliminating the need for custom integration code, Metorial helps AI developers move from prototype to production faster while maintaining security and reliability. Whether you're building autonomous research agents, customer service bots, or workflow automation tools, Metorial's MCP server library provides the integrations you need to connect your agents to the real world.

Star us on GitHub