@amplify-studio/open-mcp 0.10.1 → 0.10.2
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/bin/open-mcp.js +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +33 -11
- package/package.json +4 -3
package/bin/open-mcp.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '../dist/index.js';
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -13,7 +13,7 @@ import { createConfigResource, createHelpResource } from "./resources.js";
|
|
|
13
13
|
import { createHttpServer } from "./http-server.js";
|
|
14
14
|
import { validateEnvironment as validateEnv } from "./error-handler.js";
|
|
15
15
|
// Use a static version string that will be updated by the version script
|
|
16
|
-
const packageVersion = "0.
|
|
16
|
+
const packageVersion = "0.10.2";
|
|
17
17
|
// Export the version for use in other modules
|
|
18
18
|
export { packageVersion };
|
|
19
19
|
// Server implementation
|
|
@@ -44,18 +44,27 @@ const server = new Server({
|
|
|
44
44
|
},
|
|
45
45
|
},
|
|
46
46
|
});
|
|
47
|
-
// List tools handler
|
|
47
|
+
// List tools handler - dynamically return available tools based on configuration
|
|
48
48
|
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
49
49
|
resetActivityTimeout();
|
|
50
50
|
logMessage(server, "debug", "Handling list_tools request");
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
51
|
+
const hasGateway = !!process.env.GATEWAY_URL;
|
|
52
|
+
const hasZhipuAI = !!process.env.ZHIPUAI_API_KEY;
|
|
53
|
+
const tools = [];
|
|
54
|
+
// Add gateway-dependent tools if GATEWAY_URL is configured
|
|
55
|
+
if (hasGateway) {
|
|
56
|
+
tools.push(WEB_SEARCH_TOOL, READ_URL_TOOL);
|
|
57
|
+
}
|
|
58
|
+
// Add AI tools if ZHIPUAI_API_KEY is configured
|
|
59
|
+
if (hasZhipuAI) {
|
|
60
|
+
tools.push(IMAGE_UNDERSTAND_TOOL, IMAGE_GENERATE_TOOL);
|
|
61
|
+
}
|
|
62
|
+
// If neither is configured, return all tools (for compatibility)
|
|
63
|
+
if (tools.length === 0) {
|
|
64
|
+
tools.push(WEB_SEARCH_TOOL, READ_URL_TOOL, IMAGE_UNDERSTAND_TOOL, IMAGE_GENERATE_TOOL);
|
|
65
|
+
}
|
|
66
|
+
logMessage(server, "info", `Available tools: ${tools.map(t => t.name).join(', ')}`);
|
|
67
|
+
return { tools };
|
|
59
68
|
});
|
|
60
69
|
// Call tool handler
|
|
61
70
|
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
@@ -66,6 +75,9 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
66
75
|
let result;
|
|
67
76
|
switch (name) {
|
|
68
77
|
case "searxng_web_search": {
|
|
78
|
+
if (!process.env.GATEWAY_URL) {
|
|
79
|
+
throw new Error("GATEWAY_URL environment variable is required for web search. Configure it or use image tools only.");
|
|
80
|
+
}
|
|
69
81
|
if (!isSearXNGWebSearchArgs(args)) {
|
|
70
82
|
throw new Error("Invalid arguments for web search");
|
|
71
83
|
}
|
|
@@ -73,6 +85,9 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
73
85
|
break;
|
|
74
86
|
}
|
|
75
87
|
case "web_url_read": {
|
|
88
|
+
if (!process.env.GATEWAY_URL) {
|
|
89
|
+
throw new Error("GATEWAY_URL environment variable is required for URL reading. Configure it or use image tools only.");
|
|
90
|
+
}
|
|
76
91
|
if (!isWebUrlReadArgs(args)) {
|
|
77
92
|
throw new Error("Invalid arguments for URL reading");
|
|
78
93
|
}
|
|
@@ -87,6 +102,9 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
87
102
|
break;
|
|
88
103
|
}
|
|
89
104
|
case "image_understand": {
|
|
105
|
+
if (!process.env.ZHIPUAI_API_KEY) {
|
|
106
|
+
throw new Error("ZHIPUAI_API_KEY environment variable is required for image understanding");
|
|
107
|
+
}
|
|
90
108
|
if (!isImageUnderstandArgs(args)) {
|
|
91
109
|
throw new Error("Invalid arguments for image understanding");
|
|
92
110
|
}
|
|
@@ -94,6 +112,9 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
94
112
|
break;
|
|
95
113
|
}
|
|
96
114
|
case "image_generate": {
|
|
115
|
+
if (!process.env.ZHIPUAI_API_KEY) {
|
|
116
|
+
throw new Error("ZHIPUAI_API_KEY environment variable is required for image generation");
|
|
117
|
+
}
|
|
97
118
|
if (!isImageGenerateArgs(args)) {
|
|
98
119
|
throw new Error("Invalid arguments for image generation");
|
|
99
120
|
}
|
|
@@ -228,7 +249,8 @@ async function main() {
|
|
|
228
249
|
}
|
|
229
250
|
// Check for HTTP transport mode
|
|
230
251
|
const httpPort = process.env.MCP_HTTP_PORT;
|
|
231
|
-
const
|
|
252
|
+
const hasZhipuAI = !!process.env.ZHIPUAI_API_KEY;
|
|
253
|
+
const gatewayUrlDisplay = process.env.GATEWAY_URL || (hasZhipuAI ? "Not configured (optional, AI tools available)" : "Not configured (required for search/URL tools)");
|
|
232
254
|
if (httpPort) {
|
|
233
255
|
const port = parseInt(httpPort, 10);
|
|
234
256
|
if (isNaN(port) || port < 1 || port > 65535) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@amplify-studio/open-mcp",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.2",
|
|
4
4
|
"description": "Open MCP server for web search and URL reading via Gateway API",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Amplify Studio (https://github.com/amplify-studio)",
|
|
@@ -24,11 +24,12 @@
|
|
|
24
24
|
],
|
|
25
25
|
"type": "module",
|
|
26
26
|
"bin": {
|
|
27
|
-
"open-mcp": "
|
|
27
|
+
"open-mcp": "bin/open-mcp.js"
|
|
28
28
|
},
|
|
29
29
|
"main": "dist/index.js",
|
|
30
30
|
"files": [
|
|
31
|
-
"dist"
|
|
31
|
+
"dist",
|
|
32
|
+
"bin"
|
|
32
33
|
],
|
|
33
34
|
"engines": {
|
|
34
35
|
"node": ">=20"
|