Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Meilisearch is a search engine for user-facing search and AI retrieval. This lib
- [Quick Start](#quick-start)
- [Setup](#setup)
- [Example](#example)
- [Using Meilisearch MCP](#using-meilisearch-mcp)
- [API Reference](#api-reference)
- [Contributing](#contributing)
- [License](#license)
Expand Down Expand Up @@ -98,6 +99,46 @@ const { text } = await generateText({
console.log(text);
```

## Using Meilisearch MCP

You can also connect your agent to the **Meilisearch MCP server**. The AI SDK can wrap tools from MCP servers and expose them like any other tool.

```bash
npm install @ai-sdk/mcp
```

```ts
import { createMCPClient } from "@ai-sdk/mcp";
import { generateText, isStepCount } from "ai";
import { openai } from "@ai-sdk/openai";

const mcpClient = await createMCPClient({
transport: {
type: "http",
url: "https://your-project.meilisearch.io/mcp",
headers: { Authorization: "Bearer YOUR_API_KEY" },
},
});

try {
const tools = await mcpClient.tools();

const { text } = await generateText({
model: openai("gpt-5.4-mini"),
tools,
// Allow several steps: list indexes, describe, search, then answer
stopWhen: isStepCount(5),
prompt: "Recommend recent action movies about revenge",
});

console.log(text);
} finally {
await mcpClient.close();
}
```

For the list of available tools, limitations, and troubleshooting, see the [Meilisearch MCP documentation](https://www.meilisearch.com/docs/getting_started/integrations/mcp).

## API Reference

### Search tool
Expand Down
Loading