> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mcplug.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Usage

> Use of the MCPlug client with Vercel AI SDK

### Installation

The mcplug client is a npm package that you can install in your application.

```bash theme={null}
npm install @mcplug/client
```

### Example

```ts theme={null}
import { mcplug } from "@mcplug/client/ai";
import { generateText } from "ai";
import { openai } from "@ai-sdk/openai";

const tools = await mcplug({
  token: PLUG_TOKEN,
  id: PLUG_ID
});

const result = await generateText({
  model: openai("gpt-4o"),
  messages: [
    {
      role: "user",
      content: "What is the weather in Paris?"
    }
  ],
  // Necessary to let the LLM use the tools in a loop if needed and generate a response
  maxSteps: 10,
  tools
});
```

### Using constants

To use constants, you need to pass them in the `constants` property of the `mcplug` function.

You do not need to pass the constants if you have already defined them inside your plug dashboard.

```ts theme={null}
const tools = await mcplug({
  token: PLUG_TOKEN,
  id: PLUG_ID,
  constants: {
    WEATHER_API_KEY: "your-api-key-here",
    AUTH_TOKEN: "your-auth-token"
  }
});
```
