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.pyMCP资源和工具
资源
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许可证获得许可-有关详细信息,请参阅许可证文件。
