MCP server
by dwsy
Magic-API is an advanced API documentation platform for managing, debugging, and exploring your swagger API and openapi
Connects to Magic-API development environments to manage APIs, debug scripts with breakpoints, and search through API documentation and code.
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.
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.
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.
Add new capabilities to Claude beyond text generation
Example
Access external data sources, execute code, interact with tools and services
Transform Claude from chatbot to action-taking agent
Provide Claude with access to relevant context and data
Example
Load project documentation, access knowledge bases, query databases
Get more accurate, context-aware responses
Automate multi-step workflows combining AI and external tools
Example
Research → Summarize → Create document → Send notification
Complete complex tasks end-to-end without manual steps
Share your MCP server with the developer community
Magic-API is among the better-indexed MCP projects we tried; the explainx.ai summary tracks the official description.
Strong directory entry: Magic-API surfaces stars and publisher context so we could sanity-check maintenance before adopting.
I recommend Magic-API for teams standardizing on MCP; the explainx.ai page compares cleanly with sibling servers.
We wired Magic-API into a staging workspace; the listing’s GitHub and npm pointers saved time versus hunting across READMEs.
Magic-API is a well-scoped MCP server in the explainx.ai directory — install snippets and categories matched our Claude Code setup.
Magic-API reduced integration guesswork — categories and install configs on the listing matched the upstream repo.
Magic-API has been reliable for tool-calling workflows; the MCP profile page is a good permalink for internal docs.
Magic-API has been reliable for tool-calling workflows; the MCP profile page is a good permalink for internal docs.
Strong directory entry: Magic-API surfaces stars and publisher context so we could sanity-check maintenance before adopting.
I recommend Magic-API for teams standardizing on MCP; the explainx.ai page compares cleanly with sibling servers.
showing 1-10 of 34
本项目集成了 Model Context Protocol (MCP) 功能,为 Magic-API 开发提供高级交互能力。
# 如果尚未安装 uv (推荐方式)
pip install uv
# 安装项目依赖
uv sync
# 或者安装 fastmcp
uv add fastmcp
{
"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 的 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 搜索知识库,代码编写前必须获取完整语法规则。
🧭 按核心工作流顺序完成需求洞察→语法对齐→资源定位→实现调试→结果反馈。
{
"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 管理到调试和部署,全方位提升开发效率。
Magic-API MCP Server 提供了可复用的提示词模板,帮助您快速配置专业的 Magic-API 开发者助手。
生成专业的 Magic-API 开发者助手提示词,包含:
使用方法:
# 通过 MCP 客户端调用
prompt = await client.get_prompt("magic_api_developer_guide")
content = prompt.messages[0].content.text
适用场景:
本项目支持多种工具组合,可根据需要选择:
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
}
}
}
Magic-API MCP 服务器为 Magic-API 开发提供以下专业工具:
系统信息和元数据工具
文档查询与知识库工具,覆盖语法、实践、示例与流程
API调用和测试工具,支持灵活的接口调用和测试
Magic-API MCP Server 支持多种API响应格式的智能成功/失败判断:
优先级顺序:
message="success" - 最高优先级,直接匹配message字段是否等于"success"支持的响应格式示例:
// 标准格式
{"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
完整的资源管理系统,支持资源树查询与批量操作
高效的资源查询和检索工具
强大的调试功能,支持断点管理和调试会话
内容搜索与定位
完整的备份管理功能
Java类和方法检索工具
智能代码生成功能(需启用后使用)
提供可复用的提示词模板,确保助手严格遵循 MCP 工具化流程
magicapi_tools/utils/kb_practices.py 新增 "mcp_tool_driven" 等工作流,调用 get_development_workflow 或 get_practices_guide 时可获取:
Prerequisites
Time Estimate
15-60 minutes depending on server complexity
Steps
Troubleshooting
✓ Do
✗ Don't
💡 Pro Tips
Architecture
Model Context Protocol standardizes how AI hosts (Claude, Cursor) communicate with external tools and data sources through server implementations.
Protocols
Compatibility
✓ Use when
Use when you need Claude to access external data, execute actions, or integrate with tools. Best for extending AI capabilities beyond conversation.
✗ Avoid when
Avoid when native integrations exist (use official APIs directly), for real-time critical systems, or when security/compliance requires zero external dependencies.