nx-mcp-server 1.0.2 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.dockerignore +5 -0
- package/Dockerfile +19 -0
- package/package.json +1 -1
- package/src/index.js +2 -2
- package/src/tools/smart.js +10 -16
package/.dockerignore
ADDED
package/Dockerfile
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
FROM node:18-alpine
|
|
2
|
+
|
|
3
|
+
WORKDIR /app
|
|
4
|
+
|
|
5
|
+
COPY package*.json ./
|
|
6
|
+
RUN npm ci --omit=dev
|
|
7
|
+
|
|
8
|
+
COPY src/ ./src/
|
|
9
|
+
COPY config.json ./
|
|
10
|
+
|
|
11
|
+
ENV MCP_TRANSPORT=http
|
|
12
|
+
ENV MCP_PORT=3000
|
|
13
|
+
|
|
14
|
+
EXPOSE 3000
|
|
15
|
+
|
|
16
|
+
HEALTHCHECK --interval=30s --timeout=3s \
|
|
17
|
+
CMD wget -qO- http://localhost:3000/health || exit 1
|
|
18
|
+
|
|
19
|
+
CMD ["node", "src/index.js"]
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {Server} from '@modelcontextprotocol/sdk/server/index.js';
|
|
3
3
|
import {StdioServerTransport} from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
4
|
-
import {CallToolRequestSchema, ListToolsRequestSchema} from '@modelcontextprotocol/sdk/types.js';
|
|
4
|
+
import {CallToolRequestSchema, ListToolsRequestSchema, isInitializeRequest} from '@modelcontextprotocol/sdk/types.js';
|
|
5
5
|
import {generateSmart} from './tools/smart.js';
|
|
6
6
|
import {generateBasic} from './tools/basic.js';
|
|
7
7
|
import {generateQrcode} from './tools/qrcode.js';
|
|
@@ -260,7 +260,7 @@ async function startHttp(){
|
|
|
260
260
|
|
|
261
261
|
if(sessionId&&transports[sessionId]){
|
|
262
262
|
transport=transports[sessionId];
|
|
263
|
-
}else if(!sessionId){
|
|
263
|
+
}else if(!sessionId&&isInitializeRequest(req.body)){
|
|
264
264
|
// 新会话初始化
|
|
265
265
|
const eventStore={
|
|
266
266
|
events:[],
|
package/src/tools/smart.js
CHANGED
|
@@ -21,22 +21,16 @@ export async function generateSmart(args){
|
|
|
21
21
|
const buf=Buffer.from(res.data);
|
|
22
22
|
const saved=await saveOutput(buf,'ai_generated.png',args.outputDir,'url');
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
results.push({
|
|
35
|
-
...saved,
|
|
36
|
-
width:args.width||1024,
|
|
37
|
-
height:args.height||1024,
|
|
38
|
-
});
|
|
39
|
-
}
|
|
24
|
+
// 始终附带 base64,确保远程部署时用户也能看到图片
|
|
25
|
+
const b64=buf.toString('base64');
|
|
26
|
+
const mime='image/png';
|
|
27
|
+
results.push({
|
|
28
|
+
...saved,
|
|
29
|
+
base64:`data:${mime};base64,${b64}`,
|
|
30
|
+
mimeType:mime,
|
|
31
|
+
width:args.width||1024,
|
|
32
|
+
height:args.height||1024,
|
|
33
|
+
});
|
|
40
34
|
}
|
|
41
35
|
|
|
42
36
|
return {
|