AI管道集成工具

Mage.ai MCP集成是一个全面的模型上下文协议集成工具,允许AI助手如Anthropic的Claude高效地与Mage数据管道协同工作,支持浏览、编辑、执行和创建管道。

  • by KhushiBaby
  • Python
  • 本地部署
  • 3 星标
  • 更新于
在 GitHub 查看 KhushiBaby/mage-mcp-server

使用说明

Mage.ai MCP集成

一种全面的模型上下文协议(MCP)集成 Mage.ai,允许像Anthropic的Claude这样的人工智能助手高效地使用Mage数据管道。

特性

  • 浏览管道:探索所有Mage.ai管道及其组件
  • 查看和编辑代码:读取和修改块代码
  • 执行管道:运行整个管道或单个区块
  • 搜索功能:按名称、类型或内容查找块
  • 管道创建:从头开始创建新的管道和块

安装

# Clone the repository
git clone https://github.com/yourusername/mage-mcp.git
cd mage-mcp

# Install dependencies
pip install -r requirements.txt

配置

可以使用环境变量或命令行参数配置服务器:

  • MAGE_API_URL:Mage.ai API的URL(默认值: http://localhost:6789/api/)
  • MAGE_API_KEY:用于身份验证的API密钥(如果需要)

创建一个 .env 持久配置文件:

MAGE_API_URL=http://localhost:6789/api/
MAGE_API_KEY=your_api_key_if_needed

用法

运行服务器

使用提供的脚本启动MCP服务器:

# Using stdio transport (default)
python run_server.py

# Using SSE transport
python run_server.py --transport sse --host localhost --port 3000

# Additional options
python run_server.py --api-url http://your-mage-instance:6789/api/ --api-key your_key --debug

使用Claude Desktop进行安装

为了获得最佳体验,请直接使用Claude Desktop安装此服务器:

# Using mcp CLI
mcp install run_server.py --name "Mage.ai Manager"

# With environment variables
mcp install run_server.py -v MAGE_API_URL=http://localhost:6789/api/ -v MAGE_API_KEY=your_key

发展模式

对于测试和开发:

mcp dev run_server.py

MCP资源和工具

资源

  • mage://pipelines -列出所有管道
  • mage://pipelines/{pipeline_uuid} -获取管道详细信息
  • mage://pipelines/{pipeline_uuid}/blocks -列出管道中的块
  • mage://pipelines/{pipeline_uuid}/blocks/{block_uuid} -获取区块详细信息
  • mage://pipelines/{pipeline_uuid}/blocks/{block_uuid}/content -获取块代码
  • mage://pipelines/{pipeline_uuid}/content -获取整个管道内容
  • mage://pipelines/{pipeline_uuid}/execution -获取管道执行详细信息
  • mage://blocks/search/{query} -按名称、类型或内容搜索块

工具

  • list_all_pipelines() -列出所有管道及其详细信息
  • get_pipeline_details(pipeline_uuid) -获取管道信息
  • list_pipeline_blocks(pipeline_uuid) -列出管道中的块
  • get_block_content(pipeline_uuid, block_uuid) -获取块代码
  • create_pipeline(name, description, pipeline_type) -创建新管道
  • create_block(pipeline_uuid, name, block_type, language, content, upstream_blocks) -创建块
  • update_block_content(pipeline_uuid, block_uuid, content) -更新块代码
  • execute_pipeline(pipeline_uuid) -运行管道
  • execute_block(pipeline_uuid, block_uuid) -运行特定块
  • get_pipeline_code(pipeline_uuid) -获取完整的管道代码

交互示例

User: Show me all the pipelines in Mage.ai.
Claude: Let me check what pipelines are available in your Mage.ai instance.

[Lists all pipelines with descriptions and types]

User: Can you show me the blocks in the data_ingestion pipeline?
Claude: Here are all the blocks in the data_ingestion pipeline:

[Lists all blocks with their types, languages, and status]

User: I need to modify the 'transform_data' block to fix a bug.
Claude: Let me help you with that. First, let's look at the current code:

[Shows the current block code]

Here's how we can fix the bug:
[Explains the issue and suggests changes]

Would you like me to update the block with these changes?

User: Yes, please update it.
Claude: I've updated the block. Here's the new content:

[Shows the updated code]

The changes have been saved successfully.

贡献

欢迎投稿!请随时提交拉取请求。

许可证

此项目根据MIT许可证获得许可-有关详细信息,请参阅许可证文件。