Skip to content

Commit 0aef5f2

Browse files
committed
upd 将tool注册调整到server build之前
1 parent 897d0ac commit 0aef5f2

File tree

8 files changed

+478
-52
lines changed

8 files changed

+478
-52
lines changed

Dockerfile

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
FROM openjdk:11-jre-slim
2+
3+
# 设置工作目录
4+
WORKDIR /app
5+
6+
# 复制jar文件
7+
COPY target/mapper2sql-mcp-server-1.0.0.jar app.jar
8+
9+
# 创建非root用户
10+
RUN addgroup --system appgroup && \
11+
adduser --system --ingroup appgroup appuser
12+
13+
# 设置权限
14+
RUN chown -R appuser:appgroup /app
15+
USER appuser
16+
17+
# 暴露端口(如果需要HTTP接口)
18+
EXPOSE 8080
19+
20+
# 设置JVM参数
21+
ENV JAVA_OPTS="-Xmx512m -Xms256m"
22+
23+
# 启动命令
24+
ENTRYPOINT ["sh", "-c", "java $JAVA_OPTS -jar app.jar"]

docker-compose.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
version: '3.8'
2+
3+
services:
4+
mapper2sql-mcp:
5+
build: .
6+
container_name: mapper2sql-mcp-server
7+
ports:
8+
- "8080:8080"
9+
environment:
10+
- JAVA_OPTS=-Xmx512m -Xms256m
11+
volumes:
12+
# 挂载mapper文件目录
13+
- ./mapper-files:/app/mapper-files:ro
14+
# 挂载输出目录
15+
- ./output:/app/output
16+
restart: unless-stopped
17+
healthcheck:
18+
test: ["CMD", "java", "-jar", "app.jar", "--health"]
19+
interval: 30s
20+
timeout: 10s
21+
retries: 3

mcp-config-example.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"mcpServers": {
3+
"mapper2sql": {
4+
"command": "java",
5+
"args": [
6+
"-DdbType=mysql",
7+
"-DjdbcDriver=com.mysql.cj.jdbc.Driver",
8+
"-DjdbcDriverJar=/path/to/mysql-connector-java-8.0.33.jar",
9+
"-DjdbcUrl=jdbc:mysql://localhost:3306/testdb",
10+
"-DuserName=root",
11+
"-Dpassword=your_password_here",
12+
"-jar",
13+
"mapper2sql-mcp-server-1.0.0.jar"
14+
],
15+
"env": {
16+
"JAVA_HOME": "/path/to/jdk17"
17+
}
18+
}
19+
}
20+
}

mcp-registry.json

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
{
2+
"name": "mapper2sql",
3+
"version": "1.0.0",
4+
"description": "Extract SQL from MyBatis mapper XML files with parameter mocking and testing capabilities",
5+
"author": "handsomestWei",
6+
"license": "MIT",
7+
"repository": {
8+
"type": "git",
9+
"url": "https://github.com/handsomestWei/mybatis-mapper2sql-mcp-server"
10+
},
11+
"keywords": [
12+
"mybatis",
13+
"sql",
14+
"mapper",
15+
"xml",
16+
"extraction",
17+
"testing",
18+
"mcp"
19+
],
20+
"tools": [
21+
{
22+
"name": "parse_mapper",
23+
"description": "Parse MyBatis mapper XML files and extract SQL statements with placeholders",
24+
"inputSchema": {
25+
"type": "object",
26+
"properties": {
27+
"file_path": {
28+
"type": "string",
29+
"description": "Path to mapper XML file or directory"
30+
}
31+
},
32+
"required": [
33+
"file_path"
34+
]
35+
}
36+
},
37+
{
38+
"name": "parse_mapper_with_mock",
39+
"description": "Parse MyBatis mapper XML files and extract SQL statements with parameter mocking",
40+
"inputSchema": {
41+
"type": "object",
42+
"properties": {
43+
"file_path": {
44+
"type": "string",
45+
"description": "Path to mapper XML file or directory"
46+
},
47+
"use_jdbc_connection": {
48+
"type": "boolean",
49+
"description": "Whether to use JDBC connection for type inference (default: false)"
50+
}
51+
},
52+
"required": [
53+
"file_path"
54+
]
55+
}
56+
},
57+
{
58+
"name": "parse_mapper_with_test",
59+
"description": "Parse MyBatis mapper XML files, extract SQL statements with parameter mocking, and test execution",
60+
"inputSchema": {
61+
"type": "object",
62+
"properties": {
63+
"file_path": {
64+
"type": "string",
65+
"description": "Path to mapper XML file or directory"
66+
}
67+
},
68+
"required": [
69+
"file_path"
70+
]
71+
}
72+
}
73+
],
74+
"examples": [
75+
{
76+
"name": "Basic SQL Extraction",
77+
"description": "Extract SQL from a MyBatis mapper XML file",
78+
"tool": "parse_mapper",
79+
"arguments": {
80+
"file_path": "/path/to/UserMapper.xml"
81+
}
82+
},
83+
{
84+
"name": "SQL Extraction with Parameter Mocking",
85+
"description": "Extract SQL with automatically mocked parameters",
86+
"tool": "parse_mapper_with_mock",
87+
"arguments": {
88+
"file_path": "/path/to/UserMapper.xml",
89+
"use_jdbc_connection": true
90+
}
91+
},
92+
{
93+
"name": "SQL Testing",
94+
"description": "Extract SQL, mock parameters, and test execution",
95+
"tool": "parse_mapper_with_test",
96+
"arguments": {
97+
"file_path": "/path/to/UserMapper.xml"
98+
}
99+
}
100+
],
101+
"installation": {
102+
"type": "jar",
103+
"downloadUrl": "https://github.com/handsomestWei/mybatis-mapper2sql-mcp-server/releases/download/v1.0.0/mapper2sql-mcp-server-1.0.0.jar",
104+
"requirements": {
105+
"java": ">=11",
106+
"memory": "512MB"
107+
}
108+
},
109+
"documentation": {
110+
"url": "https://github.com/handsomestWei/mybatis-mapper2sql-mcp-server/blob/main/README.md"
111+
}
112+
}

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@
149149
</executions>
150150
</plugin>
151151

152-
<!-- 复制system scope的依赖 -->
152+
<!-- 复制本地libs目录引用的system scope的依赖 -->
153153
<plugin>
154154
<groupId>org.apache.maven.plugins</groupId>
155155
<artifactId>maven-dependency-plugin</artifactId>

0 commit comments

Comments
 (0)