Sponsored by Deepsite.site

Mybatis Mapper2sql

Created By
handsomestWei4 months ago
Automatically extract SQL statements from MyBatis mapper XML files. Support automatic mocking of SQL parameters, and support automatic connection to the database to execute SQL tests and output results.
Content

将原有的 MyBatis Mapper2SQL 工具,转型为 MCP (Model Context Protocol) 服务,使其能够在 AI 时代继续发挥价值,并与 AI 模型协作提供更强大的 SQL 提取和分析能力。

功能特性

  • SQL提取: 从MyBatis mapper XML文件中提取SQL语句
  • 参数Mock: 自动生成SQL参数,支持基于resultMap和JDBC连接的类型推断
  • SQL测试: 连接数据库执行SQL并记录执行结果

核心优势

  1. 确定性解析: 基于 MyBatis 官方解析引擎,结果稳定可靠。
  2. AI 协作: 作为 AI 的"专家工具",提供精确的 SQL 解析能力。
  3. 服务化: 通过 MCP 协议提供标准化接口。
  4. 扩展性: 支持多种数据库类型。

可用工具

本项目提供3个专业工具,满足不同场景的SQL提取需求:

1. parse_mapper

  • 功能: 基础 SQL 提取,保留占位符(不进行参数模拟)
  • 适用场景: 快速查看 SQL 结构,无需参数 mock
  • 参数:
    • filePath (string): mapper XML文件或目录路径

2. parse_mapper_and_mock

  • 功能: SQL 提取 + 参数自动 mock
  • 适用场景: 需要可执行 SQL 进行测试或分析
  • 参数:
    • filePath (string): mapper XML文件或目录路径

3. parse_mapper_and_run_test

  • 功能: SQL 提取 + 参数 mock + 执行测试
  • 适用场景: 验证 SQL 在真实数据库中的执行情况
  • 参数:
    • filePath (string): mapper XML文件或目录路径

Server Config

{
  "mcpServers": {
    "mapper2sql": {
      "command": "java",
      "args": [
        "-DdbType=mysql",
        "-DjdbcDriver=com.mysql.cj.jdbc.Driver",
        "-DjdbcDriverJar=/path/to/mysql-connector-java-8.0.33.jar",
        "-DjdbcUrl=jdbc:mysql://localhost:3306/testdb",
        "-DuserName=root",
        "-Dpassword=your_password_here",
        "-jar",
        "mapper2sql-mcp-server-1.0.0.jar"
      ],
      "env": {
        "JAVA_HOME": "/path/to/jdk17",
        "PATH": "/path/to/jdk17/bin;${PATH}"
      }
    }
  }
}
Recommend Servers
TraeBuild with Free GPT-4.1 & Claude 3.7. Fully MCP-Ready.
Context7Context7 MCP Server -- Up-to-date code documentation for LLMs and AI code editors
EdgeOne Pages MCPAn MCP service designed for deploying HTML content to EdgeOne Pages and obtaining an accessible public URL.
TimeA Model Context Protocol server that provides time and timezone conversion capabilities. This server enables LLMs to get current time information and perform timezone conversions using IANA timezone names, with automatic system timezone detection.
Baidu Map百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Amap Maps高德地图官方 MCP Server
Playwright McpPlaywright MCP server
Howtocook Mcp基于Anduin2017 / HowToCook (程序员在家做饭指南)的mcp server,帮你推荐菜谱、规划膳食,解决“今天吃什么“的世纪难题; Based on Anduin2017/HowToCook (Programmer's Guide to Cooking at Home), MCP Server helps you recommend recipes, plan meals, and solve the century old problem of "what to eat today"
WindsurfThe new purpose-built IDE to harness magic
BlenderBlenderMCP connects Blender to Claude AI through the Model Context Protocol (MCP), allowing Claude to directly interact with and control Blender. This integration enables prompt assisted 3D modeling, scene creation, and manipulation.
DeepChatYour AI Partner on Desktop
ChatWiseThe second fastest AI chatbot™
Zhipu Web SearchZhipu Web Search MCP Server is a search engine specifically designed for large models. It integrates four search engines, allowing users to flexibly compare and switch between them. Building upon the web crawling and ranking capabilities of traditional search engines, it enhances intent recognition capabilities, returning results more suitable for large model processing (such as webpage titles, URLs, summaries, site names, site icons, etc.). This helps AI applications achieve "dynamic knowledge acquisition" and "precise scenario adaptation" capabilities.
CursorThe AI Code Editor
MCP AdvisorMCP Advisor & Installation - Use the right MCP server for your needs
Serper MCP ServerA Serper MCP Server
Jina AI MCP ToolsA Model Context Protocol (MCP) server that integrates with Jina AI Search Foundation APIs.
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code
MiniMax MCPOfficial MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.
Tavily Mcp
AiimagemultistyleA Model Context Protocol (MCP) server for image generation and manipulation using fal.ai's Stable Diffusion model.