Back to MCP directory
publicPublicdnsLocal runtime

Meilisearch MCP Server

Meilisearch的MCP服务器实现,为AI助手提供标准化接口与Meilisearch交互

article

README

🚀 Meilisearch MCP 服务器

Meilisearch MCP 服务器是一个强大的工具,它提供了丰富的搜索和索引管理功能,支持异步任务和日志记录等高级特性,能帮助开发者高效地构建搜索服务。

smithery badge

🚀 快速开始

package.json 中配置以下内容:

{
  "scripts": {
    "start": "mcp-server"
  }
}

然后运行:

npm run start

✨ 主要特性

  • 搜索功能:支持基本搜索和高级搜索,满足不同场景的搜索需求。
  • 索引管理:可以方便地创建和删除索引。
  • 高级功能:具备异步任务和日志记录功能,提升系统的可维护性和性能。

📦 安装指南

安装步骤

  1. 克隆仓库

    git clone https://github.com/your-username/meilisearch-mcp-server.git
    cd meilisearch-mcp-server
    
  2. 安装依赖

    npm install
    
  3. 启动服务器

    npm start
    

💻 使用示例

基础用法

const mcp = require('meilisearch-mcp-server');

async function main() {
  await mcp.createIndex('test_index');
  const result = await mcp.search('test_index', 'test_query');
  console.log(result);
}

main().catch(console.error);

高级用法

const mcp = require('meilisearch-mcp-server');

async function main() {
  // 创建索引
  await mcp.createIndex('complex_search');

  // 添加文档
  const documents = [
    { id: 1, title: 'Introduction to Node.js', content: 'Learn Node.js basics.' },
    { id: 2, title: 'Advanced React Patterns', content: 'Master React techniques.' }
  ];
  await mcp.addDocuments('complex_search', documents);

  // 高级搜索
  const result = await mcp.advancedSearch('complex_search', {
    bool: {
      must: [
        { term: { field: 'status', value: 'active' } },
        { match_phrase: { field: 'content', value: 'Learn Node.js' } }
      ]
    }
  });

  console.log(result);
}

main().catch(console.error);

📚 详细文档

配置文件

创建或修改 config.json 文件:

{
  "host": "localhost",
  "port": 3000,
  "api_key": "your_api_key"
}

功能模块

搜索功能

  • 基本搜索
    const result = await mcp.search({
      index: 'your_index',
      query: 'search_term'
    });
    

- **高级搜索**
  ```javascript
  const result = await mcp.advancedSearch({
    index: 'your_index',
    query: {
      bool: {
        must: [
          { term: { field: 'status', value: 'active' } }
        ]
      }
    }
  });

索引管理

  • 创建索引
    await mcp.createIndex('new_index');
    

- **删除索引**
  ```javascript
  await mcp.deleteIndex('existing_index');

高级功能

异步任务

const taskId = await mcp.startTask('your_task_description');
await mcp.waitForTask(taskId);

日志记录

  • 启用日志
    mcp.enableLogging(true);
    

- **查看日志**
  ```javascript
  const logs = await mcp.fetchLogs();

整合指南

集成步骤

  1. 安装依赖:

    npm install meilisearch-mcp-server
    
  2. 初始化模块:

    const mcp = require('meilisearch-mcp-server');
    
  3. 启动服务:

    mcp.startServer(3000);
    

配置选项

mcp.configure({
  host: 'localhost',
  port: 3000,
  logging: true,
  api_key: 'your_api_key'
});

错误处理

常见错误

  • 未找到索引
    mcp.getIndex('nonexistent_index').catch(err => console.error(err.message));
    

- **API 错误**
  ```javascript
  mcp.search('your_index', 'invalid_query').catch(err => console.error(err.status, err.data));

参考文档

API 文档

社区资源

📄 许可证

本项目遵循 MIT 协议,详见 LICENSE 文件。

贡献指南

欢迎 fork 和提交 Pull Request!

help

Runtime guide

cloud

Hosted runtime

Hosted servers run from a provider-managed environment. You usually connect the MCP client to the hosted endpoint or follow the provider's authorization flow, without keeping a local process alive

  1. Open provider connection page
  2. Authorize or copy endpoint
  3. Connect from your MCP client
terminal

Local runtime / other methods

Local servers run on your own machine or infrastructure. You normally copy the server_config into your MCP client, install the required package, and provide env variables from env_schema when needed

  1. Copy server_config
  2. Install required package
  3. Fill env variables and restart client