Magic-API▌

by dwsy
Magic-API is an advanced API documentation platform for managing, debugging, and exploring your swagger API and openapi
Integrates with Magic-API development environments to provide API management, debugging with breakpoints and step execution, documentation access, backup/restore functionality, Java class introspection, and content search across API scripts through REST endpoints and WebSocket interfaces.
best for
- / Magic-API developers building REST APIs
- / Teams debugging complex API scripts
- / Developers learning Magic-Script syntax
- / API documentation and code exploration
capabilities
- / Debug Magic-API scripts with breakpoints and step execution
- / Create and manage API endpoints and resources
- / Search across API scripts and documentation
- / Access Java class introspection data
- / Backup and restore API configurations
- / Query Magic-Script syntax rules and development workflows
what it does
Connects to Magic-API development environments to manage APIs, debug scripts with breakpoints, and search through API documentation and code.
about
Magic-API is a community-built MCP server published by dwsy that provides AI assistants with tools and capabilities via the Model Context Protocol. Magic-API is an advanced API documentation platform for managing, debugging, and exploring your swagger API and openapi It is categorized under developer tools.
how to install
You can install Magic-API in your AI client of choice. Use the install panel on this page to get one-click setup for Cursor, Claude Desktop, VS Code, and other MCP-compatible clients. This server runs locally on your machine via the stdio transport.
license
MIT
Magic-API is released under the MIT license. This is a permissive open-source license, meaning you can freely use, modify, and distribute the software.
readme
Magic-API MCP Server 使用指南
🚀 快速开始
本项目集成了 Model Context Protocol (MCP) 功能,为 Magic-API 开发提供高级交互能力。
1. 安装与测试
# 如果尚未安装 uv (推荐方式)
pip install uv
# 安装项目依赖
uv sync
# 或者安装 fastmcp
uv add fastmcp
2. MCP 配置
基础配置(适用于大多数用户):
{
"mcpServers": {
"magic-api-mcp-server": {
"command": "uvx",
"args": ["magic-api-mcp-server@latest", "--transport", "stdio"],
"timeout": 600
}
}
}
高级配置(需要自定义环境):
{
"mcpServers": {
"magic-api-mcp-server": {
"command": "uvx",
"args": ["magic-api-mcp-server@latest", "--transport", "stdio"],
"timeout": 600,
"env": {
"MAGIC_API_BASE_URL": "http://127.0.0.1:10712",
"MAGIC_API_WS_URL": "ws://127.0.0.1:10712/magic/web/console",
"MAGIC_API_TIMEOUT_SECONDS": "30.0",
"LOG_LEVEL": "INFO"
}
}
}
}
MCP 提示词 (非常重要)
提示词概述
当使用支持 MCP 的 AI 助手(如 Claude Desktop、Cursor 等)时,请务必使用以下提示词让助手了解 Magic-API MCP Server 的功能和用途。
核心提示词
你现在是一个专业的 Magic-API 开发者助手,具备强大的 MCP (Model Context Protocol) 工具(Magic-API MCP Server)支持。
## 🎯 你的核心职能
- 提供 Magic-API 脚本语法指导和最佳实践
- 帮助用户编写高效的数据库查询和业务逻辑
- 解答 Magic-API 配置和部署相关问题
- 提供代码示例和调试建议
## ⚠️ 强制要求:代码编写前语法规则获取
**重要:** 在编写任何 Magic-Script 代码前,你必须首先调用 `get_full_magic_script_syntax` 工具获取完整的语法规则。
Magic-Script 是一种小众语言,具有独特的语法规则,不遵循标准 JavaScript 或 Java 语法。
不获取完整语法规则而直接编写代码将导致严重的语法错误。
**重要:** 在API脚本开发(create/edit API scripts)编写编辑脚本前,你必须:
1. 调用 `get_full_magic_script_syntax` 获取完整的 Magic-Script 语法规则
2. 调用 `get_development_workflow` 获取开发工作流指南
3. 遵循标准化的开发流程:准备→信息采集→执行→校验→总结
## 🧭 MagicAPI MCP Agent 核心工作流
> 流转需按顺序推进,用户可随时指令跳转。
按照以下流程调用 MCP 工具,确保每一步都有依据:
- **[需求洞察]** → `search_knowledge`、`get_development_workflow`,识别目标场景与约束
- **语法对齐** → `get_full_magic_script_syntax`、`get_script_syntax`,确认Magic-Script写法
- **[资源定位]** → `get_resource_tree`、`get_api_details_by_path`、`search_api_endpoints`,查阅现有资产
- **[实现与调试]** → `create_api_resource`、`replace_api_script`、`call_magic_api`、`call_api_with_debug`、`set_breakpoint`,落实代码并验证
- **[结果反馈]** → `get_practices_guide`、`get_common_pitfalls`、`list_backups`,输出结论并保证可回溯
## 🛠️ 可用工具能力
在本文档第 3 节中详细介绍了所有可用工具,包括:
- **文档工具** (DocumentationTools): 语法、文档、示例、最佳实践等
- **API 工具** (ApiTools): 接口调用和测试
- **资源管理工具** (ResourceManagementTools): 资源的CRUD操作
- **查询工具** (QueryTools): 资源检索
- **调试工具** (DebugTools): 断点管理
- **搜索工具** (SearchTools): 内容搜索
- **备份工具** (BackupTools): 数据备份管理
- **类方法工具** (ClassMethodTools): Java类和方法查询
- **系统工具** (SystemTools): 系统元信息查询
详情请参见下方第 3 节 "本项目 MCP 工具功能"。
## 📋 使用指南
##### 问题分析
首先理解用户的需求和上下文,再选择合适的工具。
##### 知识搜索策略
🔍 **当你不确定某个功能或语法时,优先使用搜索工具:**
- 调用 `search_knowledge` 进行全文搜索,关键词可以是功能名称、语法关键词等
- 例如:搜索"数据库连接"、"缓存使用"、"文件上传"等
- 可以限定搜索分类:syntax(语法)、modules(模块)、functions(函数)、web_docs(文档)等
##### 最佳实践
- 🔍 **遇到不确定的问题时,先搜索知识库**
- 📚 优先使用文档查询工具了解功能
- 🔍 开发时先用查询工具了解现有资源
- 🐛 调试时设置断点逐步排查问题
- 💾 重要的变更操作前先备份
##### 错误处理
- 🔍 遇到未知错误时,使用 `search_knowledge` 搜索相关解决方案
- 🌐 网络错误时检查 Magic-API 服务状态
- 🔐 权限错误时确认用户认证配置
- 📁 资源不存在时先用查询工具确认路径
## ⚠️ 注意事项
- 所有工具都支持中文和英文参数
- API 调用支持自定义请求头和参数
记住:你现在具备了完整的 Magic-API 开发工具链,可以为用户提供专业、高效的开发支持!
简短提示词 (适用于快速配置)
你是一个专业的 Magic-API 开发者助手,拥有以下 MCP 工具:
⚠️ 强制要求:
- 编写任何 Magic-Script 代码前必须先调用 get_full_magic_script_syntax 获取完整语法规则!
- API脚本开发(create/edit API scripts)编写编辑脚本前必须调用 get_development_workflow 获取工作流指南!
📚 文档查询: get_full_magic_script_syntax[强制], get_development_workflow[强制], search_knowledge[推荐], get_script_syntax, get_module_api, get_best_practices, get_examples
🔧 API 调用: call_magic_api
📁 资源管理: get_resource_tree, create_api_resource, delete_resource
🔍 查询工具: get_api_details_by_path, get_api_details_by_id, search_api_endpoints
🐛 调试工具: set_breakpoint, resume_breakpoint_execution, call_api_with_debug
🔎 搜索工具: search_api_scripts, search_todo_comments
💾 备份工具: list_backups, create_full_backup, rollback_backup
⚙️ 系统工具: get_assistant_metadata
🔍 不确定时优先使用 search_knowledge 搜索知识库,代码编写前必须获取完整语法规则。
🧭 按核心工作流顺序完成需求洞察→语法对齐→资源定位→实现调试→结果反馈。
配置提示词 (Cursor/VS Code 等编辑器)
{
"mcpServers": {
"magic-api-mcp-server": {
"command": "uvx",
"args": ["magic-api-mcp-server@latest", "--transport", "stdio"],
"timeout": 600,
"env": {
"MAGIC_API_BASE_URL": "http://127.0.0.1:10712",
"MAGIC_API_WS_URL": "ws://127.0.0.1:10712/magic/web/console"
}
}
}
}
本项目 MCP 服务器专为 Magic-API 开发者设计,提供了一套完整的工作流工具,从脚本编写、API 管理到调试和部署,全方位提升开发效率。
🧠 Prompts (提示词模板)
Magic-API MCP Server 提供了可复用的提示词模板,帮助您快速配置专业的 Magic-API 开发者助手。
可用 Prompts
magic_api_developer_guide
生成专业的 Magic-API 开发者助手提示词,包含:
- 完整的工具能力介绍
- 使用指南和最佳实践
- 错误处理建议
- 工具选择策略
使用方法:
# 通过 MCP 客户端调用
prompt = await client.get_prompt("magic_api_developer_guide")
content = prompt.messages[0].content.text
适用场景:
- 配置新的 AI 助手
- 标准化开发工作流
- 培训新团队成员
- 创建一致的开发环境
工具组合配置
本项目支持多种工具组合,可根据需要选择:
full: 完整工具集 - 适用于完整开发环境 (默认)minimal: 最小工具集 - 适用于资源受限环境development: 开发工具集 - 专注于开发调试production: 生产工具集 - 生产环境稳定运行documentation_only: 仅文档工具 - 文档查询和学习api_only: 仅API工具 - 接口测试和调用backup_only: 仅备份工具 - 数据备份和管理class_method_only: 仅类方法工具 - Java类和方法查询search_only: 仅搜索工具 - 快速搜索定位
工具组合使用场景:
| 场景 | 组合模式 | 适用环境 | 特点 |
|---|---|---|---|
| 新手学习 | documentation_only | 学习阶段 | 专注文档查询和语法学习 |
| API开发 | development | 开发环境 | 接口开发、测试和调试 |
| 生产运维 | production | 生产环境 | 系统运维和资源管理 |
| 问题调试 | minimal | 调试场景 | 问题排查,启用DEBUG日志 |
基础配置模板:
{
"mcpServers": {
"magic-api-server": {
"command": "uvx",
"args": ["magic-api-mcp-server@latest", "--composition", "{组合模式}", "--transport", "stdio"],
"timeout": 600
}
}
}
3. 本项目 MCP 工具功能
Magic-API MCP 服务器为 Magic-API 开发提供以下专业工具:
3.1 系统工具 (SystemTools)
系统信息和元数据工具
- get_assistant_metadata: 获取Magic-API MCP Server的完整元信息,包括版本、功能列表和配置
3.2 文档工具 (DocumentationTools)
文档查询与知识库工具,覆盖语法、实践、示例与流程
- get_full_magic_script_syntax ⚠️ [强制]: 获取完整的Magic-Script语法规则 - 大模型编写代码前必须调用此工具
- search_knowledge 🔍 [推荐]: 在Magic-API知识库中进行全文搜索 - 不确定时优先使用此工具
- get_magic_script_syntax: 查询 Magic-Script 语法规则与示例
- get_magic_script_examples: 获取脚本示例,支持关键词过滤
- get_magic_api_docs: 查看官方文档索引或详细内容
- get_best_practices: 查阅最佳实践列表
- get_common_pitfalls: 查阅常见问题与规避建议
- get_development_workflow: 获取标准化开发流程指南
- get_module_api_docs: 查询内置模块 API 文档
- list_available_modules: 查看可用模块与自动导入模块
- get_function_docs: 获取内置函数库文档
- get_extension_docs: 获取类型扩展文档(默认禁用,启用后可用)
- get_config_docs: 获取配置项文档(默认禁用)
- get_plugin_docs: 获取插件系统文档(默认禁用)
- get_examples / list_examples: 统一查询示例分类与代码片段
- get_docs: 获取 Magic-API 官方站点索引
3.3 API 工具 (ApiTools)
API调用和测试工具,支持灵活的接口调用和测试
- call_magic_api: 调用Magic-API接口并返回请求结果,支持GET、POST、PUT、DELETE等HTTP方法
🔍 API响应智能检查
Magic-API MCP Server 支持多种API响应格式的智能成功/失败判断:
优先级顺序:
- 🚀
message="success"- 最高优先级,直接匹配message字段是否等于"success" - 🔢 Code字段检查 - 检查code字段是否等于配置的成功码(默认1,可配置)
- 📊 Status字段检查 - 检查status字段(某些自定义响应格式)
- ❌ 错误字段检查 - 检查是否存在error、exception、failure等错误字段
- ✅ 默认成功 - 兼容模式,对没有明确标识的响应默认视为成功
支持的响应格式示例:
// 标准格式
{"code": 1, "message": "success", "data": {...}}
// 自定义状态码
{"code": 200, "message": "ok", "data": {...}}
// Message优先(最高优先级)
{"code": 500, "message": "success", "data": {...}} // 仍然成功!
{"code": 1, "message": "operation failed", "data": {...}} // 失败!
// 自定义格式
{"status": 1, "msg": "success", "body": {...}}
// 错误响应
{"code": 500, "message": "Internal Error", "data": {...}}
{"error": "something went wrong"}
配置方式:
# 通过环境变量配置成功状态码和消息
MAGIC_API_SUCCESS_CODE=200
MAGIC_API_SUCCESS_MESSAGE=ok
MAGIC_API_INVALID_CODE=400
MAGIC_API_EXCEPTION_CODE=500
3.4 资源管理工具 (ResourceManagementTools)
完整的资源管理系统,支持资源树查询与批量操作
- get_resource_tree: 获取资源树,支持过滤、导出多种格式(JSON/CSV/树形),向后兼容CSV参数
- save_group: 保存分组,支持单个分组创建或更新,包含完整的分组配置选项
- create_api_resource / create_api_endpoint: 创建单个或批量 API
- replace_api_script: 按接口 ID 替换 Magic-Script 片段,支持一次或全量替换
- copy_resource: 复制资源
- move_resource: 移动资源
- delete_resource: 删除单个或批量资源
- lock_resource / unlock_resource: 批量锁定或解锁资源
- list_resource_groups: 列出与搜索资源分组
- get_resource_stats: 统计资源数量与类型分布
3.5 查询工具 (QueryTools)
高效的资源查询和检索工具
- get_api_details_by_path: 根据API路径直接获取接口的详细信息,支持模糊匹配
- get_api_details_by_id: 根据接口ID获取完整的接口详细信息和配置
- search_api_endpoints: 搜索和过滤Magic-API接口端点,返回包含ID的完整信息列表
3.6 调试工具 (DebugTools)
强大的调试功能,支持断点管理和调试会话
- set_breakpoint: 在指定API脚本中设置断点
- remove_breakpoint: 移除指定的断点
- resume_breakpoint_execution: 恢复断点执行,继续运行调试脚本
- step_over_breakpoint: 单步执行,越过当前断点继续执行
- list_breakpoints: 列出所有当前设置的断点
- call_api_with_debug: 调用指定接口并在命中断点处暂停
- execute_debug_session: 执行完整的调试会话
- get_debug_status: 获取当前调试状态
- clear_all_breakpoints: 清除所有断点
- get_websocket_status: 获取WebSocket连接状态
3.7 搜索工具 (SearchTools)
内容搜索与定位
- search_api_scripts: 在所有 API 脚本中检索关键词
- search_todo_comments: 搜索脚本中的 TODO 注释(默认禁用)
3.8 备份工具 (BackupTools)
完整的备份管理功能
- list_backups: 查询备份列表,支持时间戳过滤和名称过滤
- get_backup_history: 获取备份历史记录
- get_backup_content: 获取指定备份的内容
- rollback_backup: 回滚到指定的备份版本
- create_full_backup: 创建完整的系统备份
3.9 类方法工具 (ClassMethodTools)
Java类和方法检索工具
- list_magic_api_classes: 列出所有Magic-API可用的类、扩展和函数,支持翻页浏览
- get_class_details: 获取指定类的详细信息,包括方法、属性和继承关系
- get_method_details: 获取指定方法的详细信息,包括参数类型和返回值
3.10 代码生成工具 (CodeGenerationTools) - 当前禁用
智能代码生成功能(需启用后使用)
- generate_crud_api: 生成完整的CRUD API接口代码
- generate_database_query: 生成数据库查询代码
- generate_api_test: 生成API接口测试代码
- generate_workflow_code: 生成工作流模板代码
3.11 提示词工具 (PromptTools)
提供可复用的提示词模板,确保助手严格遵循 MCP 工具化流程
- magic_api_developer_guide: 输出最新版“Magic-API 开发者助手”系统提示词,强调“仅依赖 MCP 工具”工作守则、六步工具工作流以及结构化输出要求
3.12 工作流知识库亮点
magicapi_tools/utils/kb_practices.py 新增 "mcp_tool_driven" 等工作流,调用 get_development_workflow 或 get_practices_guide 时可获取:
- 🔍 智能搜索驱动:遇到不
FAQ
- What is the Magic-API MCP server?
- Magic-API is a Model Context Protocol (MCP) server profile on explainx.ai. MCP lets AI hosts (e.g. Claude Desktop, Cursor) call tools and resources through a standard interface; this page summarizes categories, install hints, and community ratings.
- How do MCP servers relate to agent skills?
- Skills are reusable instruction packages (often SKILL.md); MCP servers expose live capabilities. Teams frequently combine both—skills for workflows, MCP for APIs and data. See explainx.ai/skills and explainx.ai/mcp-servers for parallel directories.
- How are reviews shown for Magic-API?
- This profile displays 10 aggregated ratings (sample rows for discoverability plus signed-in user reviews). Average score is about 4.5 out of 5—verify behavior in your own environment before production use.
Ratings
4.5★★★★★10 reviews- ★★★★★Shikha Mishra· Oct 10, 2024
Magic-API is among the better-indexed MCP projects we tried; the explainx.ai summary tracks the official description.
- ★★★★★Piyush G· Sep 9, 2024
We evaluated Magic-API against two servers with overlapping tools; this profile had the clearer scope statement.
- ★★★★★Chaitanya Patil· Aug 8, 2024
Useful MCP listing: Magic-API is the kind of server we cite when onboarding engineers to host + tool permissions.
- ★★★★★Sakshi Patil· Jul 7, 2024
Magic-API reduced integration guesswork — categories and install configs on the listing matched the upstream repo.
- ★★★★★Ganesh Mohane· Jun 6, 2024
I recommend Magic-API for teams standardizing on MCP; the explainx.ai page compares cleanly with sibling servers.
- ★★★★★Oshnikdeep· May 5, 2024
Strong directory entry: Magic-API surfaces stars and publisher context so we could sanity-check maintenance before adopting.
- ★★★★★Dhruvi Jain· Apr 4, 2024
Magic-API has been reliable for tool-calling workflows; the MCP profile page is a good permalink for internal docs.
- ★★★★★Rahul Santra· Mar 3, 2024
According to our notes, Magic-API benefits from clear Model Context Protocol framing — fewer ambiguous “AI plugin” claims.
- ★★★★★Pratham Ware· Feb 2, 2024
We wired Magic-API into a staging workspace; the listing’s GitHub and npm pointers saved time versus hunting across READMEs.
- ★★★★★Yash Thakker· Jan 1, 2024
Magic-API is a well-scoped MCP server in the explainx.ai directory — install snippets and categories matched our Claude Code setup.